Browse Source

REPORT-934颜色记住正确但是显示错误修复和部分代码调整

master
yaoh.wu 8 years ago
parent
commit
a5769fe467
  1. 38
      designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java
  2. 41
      designer_base/src/com/fr/design/style/color/ColorSelectPane.java
  3. 54
      designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
  4. 19
      designer_base/src/com/fr/design/style/color/RecentUseColorPane.java
  5. 41
      designer_base/src/com/fr/design/style/color/UsedColorPane.java

38
designer_base/src/com/fr/design/style/color/ColorSelectDetailPane.java

@ -1,38 +1,34 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.BorderLayout; import com.fr.design.dialog.BasicPane;
import java.awt.Color; import com.fr.design.layout.FRGUIPaneFactory;
import java.awt.Dimension; import com.fr.general.Inter;
import javax.swing.JColorChooser; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel; import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*;
import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
/** /**
* 颜色选择器更多颜色面板 * 颜色选择器更多颜色面板
* @author focus
* *
* @author focus
*/ */
public class ColorSelectDetailPane extends BasicPane{ public class ColorSelectDetailPane extends BasicPane {
private static final int SELECT_PANEL_HEIGHT = 245; private static final int SELECT_PANEL_HEIGHT = 245;
// Selected color // Selected color
private Color color; private Color color;
// 颜色选择器面板 // 颜色选择器面板
JColorChooser selectedPanel; private JColorChooser selectedPanel;
// 最近使用颜色面板 // 最近使用颜色面板
JPanel recentUsePanel; private JPanel recentUsePanel;
// 预览 // 预览
JPanel previewPanel; private JPanel previewPanel;
public JColorChooser getSelectedPanel() { public JColorChooser getSelectedPanel() {
return selectedPanel; return selectedPanel;
@ -50,12 +46,8 @@ public class ColorSelectDetailPane extends BasicPane{
this.color = color; this.color = color;
} }
public ColorSelectDetailPane() { public ColorSelectDetailPane(Color color) {
super(); if (color == null) {
}
public ColorSelectDetailPane(Color color){
if(color == null){
color = Color.white; color = Color.white;
} }
this.color = color; this.color = color;
@ -72,9 +64,9 @@ public class ColorSelectDetailPane extends BasicPane{
// 颜色选择器面板 // 颜色选择器面板
selectedPanel = new JColorChooser(this.color); selectedPanel = new JColorChooser(this.color);
selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(),SELECT_PANEL_HEIGHT)); selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT));
AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels(); AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels();
for(int i=0;i<choosers.length;i++){ for (int i = 0; i < choosers.length; i++) {
selectedPanel.removeChooserPanel(choosers[i]); selectedPanel.removeChooserPanel(choosers[i]);
} }
selectedPanel.setPreviewPanel(new JPanel()); selectedPanel.setPreviewPanel(new JPanel());
@ -90,7 +82,7 @@ public class ColorSelectDetailPane extends BasicPane{
RecentUseColorPane recent = new RecentUseColorPane(selectedPanel); RecentUseColorPane recent = new RecentUseColorPane(selectedPanel);
recentUsePanel.add(recent); recentUsePanel.add(recent);
this.add(recentUsePanel,BorderLayout.CENTER); this.add(recentUsePanel, BorderLayout.CENTER);
selectedPanel.setPreviewPanel(new JPanel()); selectedPanel.setPreviewPanel(new JPanel());

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

@ -3,26 +3,23 @@
*/ */
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
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.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
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.general.Inter;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/** /**
* The pane used to select color * The pane used to select color
@ -34,7 +31,8 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
//color setting action. //color setting action.
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>(); private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>();
ColorSelectDetailPane pane;
/* default */ ColorSelectDetailPane pane;
/** /**
* Constructor. * Constructor.
@ -104,20 +102,20 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
return menuColorPane; return menuColorPane;
} }
// 第一行,1个取色按钮 + 7个最近使用的颜色 // 第一行,1个取色按钮 + 1个留空的单元格 + 6个最近使用的颜色
protected JPanel getRow1Pane() { protected JPanel getRow1Pane() {
JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout());
row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0));
row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7 row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
// 最近使用 // 最近使用
UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, true); UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, this, true, true);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane()); row1Pane.add(usedColorPane.getPane());
return row1Pane; return row1Pane;
} }
protected Color[] getColorArray(){ protected Color[] getColorArray() {
return ColorFactory.MenuColors; return ColorFactory.MenuColors;
} }
@ -125,7 +123,8 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/** /**
* Add change listener. * Add change listener.
* 增加监听 * 增加监听
* @param 监听 *
* @param changeListener
*/ */
public void addChangeListener(ChangeListener changeListener) { public void addChangeListener(ChangeListener changeListener) {
this.colorChangeListenerList.add(changeListener); this.colorChangeListenerList.add(changeListener);
@ -166,8 +165,6 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/** /**
* 选中颜色 * 选中颜色
* @param 颜色单元格
*
*/ */
@Override @Override
public void colorSetted(ColorCell colorCell) { public void colorSetted(ColorCell colorCell) {
@ -176,8 +173,8 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
/** /**
* 初始化中央面板 * 初始化中央面板
* @param centerPane 中央面板
* *
* @param centerPane 中央面板
*/ */
@Override @Override
public void initCenterPaneChildren(JPanel centerPane) { public void initCenterPaneChildren(JPanel centerPane) {

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

@ -1,33 +1,25 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.design.constants.UIConstants;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
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.dialog.BasicPane;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/** /**
*
* @author zhou * @author zhou
* @since 2012-5-29上午10:39:35 * @since 2012-5-29上午10:39:35
*/ */
@ -47,7 +39,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
private final static int WINDWO_HEIGHT = 150; private final static int WINDWO_HEIGHT = 150;
// 最近使用颜色 // 最近使用颜色
UsedColorPane usedColorPane; private UsedColorPane usedColorPane;
/** /**
* Constructor. * Constructor.
@ -85,7 +77,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7 row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7
centerPane.add(row1Pane); centerPane.add(row1Pane);
// 最近使用 // 最近使用
usedColorPane = new UsedColorPane(1, 8, 1, ColorSelectConfigManager.getInstance().getColors(), this, true, false); usedColorPane = new UsedColorPane(1, 8, 1, this, true, false);
usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8));
row1Pane.add(usedColorPane.getPane()); row1Pane.add(usedColorPane.getPane());
@ -102,7 +94,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
// mod by anchore 16/11/16 // mod by anchore 16/11/16
UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color")); UIButton customButton = new UIButton(Inter.getLocText("FR-Designer-Basic_More_Color"));
//UIButton customButton = new UIButton(Inter.getLocText(new String[]{"More", "Color"}) + "...");
customButton.addMouseListener(new MouseAdapter() { customButton.addMouseListener(new MouseAdapter() {
@Override @Override
@ -118,11 +109,10 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
} }
/** /**
* 添加监听 * 添加监听
* @param 监听列表 *
* Add change listener. * @param 监听列表 Add change listener.
*/ */
public void addChangeListener(ChangeListener changeListener) { public void addChangeListener(ChangeListener changeListener) {
this.colorChangeListenerList.add(changeListener); this.colorChangeListenerList.add(changeListener);
@ -135,6 +125,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
/** /**
* 获取颜色 * 获取颜色
*
* @return 颜色 * @return 颜色
* Return the color. * Return the color.
*/ */
@ -158,8 +149,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
/** /**
* Set the color. * Set the color.
* *
* @param color * @param color the new color.
* the new color.
*/ */
@Override @Override
public void setColor(Color color) { public void setColor(Color color) {
@ -179,6 +169,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
/** /**
* 设置颜色 * 设置颜色
*
* @param 颜色位置 * @param 颜色位置
*/ */
@Override @Override
@ -189,6 +180,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
protected void doTransparent() { protected void doTransparent() {
setColor(null); setColor(null);
} }
protected void customButtonPressed() { protected void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE); pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
@ -196,7 +188,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if(isSupportTransparent){ if (isSupportTransparent) {
return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT); return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT);
} }
return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT); return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT);
@ -204,12 +196,10 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
/** /**
* 更新最近使用颜色 * 更新最近使用颜色
*
*/ */
public void updateUsedColor(){ public void updateUsedColor() {
usedColorPane.updateUsedColor(); usedColorPane.updateUsedColor();
} }
} }

19
designer_base/src/com/fr/design/style/color/RecentUseColorPane.java

@ -1,25 +1,20 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
public class RecentUseColorPane extends BasicPane implements ColorSelectable{ import javax.swing.*;
import java.awt.*;
JColorChooser chooser; public class RecentUseColorPane extends BasicPane implements ColorSelectable {
private JColorChooser chooser;
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return null; return null;
} }
public RecentUseColorPane() {
}
public RecentUseColorPane(JColorChooser chooser) { public RecentUseColorPane(JColorChooser chooser) {
this.chooser = chooser; this.chooser = chooser;
@ -28,14 +23,12 @@ public class RecentUseColorPane extends BasicPane implements ColorSelectable{
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
// 最近使用 // 最近使用
UsedColorPane pane = new UsedColorPane(2, 10, ColorSelectConfigManager.getInstance().getColors(),this); UsedColorPane pane = new UsedColorPane(2, 10, this);
centerPane.add(pane.getPane()); centerPane.add(pane.getPane());
} }
/** /**
* 选中颜色 * 选中颜色
*
* @param 颜色
*/ */
@Override @Override
public void colorSetted(ColorCell color) { public void colorSetted(ColorCell color) {

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

@ -1,17 +1,15 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.SpecialUIButton; import com.fr.design.gui.ibutton.SpecialUIButton;
public class UsedColorPane extends BasicPane{ import javax.swing.*;
import java.awt.*;
public static final Color DEFAULT_COLOR = new Color(222,222,222); public class UsedColorPane extends BasicPane {
// 默认显示颜色
public static final Color DEFAULT_COLOR = new Color(222, 222, 222);
// 最近使用面板列数 // 最近使用面板列数
private int columns; private int columns;
@ -23,8 +21,7 @@ public class UsedColorPane extends BasicPane{
private boolean needPickColorButton; private boolean needPickColorButton;
// 是否在取色时实时设定颜色 // 是否在取色时实时设定颜色
private boolean setColorRealTime; private boolean setColorRealTime;
// 最近使用颜色
private Object[] colors;
// 最近使用面板 // 最近使用面板
private JPanel pane; private JPanel pane;
@ -38,9 +35,6 @@ public class UsedColorPane extends BasicPane{
this.pane = pane; this.pane = pane;
} }
public UsedColorPane(){
}
/** /**
* 构造函数 * 构造函数
@ -52,26 +46,26 @@ public class UsedColorPane extends BasicPane{
* @param needPickColorButton 是否需要加上取色器按钮 * @param needPickColorButton 是否需要加上取色器按钮
* @param setColorRealTime 取色器是否实时设定颜色 * @param setColorRealTime 取色器是否实时设定颜色
*/ */
public UsedColorPane(int rows,int columns,int reserveCells, Object[] colors, ColorSelectable selectable, boolean needPickColorButton, boolean setColorRealTime){ public UsedColorPane(int rows, int columns, int reserveCells, ColorSelectable selectable, boolean needPickColorButton, boolean setColorRealTime) {
this.columns = columns; this.columns = columns;
this.rows = rows; this.rows = rows;
this.reserveCells = reserveCells; this.reserveCells = reserveCells;
this.colors = colors;
this.selectable = selectable; this.selectable = selectable;
this.needPickColorButton = needPickColorButton; this.needPickColorButton = needPickColorButton;
this.setColorRealTime = setColorRealTime; this.setColorRealTime = setColorRealTime;
initialComponents(); initialComponents();
} }
public UsedColorPane(int rows,int columns, Object[] colors,ColorSelectable selectable){ public UsedColorPane(int rows, int columns, ColorSelectable selectable) {
this(rows, columns, 0, colors, selectable, false, false); this(rows, columns, 0, selectable, false, false);
} }
private void initialComponents(){ private void initialComponents() {
int total = columns * rows; int total = columns * rows;
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new GridLayout(rows,columns, 1, 1)); panel.setLayout(new GridLayout(rows, columns, 1, 1));
panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
//最近使用颜色
Color[] colors = ColorSelectConfigManager.getInstance().getColors(); Color[] colors = ColorSelectConfigManager.getInstance().getColors();
int size = colors.length; int size = colors.length;
@ -90,7 +84,7 @@ public class UsedColorPane extends BasicPane{
i++; i++;
} }
while (i < total) { while (i < total) {
Color color = i < size ? colors[size-1-i]: DEFAULT_COLOR; Color color = i < size ? colors[size - (i - this.reserveCells) - 1] : DEFAULT_COLOR;
panel.add(new ColorCell(color == null ? DEFAULT_COLOR : color, selectable)); panel.add(new ColorCell(color == null ? DEFAULT_COLOR : color, selectable));
i++; i++;
} }
@ -99,15 +93,14 @@ public class UsedColorPane extends BasicPane{
/** /**
* 更新最近使用颜色 * 更新最近使用颜色
*
*/ */
public void updateUsedColor(){ public void updateUsedColor() {
int total = columns * rows; int total = columns * rows;
Color[] colors = ColorSelectConfigManager.getInstance().getColors(); Color[] colors = ColorSelectConfigManager.getInstance().getColors();
int size = colors.length; int size = colors.length;
for(int i=this.reserveCells; i<total; i++){ for (int i = this.reserveCells; i < total; i++) {
ColorCell cell = (ColorCell) this.pane.getComponent(i); ColorCell cell = (ColorCell) this.pane.getComponent(i);
Color color = i < size ? colors[size-1-i]: DEFAULT_COLOR; Color color = i < size ? colors[size - (i - this.reserveCells) - 1] : DEFAULT_COLOR;
cell.setColor(color == null ? DEFAULT_COLOR : color); cell.setColor(color == null ? DEFAULT_COLOR : color);
} }
} }

Loading…
Cancel
Save