|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.fr.design.style.color; |
|
|
|
|
|
|
|
|
|
import com.fr.base.FineColor; |
|
|
|
|
import com.fr.base.theme.FineColorDeriveState; |
|
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
@ -37,8 +38,11 @@ import java.util.List;
|
|
|
|
|
*/ |
|
|
|
|
public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
|
private static final long serialVersionUID = -8634152305687249392L; |
|
|
|
|
private static final float BRIGHTNESS_VALUE = 0.15F; |
|
|
|
|
private static final float PURITY_VALUE = 0.1F; |
|
|
|
|
|
|
|
|
|
private static final int WIDTH = 197; |
|
|
|
|
private static final int HEIGHT = 250; |
|
|
|
|
//颜色衍生的数量
|
|
|
|
|
private static final int DEFAULT_DERIVE_COUNT = 5; |
|
|
|
|
|
|
|
|
|
private FineColor color = null; // color
|
|
|
|
|
// color setting action.
|
|
|
|
@ -49,15 +53,12 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
|
|
|
|
|
private boolean isSupportThemeColor; |
|
|
|
|
|
|
|
|
|
public final static int TRANSPARENT_WINDOW_HEIGHT = 165; |
|
|
|
|
public final static int WINDOW_HEIGHT = 150; |
|
|
|
|
|
|
|
|
|
// 最近使用颜色
|
|
|
|
|
private final NewUsedColorPane usedColorPane; |
|
|
|
|
private final JPanel menuColorPane; |
|
|
|
|
private ColorCell[][] themeColorCellGrid; |
|
|
|
|
|
|
|
|
|
public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme){ |
|
|
|
|
public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme) { |
|
|
|
|
return new NewColorSelectPane(true, supportTheme); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -80,14 +81,16 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
initSelectButton(isSupportTransparent); |
|
|
|
|
// center
|
|
|
|
|
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
|
|
|
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4)); |
|
|
|
|
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0, 4)); |
|
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
menuColorPane = getMenuColorPane(); |
|
|
|
|
centerPane.add(menuColorPane); |
|
|
|
|
if(isSupportThemeColor){ |
|
|
|
|
initThemeColorPane(); |
|
|
|
|
}else { |
|
|
|
|
|
|
|
|
|
if (isSupportThemeColor) { |
|
|
|
|
JPanel themePane = initThemeColorPane(); |
|
|
|
|
centerPane.add(themePane); |
|
|
|
|
} else { |
|
|
|
|
centerPane.add(menuColorPane); |
|
|
|
|
initMenuColorPane(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -129,7 +132,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
centerPane.add(centerPane1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel createStandardColorPane(){ |
|
|
|
|
private JPanel createStandardColorPane() { |
|
|
|
|
JPanel jPanel = new JPanel(new GridLayout(1, 10, 3, 0)); |
|
|
|
|
Color[] colorArray = ColorFactory.STANDARD_COLORS; |
|
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
@ -138,19 +141,21 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
return jPanel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initThemeColorPane(){ |
|
|
|
|
private JPanel initThemeColorPane() { |
|
|
|
|
menuColorPane.removeAll(); |
|
|
|
|
JPanel themeColorPane = new JPanel(new BorderLayout(0, 5)); |
|
|
|
|
themeColorPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
|
themeColorPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Theme_Color")), BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
themeColorPane.add(menuColorPane, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
menuColorPane.setLayout(new BorderLayout(0, 10)); |
|
|
|
|
JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0)); |
|
|
|
|
JPanel centerPane = new JPanel(new GridLayout(1, 8, 3, 0)); |
|
|
|
|
menuColorPane.add(northPane, BorderLayout.NORTH); |
|
|
|
|
menuColorPane.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
Color[] colorArray = new Color[] { |
|
|
|
|
// 2列灰度色
|
|
|
|
|
Color.decode("#B3B3B3"), |
|
|
|
|
Color.decode("#808080"), |
|
|
|
|
|
|
|
|
|
Color[] colorArray = new Color[]{ |
|
|
|
|
// 8列主题色
|
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
@ -160,20 +165,22 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
|
|
|
|
|
|
// 2列灰度色
|
|
|
|
|
Color.decode("#333333"), |
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (themeColorCellGrid == null) { |
|
|
|
|
themeColorCellGrid = new ColorCell[colorArray.length][5]; |
|
|
|
|
themeColorCellGrid = new ColorCell[colorArray.length][DEFAULT_DERIVE_COUNT]; |
|
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
|
ColorCell[] colorCellColumn = new ColorCell[5]; |
|
|
|
|
boolean isDefaultColor = (i == 0 || i == 1); |
|
|
|
|
ColorCell[] colorCellColumn = new ColorCell[DEFAULT_DERIVE_COUNT]; |
|
|
|
|
boolean isDefaultColor = (i == colorArray.length - 1 || i == colorArray.length - 2); |
|
|
|
|
Color color = colorArray[i]; |
|
|
|
|
colorCellColumn[0] = createFineColorCell(color, isDefaultColor, i, 2); |
|
|
|
|
colorCellColumn[2] = createFineColorCell(color = saturationDown(color, isDefaultColor, true), isDefaultColor, i, 1); |
|
|
|
|
colorCellColumn[1] = createFineColorCell(saturationDown(color, isDefaultColor, true), isDefaultColor, i, 0); |
|
|
|
|
color = colorArray[i]; |
|
|
|
|
colorCellColumn[3] = createFineColorCell(color = saturationDown(color, isDefaultColor, false), isDefaultColor, i, 3); |
|
|
|
|
colorCellColumn[4] = createFineColorCell(saturationDown(color, isDefaultColor, false), isDefaultColor, i, 4); |
|
|
|
|
Color[] deriveColorArr = FineColorDeriveState.getDeriveColorArr(color, isDefaultColor, DEFAULT_DERIVE_COUNT); |
|
|
|
|
for (int j = 0; j < deriveColorArr.length; j++) { |
|
|
|
|
colorCellColumn[j] = createFineColorCell(deriveColorArr[j], isDefaultColor, i, j); |
|
|
|
|
} |
|
|
|
|
themeColorCellGrid[i] = colorCellColumn; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -182,15 +189,15 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
northPane.add(themeColorCellGrid[i][0]); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
|
JPanel columnPane = new JPanel(new GridLayout(4, 1, 0, 3)); |
|
|
|
|
columnPane.add(themeColorCellGrid[i][1]); |
|
|
|
|
columnPane.add(themeColorCellGrid[i][2]); |
|
|
|
|
columnPane.add(themeColorCellGrid[i][3]); |
|
|
|
|
columnPane.add(themeColorCellGrid[i][4]); |
|
|
|
|
JPanel columnPane = new JPanel(new GridLayout(DEFAULT_DERIVE_COUNT - 1, 1, 0, 3)); |
|
|
|
|
for (int j = 1; j < DEFAULT_DERIVE_COUNT; j++) { |
|
|
|
|
columnPane.add(themeColorCellGrid[i][j]); |
|
|
|
|
} |
|
|
|
|
centerPane.add(columnPane); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshThemeMenuColorPane(); |
|
|
|
|
return themeColorPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void refreshThemeMenuColorPane() { |
|
|
|
@ -198,7 +205,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
if (TemplateThemeProfileDialog.isEditingTheme()) { |
|
|
|
|
standardColors = TemplateThemeProfileDialog.getEditingColorScheme(); |
|
|
|
|
} else { |
|
|
|
|
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (template != null) { |
|
|
|
|
TemplateTheme theme = template.getTemplateTheme(); |
|
|
|
|
if (theme != null) { |
|
|
|
@ -206,43 +213,24 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (standardColors == null || standardColors.size() != 8) { |
|
|
|
|
if (standardColors == null || standardColors.size() < 8) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 2; i < themeColorCellGrid.length; i++) { |
|
|
|
|
Color color = standardColors.get(i - 2); |
|
|
|
|
|
|
|
|
|
themeColorCellGrid[i][0].setColor(color); |
|
|
|
|
themeColorCellGrid[i][2].setColor(color = saturationDown(color, false, true)); |
|
|
|
|
themeColorCellGrid[i][1].setColor(saturationDown(color, false, true)); |
|
|
|
|
|
|
|
|
|
color = standardColors.get(i - 2); |
|
|
|
|
themeColorCellGrid[i][3].setColor(color = saturationDown(color, false, false)); |
|
|
|
|
themeColorCellGrid[i][4].setColor(saturationDown(color, false, false)); |
|
|
|
|
for (int i = 0; i < themeColorCellGrid.length - 2; i++) { |
|
|
|
|
Color color = standardColors.get(i); |
|
|
|
|
Color[] deriveColorArr = FineColorDeriveState.getDeriveColorArr(color, false, DEFAULT_DERIVE_COUNT); |
|
|
|
|
for (int j = 0; j < deriveColorArr.length; j++) { |
|
|
|
|
themeColorCellGrid[i][j].setColor(deriveColorArr[j]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private FineColorCell createFineColorCell(Color color, boolean isDefaultColor, int x, int y) { |
|
|
|
|
return isDefaultColor ? new FineColorCell(color, this) : new FineColorCell(color, this, x - 2, y); |
|
|
|
|
return isDefaultColor ? new FineColorCell(color, this) : new FineColorCell(color, this, x, y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 调整明度和纯度,默认色只调整明度 |
|
|
|
|
* @param color |
|
|
|
|
* @param isDefaultColor |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static Color saturationDown(Color color, boolean isDefaultColor, boolean isLight) { |
|
|
|
|
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); |
|
|
|
|
if (!isDefaultColor) { |
|
|
|
|
hsb[1] = isLight ? Math.max(0, hsb[1] - PURITY_VALUE) : Math.min(1, hsb[1] + PURITY_VALUE); |
|
|
|
|
} |
|
|
|
|
hsb[2] = isLight ? Math.min(1, hsb[2] + BRIGHTNESS_VALUE) : Math.max(0, hsb[2] - BRIGHTNESS_VALUE); |
|
|
|
|
Color color1 = Color.getHSBColor(hsb[0], hsb[1], hsb[2]); |
|
|
|
|
return color1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initMenuColorPane() { |
|
|
|
|
menuColorPane.setLayout(new GridLayout(5, 8, 3, 3)); |
|
|
|
@ -266,7 +254,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void initSelectButton(boolean isSupportTransparent){ |
|
|
|
|
protected void initSelectButton(boolean isSupportTransparent) { |
|
|
|
|
this.isSupportTransparent = isSupportTransparent; |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); |
|
|
|
@ -280,6 +268,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加监听 |
|
|
|
|
* |
|
|
|
|
* @param changeListener 监听 |
|
|
|
|
*/ |
|
|
|
|
public void addChangeListener(ChangeListener changeListener) { |
|
|
|
@ -332,7 +321,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
setFineColor(fineColor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setFineColor(FineColor fineColor){ |
|
|
|
|
private void setFineColor(FineColor fineColor) { |
|
|
|
|
this.color = fineColor; |
|
|
|
|
|
|
|
|
|
// fire color change.
|
|
|
|
@ -343,7 +332,9 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
changeListener.stateChanged(evt); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); |
|
|
|
|
if (color != null) { |
|
|
|
|
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color.getColor()); |
|
|
|
|
} |
|
|
|
|
this.repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -375,10 +366,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
int height = HEIGHT; |
|
|
|
|
if (isSupportTransparent) { |
|
|
|
|
return new Dimension(197, 265); |
|
|
|
|
height += 15; |
|
|
|
|
} |
|
|
|
|
if (isSupportThemeColor) { |
|
|
|
|
height += 25; |
|
|
|
|
} |
|
|
|
|
return new Dimension(197, 250); |
|
|
|
|
return new Dimension(WIDTH, height); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -400,12 +395,12 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
|
|
|
|
|
private boolean setColorRealTime; |
|
|
|
|
|
|
|
|
|
public JPanel getPane(){ |
|
|
|
|
public JPanel getPane() { |
|
|
|
|
return this.pane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public NewUsedColorPane(int columns, ColorSelectable selectable, boolean setColorRealTime){ |
|
|
|
|
public NewUsedColorPane(int columns, ColorSelectable selectable, boolean setColorRealTime) { |
|
|
|
|
this.columns = columns; |
|
|
|
|
this.selectable = selectable; |
|
|
|
|
this.setColorRealTime = setColorRealTime; |
|
|
|
@ -436,7 +431,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
* 更新最近使用颜色 |
|
|
|
|
*/ |
|
|
|
|
public void updateUsedColor() { |
|
|
|
|
int total = columns ; |
|
|
|
|
int total = columns; |
|
|
|
|
Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); |
|
|
|
|
int size = colors.length; |
|
|
|
|
for (int i = 0; i < total; i++) { |
|
|
|
@ -452,4 +447,5 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|