|
|
@ -1,15 +1,19 @@ |
|
|
|
package com.fr.design.style.color; |
|
|
|
package com.fr.design.style.color; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.FineColor; |
|
|
|
import com.fr.base.FineColor; |
|
|
|
|
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
|
|
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.file.HistoryTemplateListCache; |
|
|
|
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.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 com.fr.design.mainframe.JTemplate; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JButton; |
|
|
@ -24,6 +28,7 @@ import java.awt.GridLayout; |
|
|
|
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; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -49,6 +54,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
|
|
|
|
|
|
|
|
// 最近使用颜色
|
|
|
|
// 最近使用颜色
|
|
|
|
private final NewUsedColorPane usedColorPane; |
|
|
|
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); |
|
|
|
return new NewColorSelectPane(true, supportTheme); |
|
|
@ -76,12 +83,12 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4)); |
|
|
|
centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4)); |
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
JPanel menuColorPane1 = getMenuColorPane(); |
|
|
|
menuColorPane = getMenuColorPane(); |
|
|
|
centerPane.add(menuColorPane1); |
|
|
|
centerPane.add(menuColorPane); |
|
|
|
if(isSupportThemeColor){ |
|
|
|
if(isSupportThemeColor){ |
|
|
|
initThemeColorPane(menuColorPane1); |
|
|
|
initThemeColorPane(); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
initMenuColorPane(menuColorPane1); |
|
|
|
initMenuColorPane(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JPanel standardColorPane = new JPanel(new BorderLayout(0, 5)); |
|
|
|
JPanel standardColorPane = new JPanel(new BorderLayout(0, 5)); |
|
|
@ -132,34 +139,89 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
return jPanel; |
|
|
|
return jPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initThemeColorPane(JPanel menuColorPane){ |
|
|
|
private void initThemeColorPane(){ |
|
|
|
|
|
|
|
menuColorPane.removeAll(); |
|
|
|
menuColorPane.setLayout(new BorderLayout(0, 10)); |
|
|
|
menuColorPane.setLayout(new BorderLayout(0, 10)); |
|
|
|
JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0)); |
|
|
|
JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0)); |
|
|
|
JPanel centerPane = 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(northPane, BorderLayout.NORTH); |
|
|
|
menuColorPane.add(centerPane, BorderLayout.CENTER); |
|
|
|
menuColorPane.add(centerPane, BorderLayout.CENTER); |
|
|
|
//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}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Color[] colorArray = new Color[] { |
|
|
|
|
|
|
|
// 2列灰度色
|
|
|
|
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 8列主题色
|
|
|
|
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
|
|
|
|
Color.decode("#FFFFFF"), |
|
|
|
|
|
|
|
Color.decode("#CCCCCC"), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (themeColorCellGrid == null) { |
|
|
|
|
|
|
|
themeColorCellGrid = new ColorCell[colorArray.length][5]; |
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
Color color = colorArray[i]; |
|
|
|
ColorCell[] colorCellColumn = new ColorCell[5]; |
|
|
|
boolean isDefaultColor = (i == 0 || i == 1); |
|
|
|
boolean isDefaultColor = (i == 0 || i == 1); |
|
|
|
northPane.add(createFineColorCell(color, isDefaultColor, i, 0)); |
|
|
|
Color color = colorArray[i]; |
|
|
|
|
|
|
|
colorCellColumn[0] = createFineColorCell(color, isDefaultColor, i, 2); |
|
|
|
|
|
|
|
colorCellColumn[2] = createFineColorCell(color = saturationDown(color, false, true), isDefaultColor, i, 1); |
|
|
|
|
|
|
|
colorCellColumn[1] = createFineColorCell(saturationDown(color, false, true), isDefaultColor, i, 0); |
|
|
|
|
|
|
|
color = colorArray[i]; |
|
|
|
|
|
|
|
colorCellColumn[3] = createFineColorCell(color = saturationDown(color, false, false), isDefaultColor, i, 3); |
|
|
|
|
|
|
|
colorCellColumn[4] = createFineColorCell(saturationDown(color, false, false), isDefaultColor, i, 4); |
|
|
|
|
|
|
|
themeColorCellGrid[i] = colorCellColumn; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
Color color = colorArray[i]; |
|
|
|
northPane.add(themeColorCellGrid[i][0]); |
|
|
|
boolean isDefaultColor = (i == 0 || i == 1); |
|
|
|
} |
|
|
|
JPanel jPanel = new JPanel(new GridLayout(4, 1, 0, 3)); |
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, true), isDefaultColor, i, 1)); |
|
|
|
JPanel columnPane = new JPanel(new GridLayout(4, 1, 0, 3)); |
|
|
|
jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, true), isDefaultColor, i, 2)); |
|
|
|
columnPane.add(themeColorCellGrid[i][1]); |
|
|
|
color = colorArray[i]; |
|
|
|
columnPane.add(themeColorCellGrid[i][2]); |
|
|
|
jPanel.add(createFineColorCell(color = saturationDown(color, isDefaultColor, false), isDefaultColor, i, 3)); |
|
|
|
columnPane.add(themeColorCellGrid[i][3]); |
|
|
|
jPanel.add(createFineColorCell(saturationDown(color, isDefaultColor, false), isDefaultColor, i, 4)); |
|
|
|
columnPane.add(themeColorCellGrid[i][4]); |
|
|
|
centerPane.add(jPanel); |
|
|
|
centerPane.add(columnPane); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refreshThemeMenuColorPane(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshThemeMenuColorPane() { |
|
|
|
|
|
|
|
List<Color> standardColors = null; |
|
|
|
|
|
|
|
if (TemplateThemeProfileDialog.isEditingTheme()) { |
|
|
|
|
|
|
|
standardColors = TemplateThemeProfileDialog.getEditingColorScheme(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
if (template != null) { |
|
|
|
|
|
|
|
TemplateTheme theme = template.getTemplateTheme(); |
|
|
|
|
|
|
|
if (theme != null) { |
|
|
|
|
|
|
|
standardColors = theme.getColorScheme().getColors(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -183,7 +245,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
return color1; |
|
|
|
return color1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initMenuColorPane(JPanel menuColorPane) { |
|
|
|
private void initMenuColorPane() { |
|
|
|
menuColorPane.setLayout(new GridLayout(5, 8, 3, 3)); |
|
|
|
menuColorPane.setLayout(new GridLayout(5, 8, 3, 3)); |
|
|
|
Color[] colorArray = this.getColorArray(); |
|
|
|
Color[] colorArray = this.getColorArray(); |
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
|
for (int i = 0; i < colorArray.length; i++) { |
|
|
@ -259,6 +321,9 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setColor(Color color) { |
|
|
|
public void setColor(Color color) { |
|
|
|
|
|
|
|
if (isSupportThemeColor) { |
|
|
|
|
|
|
|
refreshThemeMenuColorPane(); |
|
|
|
|
|
|
|
} |
|
|
|
FineColor fineColor; |
|
|
|
FineColor fineColor; |
|
|
|
if (color == null) { |
|
|
|
if (color == null) { |
|
|
|
fineColor = null; |
|
|
|
fineColor = null; |
|
|
|