From 02f5befc458ba43939a43b8d80d81aa488d1088b Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 16 Jan 2017 16:22:28 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-1096=20=E5=8F=96=E8=89=B2=E6=9D=BF=3D>1?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E6=97=A0=E9=80=8F=E6=98=8E=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E9=80=89=E6=8B=A9=E6=A1=86=E7=9A=84=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=EF=BC=9B2=E3=80=81=E2=80=9C=E6=9B=B4=E5=A4=9A=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E2=80=9D=E6=8C=89=E9=92=AE=E4=B8=8B=E7=95=99=E5=87=BA?= =?UTF-8?q?=E7=A9=BA=E9=9A=99=EF=BC=9B3=E3=80=81=E5=8F=96=E8=89=B2?= =?UTF-8?q?=E5=99=A8=E6=8C=89=E9=92=AE=E5=A4=A7=E5=B0=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=B8=8E=E8=89=B2=E5=9D=97=E7=9B=B8=E5=90=8C=EF=BC=9B?= =?UTF-8?q?4=E3=80=81=E7=A9=BA=E5=87=BA=E4=B8=80=E4=B8=AA=E8=89=B2?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/style/color/ColorSelectPane.java | 25 ++++++------- .../style/color/NewColorSelectPane.java | 11 ++---- .../fr/design/style/color/UsedColorPane.java | 35 +++++++++++++++++-- .../ColorSelectPaneWithOutTransparent.java | 12 ++++++- 4 files changed, 59 insertions(+), 24 deletions(-) diff --git a/designer_base/src/com/fr/design/style/color/ColorSelectPane.java b/designer_base/src/com/fr/design/style/color/ColorSelectPane.java index 743a71ce4..851768f5a 100644 --- a/designer_base/src/com/fr/design/style/color/ColorSelectPane.java +++ b/designer_base/src/com/fr/design/style/color/ColorSelectPane.java @@ -71,11 +71,8 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable centerPane.add(getRow1Pane()); - JPanel menuColorPane1 = new JPanel(); + JPanel menuColorPane1 = getMenuColorPane(); centerPane.add(menuColorPane1); - - menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1)); - menuColorPane1.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]; @@ -94,24 +91,28 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable }); customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); - centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8)); + centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8)); centerPane1.add(customButton, BorderLayout.NORTH); centerPane.add(centerPane1); } + protected JPanel getMenuColorPane() { + JPanel menuColorPane = new JPanel(); + menuColorPane.setLayout(new GridLayout(5, 8, 1, 1)); + menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); + + return menuColorPane; + } + // 第一行,1个取色按钮 + 7个最近使用的颜色 - private JPanel getRow1Pane() { + protected JPanel getRow1Pane() { JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7 - // 取色按钮 - UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON16, true); - row1Pane.add(pickColorButton, BorderLayout.WEST); - // 最近使用 - UsedColorPane usedColorPane = new UsedColorPane(1, 7, ColorSelectConfigManager.getInstance().getColors(),this); - usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 8)); + UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, true, ColorSelectConfigManager.getInstance().getColors(),this); + usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); row1Pane.add(usedColorPane.getPane()); return row1Pane; } diff --git a/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java b/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java index ba28b4201..b8cff5cde 100644 --- a/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java +++ b/designer_base/src/com/fr/design/style/color/NewColorSelectPane.java @@ -79,19 +79,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); this.add(centerPane, BorderLayout.CENTER); - // 第一行,1个取色按钮 + 7个最近使用的颜色 + // 第一行 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); - - // 取色按钮 - UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON16); - row1Pane.add(pickColorButton, BorderLayout.WEST); - // 最近使用 - usedColorPane = new UsedColorPane(1, 7, ColorSelectConfigManager.getInstance().getColors(),this); - usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 8)); + usedColorPane = new UsedColorPane(1, 8, 1, true, ColorSelectConfigManager.getInstance().getColors(),this); + usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); row1Pane.add(usedColorPane.getPane()); JPanel menuColorPane1 = new JPanel(); diff --git a/designer_base/src/com/fr/design/style/color/UsedColorPane.java b/designer_base/src/com/fr/design/style/color/UsedColorPane.java index 37f14fa00..26e091554 100644 --- a/designer_base/src/com/fr/design/style/color/UsedColorPane.java +++ b/designer_base/src/com/fr/design/style/color/UsedColorPane.java @@ -7,6 +7,7 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButton; public class UsedColorPane extends BasicPane{ @@ -16,6 +17,10 @@ public class UsedColorPane extends BasicPane{ private int columns; // 最近使用面板行数 private int rows; + // 留白的单元格数量 + private int reserveCells; + // 是否需要取色器按钮 + private boolean needPickColorButton; // 最近使用颜色 private Object[] colors; // 最近使用面板 @@ -40,15 +45,23 @@ public class UsedColorPane extends BasicPane{ * * @param rows 行 * @param columns 列 + * @param reserveCells 留白的单元格个数 + * @param needPickColorButton 是否需要加上取色器按钮 * @param colors 最近使用的颜色 */ - public UsedColorPane(int rows,int columns,Object[] colors,ColorSelectable selectable){ + public UsedColorPane(int rows,int columns,int reserveCells, boolean needPickColorButton, Object[] colors,ColorSelectable selectable){ this.columns = columns; this.rows = rows; + this.reserveCells = reserveCells; + this.needPickColorButton = needPickColorButton; this.colors = colors; this.selectable = selectable; initialComponents(); } + + public UsedColorPane(int rows,int columns, Object[] colors,ColorSelectable selectable){ + this(rows, columns, 0, false, colors, selectable); + } private void initialComponents(){ int total = columns * rows; @@ -57,9 +70,25 @@ public class UsedColorPane extends BasicPane{ panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); Color[] colors = ColorSelectConfigManager.getInstance().getColors(); int size = colors.length; - for (int i = 0; i < total; i++) { + + int i = 0; + if (needPickColorButton) { + // 取色按钮 + UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, true); + panel.add(pickColorButton); + i++; + this.reserveCells += 1; + } + while (i < this.reserveCells) { + ColorCell cc = new ColorCell(DEFAULT_COLOR, selectable); + cc.setVisible(false); + panel.add(cc); + i++; + } + while (i < total) { Color color = i < size ? colors[size-1-i]: DEFAULT_COLOR; panel.add(new ColorCell(color == null ? DEFAULT_COLOR : color, selectable)); + i++; } this.pane = panel; } @@ -72,7 +101,7 @@ public class UsedColorPane extends BasicPane{ int total = columns * rows; Color[] colors = ColorSelectConfigManager.getInstance().getColors(); int size = colors.length; - for(int i=0; i