Browse Source

REPORT-1096 取色板=>将“最近使用的颜色”面板的色块改为6个;修改取色 器按钮背景为白色

master
plough 8 years ago
parent
commit
9421bfc288
  1. 2
      designer_base/src/com/fr/design/style/color/ColorSelectPane.java
  2. 3
      designer_base/src/com/fr/design/style/color/CustomChooserPanel.java
  3. 2
      designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
  4. 48
      designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java
  5. 16
      designer_base/src/com/fr/design/style/color/UsedColorPane.java

2
designer_base/src/com/fr/design/style/color/ColorSelectPane.java

@ -111,7 +111,7 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
// 最近使用
UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, true, ColorSelectConfigManager.getInstance().getColors(),this);
UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, true);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane());
return row1Pane;

3
designer_base/src/com/fr/design/style/color/CustomChooserPanel.java

@ -21,6 +21,7 @@ import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import com.fr.design.gui.ibutton.SpecialUIButton;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
@ -706,7 +707,7 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec
mainPanel.add(hexPanel, BorderLayout.SOUTH);
JPanel rightPane = new JPanel(new BorderLayout());
UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON18, true);
SpecialUIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON18, true);
JPanel blankArea = new JPanel();
blankArea.setPreferredSize(new Dimension(100, 175));
rightPane.add(blankArea, BorderLayout.CENTER);

2
designer_base/src/com/fr/design/style/color/NewColorSelectPane.java

@ -85,7 +85,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
centerPane.add(row1Pane);
// 最近使用
usedColorPane = new UsedColorPane(1, 8, 1, true, ColorSelectConfigManager.getInstance().getColors(),this);
usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, false);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane());

48
designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java

@ -1,7 +1,10 @@
package com.fr.design.style.color;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.SpecialUIButton;
import javax.swing.*;
import javax.swing.plaf.ButtonUI;
import java.awt.*;
import java.awt.event.*;
@ -9,22 +12,27 @@ import java.awt.event.*;
* Created by plough on 2016/12/22.
*/
public class PickColorButtonFactory {
private static int iconSize;
private static IconType iconType;
private static Image iconImage;
public static UIButton getPickColorButton(ColorSelectable colorSelectable, IconType iconType) {
public static SpecialUIButton getPickColorButton(ColorSelectable colorSelectable, IconType iconType) {
return getPickColorButton(colorSelectable, iconType, false);
}
public static UIButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final Boolean setColorRealTime) {
UIButton pickColorButton = new UIButton();
public static SpecialUIButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final boolean setColorRealTime) {
SpecialUIButton pickColorButton = new SpecialUIButton(new WhiteButtonUI());
PickColorButtonFactory.iconType = iconType;
if (iconType == IconType.ICON16) {
pickColorButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker16.png"));
pickColorButton.setPreferredSize(new Dimension(16, 16));
iconImage = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPicker16.png");
iconSize = 16;
} else {
pickColorButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker18.png"));
pickColorButton.setPreferredSize(new Dimension(18, 18));
iconImage = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPicker18.png");
iconSize = 18;
pickColorButton.setBorderPainted(false);
}
pickColorButton.setPreferredSize(new Dimension(iconSize, iconSize));
pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
pickColorButton.addMouseListener(new MouseAdapter() {
@ -41,4 +49,28 @@ public class PickColorButtonFactory {
public enum IconType {
ICON16, ICON18
}
private static class WhiteButtonUI extends ButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
Dimension size = c.getSize();
g.setColor(Color.white);
g.fillRoundRect(0, 0, size.width - 1, size.height - 1, 1, 1);
g.setColor(new Color(153, 153, 153)); // #999999
g.drawRoundRect(0, 0, size.width - 1, size.height - 1, 1, 1);
if (iconType == IconType.ICON16) {
g.drawImage(
iconImage,
(size.width - iconImage.getWidth(null)) / 2,
(size.height - iconImage.getHeight(null)) / 2,
iconImage.getWidth(null),
iconImage.getHeight(null),
null
);
} else {
g.drawImage(iconImage, 0, 0, iconSize, iconSize, null);
}
}
}
}

16
designer_base/src/com/fr/design/style/color/UsedColorPane.java

@ -7,7 +7,7 @@ import javax.swing.BorderFactory;
import javax.swing.JPanel;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.SpecialUIButton;
public class UsedColorPane extends BasicPane{
@ -21,6 +21,8 @@ public class UsedColorPane extends BasicPane{
private int reserveCells;
// 是否需要取色器按钮
private boolean needPickColorButton;
// 是否在取色时实时设定颜色
private boolean setColorRealTime;
// 最近使用颜色
private Object[] colors;
// 最近使用面板
@ -46,21 +48,23 @@ public class UsedColorPane extends BasicPane{
* @param rows
* @param columns
* @param reserveCells 留白的单元格个数
* @param needPickColorButton 是否需要加上取色器按钮
* @param colors 最近使用的颜色
* @param needPickColorButton 是否需要加上取色器按钮
* @param setColorRealTime 取色器是否实时设定颜色
*/
public UsedColorPane(int rows,int columns,int reserveCells, boolean needPickColorButton, Object[] colors,ColorSelectable selectable){
public UsedColorPane(int rows,int columns,int reserveCells, Object[] colors, ColorSelectable selectable, boolean needPickColorButton, boolean setColorRealTime){
this.columns = columns;
this.rows = rows;
this.reserveCells = reserveCells;
this.needPickColorButton = needPickColorButton;
this.colors = colors;
this.selectable = selectable;
this.needPickColorButton = needPickColorButton;
this.setColorRealTime = setColorRealTime;
initialComponents();
}
public UsedColorPane(int rows,int columns, Object[] colors,ColorSelectable selectable){
this(rows, columns, 0, false, colors, selectable);
this(rows, columns, 0, colors, selectable, false, false);
}
private void initialComponents(){
@ -74,7 +78,7 @@ public class UsedColorPane extends BasicPane{
int i = 0;
if (needPickColorButton) {
// 取色按钮
UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, true);
SpecialUIButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime);
panel.add(pickColorButton);
i++;
this.reserveCells += 1;

Loading…
Cancel
Save