|
|
@ -1,16 +1,18 @@ |
|
|
|
package com.fr.design.style.color; |
|
|
|
package com.fr.design.style.color; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.FineColor; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.Box; |
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
@ -19,8 +21,6 @@ import java.awt.Color; |
|
|
|
import java.awt.Cursor; |
|
|
|
import java.awt.Cursor; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.GridLayout; |
|
|
|
import java.awt.GridLayout; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -32,57 +32,67 @@ import java.util.ArrayList; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
private static final long serialVersionUID = -8634152305687249392L; |
|
|
|
private static final long serialVersionUID = -8634152305687249392L; |
|
|
|
|
|
|
|
private static final float BRIGHTNESS_VALUE = 0.15F; |
|
|
|
|
|
|
|
private static final float PURITY_VALUE = 0.1F; |
|
|
|
|
|
|
|
|
|
|
|
private Color color = null; // color
|
|
|
|
private FineColor color = null; // color
|
|
|
|
// color setting action.
|
|
|
|
// color setting action.
|
|
|
|
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>(); |
|
|
|
private final ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 是否支持透明
|
|
|
|
// 是否支持透明
|
|
|
|
private boolean isSupportTransparent; |
|
|
|
private boolean isSupportTransparent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isSupportThemeColor; |
|
|
|
|
|
|
|
|
|
|
|
public final static int TRANSPARENT_WINDOW_HEIGHT = 165; |
|
|
|
public final static int TRANSPARENT_WINDOW_HEIGHT = 165; |
|
|
|
public final static int WINDOW_HEIGHT = 150; |
|
|
|
public final static int WINDOW_HEIGHT = 150; |
|
|
|
|
|
|
|
|
|
|
|
// 最近使用颜色
|
|
|
|
// 最近使用颜色
|
|
|
|
private UsedColorPane usedColorPane; |
|
|
|
private final NewUsedColorPane usedColorPane; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme){ |
|
|
|
|
|
|
|
return new NewColorSelectPane(true, supportTheme); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor. |
|
|
|
* Constructor. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public NewColorSelectPane() { |
|
|
|
public NewColorSelectPane() { |
|
|
|
this(false); |
|
|
|
this(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public NewColorSelectPane(boolean isSupportTransparent) { |
|
|
|
|
|
|
|
this(isSupportTransparent, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor. |
|
|
|
* Constructor. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
NewColorSelectPane(boolean isSupportTransparent) { |
|
|
|
public NewColorSelectPane(boolean isSupportTransparent, boolean isSupportThemeColor) { |
|
|
|
|
|
|
|
this.isSupportThemeColor = isSupportThemeColor; |
|
|
|
initSelectButton(isSupportTransparent); |
|
|
|
initSelectButton(isSupportTransparent); |
|
|
|
|
|
|
|
|
|
|
|
// center
|
|
|
|
// center
|
|
|
|
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
|
|
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
|
|
|
|
|
|
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4)); |
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
// 第一行
|
|
|
|
JPanel menuColorPane1 = getMenuColorPane(); |
|
|
|
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
|
|
|
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); |
|
|
|
|
|
|
|
row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
|
|
|
|
|
|
|
|
centerPane.add(row1Pane); |
|
|
|
|
|
|
|
// 最近使用
|
|
|
|
|
|
|
|
usedColorPane = new UsedColorPane(1, 8, 1, this, true, false); |
|
|
|
|
|
|
|
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); |
|
|
|
|
|
|
|
row1Pane.add(usedColorPane.getPane()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel menuColorPane1 = new JPanel(); |
|
|
|
|
|
|
|
centerPane.add(menuColorPane1); |
|
|
|
centerPane.add(menuColorPane1); |
|
|
|
|
|
|
|
if(isSupportThemeColor){ |
|
|
|
menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1)); |
|
|
|
initThemeColorPane(menuColorPane1); |
|
|
|
menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); |
|
|
|
}else { |
|
|
|
for (int i = 0; i < ColorFactory.MenuColors.length; i++) { |
|
|
|
initMenuColorPane(menuColorPane1); |
|
|
|
menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
centerPane.add(Box.createVerticalStrut(1)); |
|
|
|
// 增加最近使用 pane
|
|
|
|
|
|
|
|
JPanel row1Pane = new JPanel(new BorderLayout(0, 5)); |
|
|
|
|
|
|
|
row1Pane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
|
|
|
|
|
|
|
row1Pane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Used")), BorderLayout.NORTH); |
|
|
|
|
|
|
|
centerPane.add(row1Pane); |
|
|
|
|
|
|
|
// 最近使用
|
|
|
|
|
|
|
|
usedColorPane = new NewUsedColorPane(8, this, selectRealTime()); |
|
|
|
|
|
|
|
usedColorPane.setPreferredSize(new Dimension(168, 16)); |
|
|
|
|
|
|
|
row1Pane.add(usedColorPane.getPane(), BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
// mod by anchore 16/11/16
|
|
|
|
// mod by anchore 16/11/16
|
|
|
|
final UIButton customButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_More_Color")); |
|
|
|
final UIButton customButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_More_Color")); |
|
|
@ -99,12 +109,58 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
|
|
|
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
|
|
|
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
JPanel centerPane1 = new JPanel(new BorderLayout(0, 0)); |
|
|
|
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8)); |
|
|
|
centerPane1.setBorder(BorderFactory.createEmptyBorder(9, 0, 11, 0)); |
|
|
|
centerPane1.add(customButton, BorderLayout.NORTH); |
|
|
|
centerPane1.add(customButton, BorderLayout.CENTER); |
|
|
|
|
|
|
|
customButton.setPreferredSize(new Dimension(197, 20)); |
|
|
|
centerPane.add(centerPane1); |
|
|
|
centerPane.add(centerPane1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initThemeColorPane(JPanel menuColorPane){ |
|
|
|
|
|
|
|
menuColorPane.setLayout(new GridLayout(1, 8, 3, 0)); |
|
|
|
|
|
|
|
//todo 暂时先写死,后续对接的时候从主体里面拿主题配色
|
|
|
|
|
|
|
|
Color[] colorArray = new Color[]{Color.decode("#FFFFFF"), Color.decode("#CCCCCC"), |
|
|
|
|
|
|
|
Color.decode("#E6A48A"), Color.decode("#E68A8A"), Color.gray, Color.green, Color.DARK_GRAY, Color.CYAN, Color.YELLOW, Color.lightGray}; |
|
|
|
|
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
|
|
|
|
Color color = colorArray[i]; |
|
|
|
|
|
|
|
boolean isDefaultColor = (i == 0 || i ==1); |
|
|
|
|
|
|
|
JPanel jPanel = new JPanel(new GridLayout(5, 1, 0, 3)); |
|
|
|
|
|
|
|
jPanel.add(new FineColorCell(color, this, i, 0)); |
|
|
|
|
|
|
|
jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 1)); |
|
|
|
|
|
|
|
jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 2)); |
|
|
|
|
|
|
|
jPanel.add(new FineColorCell(color = saturationDown(color, isDefaultColor), this, i, 3)); |
|
|
|
|
|
|
|
jPanel.add(new FineColorCell(saturationDown(color, isDefaultColor), this, i, 4)); |
|
|
|
|
|
|
|
menuColorPane.add(jPanel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 调整明度和纯度,默认色只调整明度 |
|
|
|
|
|
|
|
* @param color |
|
|
|
|
|
|
|
* @param isDefaultColor |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static Color saturationDown(Color color, boolean isDefaultColor) { |
|
|
|
|
|
|
|
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); |
|
|
|
|
|
|
|
if (!isDefaultColor) { |
|
|
|
|
|
|
|
hsb[1] += PURITY_VALUE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
hsb[2] -= BRIGHTNESS_VALUE; |
|
|
|
|
|
|
|
return Color.getHSBColor(hsb[0], hsb[1], hsb[2]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initMenuColorPane(JPanel menuColorPane){ |
|
|
|
|
|
|
|
menuColorPane.setLayout(new GridLayout(5, 8, 1, 1)); |
|
|
|
|
|
|
|
menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); |
|
|
|
|
|
|
|
Color[] colorArray = this.getColorArray(); |
|
|
|
|
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
|
|
|
|
Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i]; |
|
|
|
|
|
|
|
menuColorPane.add(new ColorCell(color, this)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isSupportTransparent() { |
|
|
|
public boolean isSupportTransparent() { |
|
|
|
return isSupportTransparent; |
|
|
|
return isSupportTransparent; |
|
|
|
} |
|
|
|
} |
|
|
@ -113,6 +169,10 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
isSupportTransparent = supportTransparent; |
|
|
|
isSupportTransparent = supportTransparent; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean selectRealTime() { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void initSelectButton(boolean isSupportTransparent){ |
|
|
|
protected void initSelectButton(boolean isSupportTransparent){ |
|
|
|
this.isSupportTransparent = isSupportTransparent; |
|
|
|
this.isSupportTransparent = isSupportTransparent; |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
@ -120,21 +180,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
if (isSupportTransparent) { |
|
|
|
if (isSupportTransparent) { |
|
|
|
UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); |
|
|
|
UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); |
|
|
|
this.add(transparentButton, BorderLayout.NORTH); |
|
|
|
this.add(transparentButton, BorderLayout.NORTH); |
|
|
|
transparentButton.addActionListener(new ActionListener() { |
|
|
|
transparentButton.addActionListener(e -> doTransparent()); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
doTransparent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 添加监听 |
|
|
|
* 添加监听 |
|
|
|
* |
|
|
|
* @param changeListener 监听 |
|
|
|
* @param 监听列表 Add change listener. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void addChangeListener(ChangeListener changeListener) { |
|
|
|
public void addChangeListener(ChangeListener changeListener) { |
|
|
|
this.colorChangeListenerList.add(changeListener); |
|
|
|
this.colorChangeListenerList.add(changeListener); |
|
|
@ -151,7 +204,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
* @return 颜色 |
|
|
|
* @return 颜色 |
|
|
|
* Return the color. |
|
|
|
* Return the color. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Color getColor() { |
|
|
|
public FineColor getColor() { |
|
|
|
return color; |
|
|
|
return color; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -163,7 +216,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
public Color getNotNoneColor() { |
|
|
|
public Color getNotNoneColor() { |
|
|
|
if (color == null) { |
|
|
|
if (color == null) { |
|
|
|
setColor(Color.WHITE); |
|
|
|
setColor(Color.WHITE); |
|
|
|
return Color.WHITE; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return color; |
|
|
|
return color; |
|
|
|
} |
|
|
|
} |
|
|
@ -175,27 +227,33 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setColor(Color color) { |
|
|
|
public void setColor(Color color) { |
|
|
|
this.color = color; |
|
|
|
FineColor fineColor; |
|
|
|
|
|
|
|
if (color == null) { |
|
|
|
|
|
|
|
fineColor = null; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
fineColor = color instanceof FineColor ? (FineColor) color : new FineColor(color); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setFineColor(fineColor); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setFineColor(FineColor fineColor){ |
|
|
|
|
|
|
|
this.color = fineColor; |
|
|
|
|
|
|
|
|
|
|
|
// fire color change.
|
|
|
|
// fire color change.
|
|
|
|
if (!colorChangeListenerList.isEmpty()) { |
|
|
|
if (!colorChangeListenerList.isEmpty()) { |
|
|
|
ChangeEvent evt = new ChangeEvent(this); |
|
|
|
ChangeEvent evt = new ChangeEvent(this); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < colorChangeListenerList.size(); i++) { |
|
|
|
for (ChangeListener changeListener : colorChangeListenerList) { |
|
|
|
this.colorChangeListenerList.get(i).stateChanged(evt); |
|
|
|
changeListener.stateChanged(evt); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); |
|
|
|
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); |
|
|
|
this.repaint(); |
|
|
|
this.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置颜色 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param 颜色位置 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void colorSetted(ColorCell colorCell) { |
|
|
|
public void colorSetted(ColorCell colorCell) { |
|
|
|
|
|
|
|
this.updateUsedColor(); |
|
|
|
colorCell.repaint(); |
|
|
|
colorCell.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -203,18 +261,28 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
setColor(null); |
|
|
|
setColor(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Color[] getColorArray() { |
|
|
|
|
|
|
|
return ColorFactory.MenuColors; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected JPanel getMenuColorPane() { |
|
|
|
|
|
|
|
return new JPanel(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void customButtonPressed() { |
|
|
|
protected void customButtonPressed() { |
|
|
|
// 颜色选择器
|
|
|
|
// 颜色选择器
|
|
|
|
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); |
|
|
|
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); |
|
|
|
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); |
|
|
|
Color color = getColor() == null ? Color.WHITE : getColor().getColor(); |
|
|
|
|
|
|
|
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, color, this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
if (isSupportTransparent) { |
|
|
|
if (isSupportTransparent) { |
|
|
|
return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT); |
|
|
|
return new Dimension(197, 207); |
|
|
|
} |
|
|
|
} |
|
|
|
return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT); |
|
|
|
return new Dimension(197, 192); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -224,5 +292,72 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
usedColorPane.updateUsedColor(); |
|
|
|
usedColorPane.updateUsedColor(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NewUsedColorPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 最近使用面板列数
|
|
|
|
|
|
|
|
private int columns; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 最近使用面板
|
|
|
|
|
|
|
|
private JPanel pane; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ColorSelectable selectable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean setColorRealTime; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JPanel getPane(){ |
|
|
|
|
|
|
|
return this.pane; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public NewUsedColorPane(int columns, ColorSelectable selectable, boolean setColorRealTime){ |
|
|
|
|
|
|
|
this.columns = columns; |
|
|
|
|
|
|
|
this.selectable = selectable; |
|
|
|
|
|
|
|
this.setColorRealTime = setColorRealTime; |
|
|
|
|
|
|
|
initialComponents(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initialComponents() { |
|
|
|
|
|
|
|
int total = columns; |
|
|
|
|
|
|
|
JPanel panel = new JPanel(); |
|
|
|
|
|
|
|
panel.setLayout(new GridLayout(1, columns + 2, 3, 3)); |
|
|
|
|
|
|
|
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
|
|
|
|
//最近使用颜色
|
|
|
|
|
|
|
|
Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); |
|
|
|
|
|
|
|
int size = colors.length; |
|
|
|
|
|
|
|
for (int i = 0; i < total; i++) { |
|
|
|
|
|
|
|
Color color = i < size ? colors[size - i - 1] : |
|
|
|
|
|
|
|
UsedColorPane.DEFAULT_COLOR; |
|
|
|
|
|
|
|
panel.add(new ColorCell(color == null ? UsedColorPane.DEFAULT_COLOR : color, selectable)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 取色按钮
|
|
|
|
|
|
|
|
JButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime); |
|
|
|
|
|
|
|
panel.add(pickColorButton); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ColorCell cc = new ColorCell(UsedColorPane.DEFAULT_COLOR, selectable); |
|
|
|
|
|
|
|
cc.setVisible(false); |
|
|
|
|
|
|
|
panel.add(cc); |
|
|
|
|
|
|
|
this.pane = panel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 更新最近使用颜色 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void updateUsedColor() { |
|
|
|
|
|
|
|
int total = columns ; |
|
|
|
|
|
|
|
Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); |
|
|
|
|
|
|
|
int size = colors.length; |
|
|
|
|
|
|
|
for (int i = 0; i < total; i++) { |
|
|
|
|
|
|
|
ColorCell cell = (ColorCell) this.pane.getComponent(i); |
|
|
|
|
|
|
|
Color color = i < size ? colors[size - i - 1] : UsedColorPane.DEFAULT_COLOR; |
|
|
|
|
|
|
|
cell.setColor(color == null ? UsedColorPane.DEFAULT_COLOR : color); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|