From fa21593fcc68723a6d941f4e901ba3d1b46242ee Mon Sep 17 00:00:00 2001 From: MoMeak Date: Fri, 18 Aug 2017 14:50:38 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-3895=20[9.0=E4=B8=80=E8=BD=AE=E5=9B=9E?= =?UTF-8?q?=E5=BD=92]=E6=B8=90=E5=8F=98=E8=89=B2=E5=B7=A6=E8=BE=B9?= =?UTF-8?q?=E7=AE=AD=E5=A4=B4=E4=B8=8D=E6=98=93=E6=93=8D=E4=BD=9C=EF=BC=8C?= =?UTF-8?q?=E5=8F=B3=E8=BE=B9=E7=AE=AD=E5=A4=B4=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=A6=82=E9=99=84=E4=BB=B6=E5=9B=BE=E7=89=87=20REPORT-3896=20[?= =?UTF-8?q?9.0=E4=B8=80=E8=BD=AE=E5=9B=9E=E5=BD=92]=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E8=83=8C=E6=99=AF=E5=9B=BE=E6=A1=88?= =?UTF-8?q?=E7=9A=84=E5=89=8D=E6=99=AF=E5=92=8C=E8=83=8C=E6=99=AF=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=8C=89=E9=92=AE=E5=8F=AA=E6=98=BE=E7=A4=BA=E4=B8=80?= =?UTF-8?q?=E5=8D=8A=E5=A6=82=E9=99=84=E4=BB=B6=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cell/settingpane/CellOtherSetPane.java | 2 - .../GradientBackgroundQuickPane.java | 4 +- .../ImageBackgroundQuickPane.java | 7 +- .../PatternBackgroundQuickPane.java | 372 +++++++++--------- .../TextureBackgroundQuickPane.java | 1 - 5 files changed, 196 insertions(+), 190 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 411ef87a9..751acbf46 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -248,8 +248,6 @@ public class CellOtherSetPane extends AbstractCellAttrPane { } } }); - tooltipTextField = new UITextField(); - tooltipTextField.getUI(); return fileNamePane; } diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java index 08ef9e61c..97ba9cbe7 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java @@ -22,7 +22,7 @@ import java.awt.*; public class GradientBackgroundQuickPane extends BackgroundQuickPane { private static final long serialVersionUID = -6854603990673031897L; - private static final int DEFAULT_GRADIENT_WIDTH = 185; + private static final int DEFAULT_GRADIENT_WIDTH = 150 ; private int gradientBarWidth = DEFAULT_GRADIENT_WIDTH; @@ -52,7 +52,7 @@ public class GradientBackgroundQuickPane extends BackgroundQuickPane { Component[][] components = new Component[][]{ new Component[]{gradientBar, null}, - new Component[]{new UILabel(Inter.getLocText("Gradient-Direction") + ":"), directionPane} + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Gradient_Direction")), directionPane} }; JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java index 114b704c0..4dafe476a 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java @@ -61,17 +61,14 @@ public class ImageBackgroundQuickPane extends BackgroundQuickPane { contentPane.add(southPane, BorderLayout.NORTH); this.add(contentPane, BorderLayout.CENTER); - JPanel selectFilePane = new JPanel(new GridLayout(0, 2)); UIButton selectPictureButton = new UIButton(Inter.getLocText("Image-Select_Picture")); - selectFilePane.add(new JPanel()); - selectFilePane.add(selectPictureButton); selectPictureButton.addActionListener(selectPictureActionListener); if(hasImageLayout){ - southPane.add(imageLayoutPane, BorderLayout.CENTER); + southPane.add(imageLayoutPane, BorderLayout.SOUTH); } - southPane.add(selectFilePane, BorderLayout.SOUTH); + southPane.add(selectPictureButton, BorderLayout.CENTER); imageLayoutPane.addChangeListener(new ChangeListener() { diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java index 16b294955..86a96a2cb 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java @@ -2,14 +2,17 @@ package com.fr.design.mainframe.backgroundpane; import com.fr.base.GraphHelper; import com.fr.base.background.PatternBackground; -import com.fr.design.constants.UIConstants; import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.constants.UIConstants; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.color.ColorSelectBox; import com.fr.general.Background; import com.fr.general.Inter; -import com.fr.design.style.color.ColorSelectBox; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -25,182 +28,191 @@ import java.awt.geom.Rectangle2D; */ public class PatternBackgroundQuickPane extends BackgroundQuickPane { - private int patternIndex = 0; // pattern setIndex. - private final static int DEFAULT_DIM_HEIGHT = 190; - private ColorSelectBox foregroundColorPane; - private ColorSelectBox backgroundColorPane; - private PatternButton[] patternButtonArray; - - public PatternBackgroundQuickPane() { - this.setLayout(new BorderLayout(0, 4)); - JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); - this.add(contentPane, BorderLayout.NORTH); - contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); - JPanel typePane2 = new JPanel(); - contentPane.add(typePane2); - typePane2.setLayout(new GridLayout(0, 8, 1, 1)); - typePane2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); - ButtonGroup patternButtonGroup = new ButtonGroup(); - patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; - for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { - patternButtonArray[i] = new PatternButton(i); - patternButtonGroup.add(patternButtonArray[i]); - typePane2.add(patternButtonArray[i]); - } - JPanel colorPane = new JPanel(new GridLayout(0, 2)); - foregroundColorPane = new ColorSelectBox(70); - backgroundColorPane = new ColorSelectBox(70); - colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Foreground") + ":", foregroundColorPane)); - colorPane.add(this.createLabelColorPane(Inter.getLocText("FR-Designer_Background") + ":", backgroundColorPane)); - this.add(colorPane, BorderLayout.CENTER); - foregroundColorPane.addSelectChangeListener(colorChangeListener); - backgroundColorPane.addSelectChangeListener(colorChangeListener); - } - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.height = DEFAULT_DIM_HEIGHT; - return dim; - } - - private JPanel createLabelColorPane(String text, JComponent colorPane) { - JPanel labelColorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); - labelColorPane.add(new UILabel(text)); - labelColorPane.add(colorPane); - - return labelColorPane; - } - - public void populateBean(Background background) { - PatternBackground patternBackground = (PatternBackground) background; - int patternIndex = patternBackground.getPatternIndex(); - - if (patternIndex >= 0 && patternIndex < this.patternButtonArray.length) { - this.patternButtonArray[patternIndex].setSelected(true); - this.patternIndex = patternIndex; - } else { - this.patternIndex = 0; - } - - foregroundColorPane.setSelectObject(patternBackground.getForeground()); - backgroundColorPane.setSelectObject(patternBackground.getBackground()); - } - - public Background updateBean() { - return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); - } - - - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(final UIObserverListener listener) { - foregroundColorPane.addSelectChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - backgroundColorPane.addSelectChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - for (int i = 0, count = patternButtonArray.length; i < count; i ++) { - patternButtonArray[i].addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - listener.doChange(); - } - }); - } - } - - - // Foreground or Background changed. - ChangeListener colorChangeListener = new ChangeListener() { - - public void stateChanged(ChangeEvent e) { - for (int i = 0; i < patternButtonArray.length; i++) { - patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); - patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); - } - - PatternBackgroundQuickPane.this.repaint();// repaint - } - }; - - /** - * Pattern type button. - */ - class PatternButton extends JToggleButton implements ActionListener { - - public PatternButton(int pIndex) { - this.pIndex = pIndex; - this.addActionListener(this); - - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); - this.setBorder(null); - this.patternBackground = new PatternBackground(this.pIndex, Color.lightGray, Color.black); - } - - public void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); - - if (this.pIndex == patternIndex) {// it's selected. - g2d.setPaint(UIConstants.LINE_COLOR); - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); - } - } - - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 20); - } - - public void setPatternForeground(Color foreground) { - this.patternBackground.setForeground(foreground); - } - - public void setPatternBackground(Color background) { - this.patternBackground.setBackground(background); - } - - /** - * set Pattern setIndex. - */ - public void actionPerformed(ActionEvent evt) { - PatternBackgroundQuickPane.this.patternIndex = pIndex; - - fireChagneListener(); - PatternBackgroundQuickPane.this.repaint();// repaint - } - - public void addChangeListener(ChangeListener changeListener) { - this.changeListener = changeListener; - } - - private void fireChagneListener() { - if (this.changeListener != null) { - ChangeEvent evt = new ChangeEvent(this); - this.changeListener.stateChanged(evt); - } - } - - private int pIndex = 0; - private PatternBackground patternBackground; - } - - @Override - public boolean accept(Background background) { - return background instanceof PatternBackground; - } - - @Override - public String title4PopupWindow() { - return Inter.getLocText("FR-Designer_Background-Pattern"); - } + private int patternIndex = 0; // pattern setIndex. + private final static int DEFAULT_DIM_HEIGHT = 210; + private ColorSelectBox foregroundColorPane; + private ColorSelectBox backgroundColorPane; + private PatternButton[] patternButtonArray; + + public PatternBackgroundQuickPane() { + this.setLayout(new BorderLayout(0, 4)); + JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + this.add(contentPane, BorderLayout.NORTH); + contentPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); + JPanel typePane2 = new JPanel(); + contentPane.add(typePane2); + typePane2.setLayout(new GridLayout(0, 8, 1, 1)); + typePane2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); + ButtonGroup patternButtonGroup = new ButtonGroup(); + patternButtonArray = new PatternButton[PatternBackground.PATTERN_COUNT]; + for (int i = 0; i < PatternBackground.PATTERN_COUNT; i++) { + patternButtonArray[i] = new PatternButton(i); + patternButtonGroup.add(patternButtonArray[i]); + typePane2.add(patternButtonArray[i]); + } + foregroundColorPane = new ColorSelectBox(60); + backgroundColorPane = new ColorSelectBox(60); + + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Foreground"), UILabel.LEFT), foregroundColorPane}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background"), UILabel.LEFT), backgroundColorPane}, + }; + double[] rowSize = {p, p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; + JPanel colorPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_LARGE); + this.add(colorPane, BorderLayout.CENTER); + foregroundColorPane.addSelectChangeListener(colorChangeListener); + backgroundColorPane.addSelectChangeListener(colorChangeListener); + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.height = DEFAULT_DIM_HEIGHT; + return dim; + } + + private JPanel createLabelColorPane(String text, JComponent colorPane) { + JPanel labelColorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); + labelColorPane.add(new UILabel(text)); + labelColorPane.add(colorPane); + + return labelColorPane; + } + + public void populateBean(Background background) { + PatternBackground patternBackground = (PatternBackground) background; + int patternIndex = patternBackground.getPatternIndex(); + + if (patternIndex >= 0 && patternIndex < this.patternButtonArray.length) { + this.patternButtonArray[patternIndex].setSelected(true); + this.patternIndex = patternIndex; + } else { + this.patternIndex = 0; + } + + foregroundColorPane.setSelectObject(patternBackground.getForeground()); + backgroundColorPane.setSelectObject(patternBackground.getBackground()); + } + + public Background updateBean() { + return new PatternBackground(patternIndex, foregroundColorPane.getSelectObject(), backgroundColorPane.getSelectObject()); + } + + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + foregroundColorPane.addSelectChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + backgroundColorPane.addSelectChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + for (int i = 0, count = patternButtonArray.length; i < count; i++) { + patternButtonArray[i].addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + listener.doChange(); + } + }); + } + } + + + // Foreground or Background changed. + ChangeListener colorChangeListener = new ChangeListener() { + + public void stateChanged(ChangeEvent e) { + for (int i = 0; i < patternButtonArray.length; i++) { + patternButtonArray[i].setPatternForeground(foregroundColorPane.getSelectObject()); + patternButtonArray[i].setPatternBackground(backgroundColorPane.getSelectObject()); + } + + PatternBackgroundQuickPane.this.repaint();// repaint + } + }; + + /** + * Pattern type button. + */ + class PatternButton extends JToggleButton implements ActionListener { + + public PatternButton(int pIndex) { + this.pIndex = pIndex; + this.addActionListener(this); + + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.setBorder(null); + this.patternBackground = new PatternBackground(this.pIndex, Color.lightGray, Color.black); + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + + if (this.pIndex == patternIndex) {// it's selected. + g2d.setPaint(UIConstants.LINE_COLOR); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); + } + } + + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 20); + } + + public void setPatternForeground(Color foreground) { + this.patternBackground.setForeground(foreground); + } + + public void setPatternBackground(Color background) { + this.patternBackground.setBackground(background); + } + + /** + * set Pattern setIndex. + */ + public void actionPerformed(ActionEvent evt) { + PatternBackgroundQuickPane.this.patternIndex = pIndex; + + fireChagneListener(); + PatternBackgroundQuickPane.this.repaint();// repaint + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + private int pIndex = 0; + private PatternBackground patternBackground; + } + + @Override + public boolean accept(Background background) { + return background instanceof PatternBackground; + } + + @Override + public String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Background-Pattern"); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java b/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java index dcd386343..33e09057b 100644 --- a/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java +++ b/designer_base/src/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java @@ -33,7 +33,6 @@ public class TextureBackgroundQuickPane extends BackgroundQuickPane { this.add(borderPane, BorderLayout.NORTH); contentPane.setLayout(new GridLayout(0, 8, 1, 1)); contentPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); - borderPane.setPreferredSize(new Dimension(0, 145)); ButtonGroup patternButtonGroup = new ButtonGroup(); textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) {