From b99265cf87590ed5ab5b73be0085601fa100880d Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 6 Sep 2017 11:20:31 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=AF=86=E7=A0=81=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E8=BE=B9=E6=A1=86=E9=A2=9C=E8=89=B2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/borders/UITextFieldBorder.java | 3 +- .../gui/ipasswordfield/UIPassWordField.java | 47 +++++++++++++++++-- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/borders/UITextFieldBorder.java b/designer_base/src/com/fr/design/gui/borders/UITextFieldBorder.java index b173eb806..019caba03 100644 --- a/designer_base/src/com/fr/design/gui/borders/UITextFieldBorder.java +++ b/designer_base/src/com/fr/design/gui/borders/UITextFieldBorder.java @@ -4,6 +4,7 @@ package com.fr.design.gui.borders; +import com.fr.design.constants.UIConstants; import com.fr.design.utils.DrawRoutines; import com.fr.design.utils.ThemeUtils; @@ -54,7 +55,7 @@ public class UITextFieldBorder extends AbstractBorder implements UIResource { g, ThemeUtils.TEXT_BORDER_DISABLED_COLOR, x, y, w, h); } else { DrawRoutines.drawBorder( - g, ThemeUtils.TEXT_BORDER_COLOR, x, y, w, h); + g, UIConstants.POP_DIALOG_BORDER, x, y, w, h); } } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/ipasswordfield/UIPassWordField.java b/designer_base/src/com/fr/design/gui/ipasswordfield/UIPassWordField.java index c7910d0cd..95f28a0a0 100644 --- a/designer_base/src/com/fr/design/gui/ipasswordfield/UIPassWordField.java +++ b/designer_base/src/com/fr/design/gui/ipasswordfield/UIPassWordField.java @@ -1,8 +1,13 @@ package com.fr.design.gui.ipasswordfield; +import com.fr.design.constants.UIConstants; + import javax.swing.*; import javax.swing.text.Document; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; /** * Created with IntelliJ IDEA. @@ -12,24 +17,56 @@ import javax.swing.text.Document; * To change this template use File | Settings | File Templates. */ public class UIPassWordField extends JPasswordField { + private boolean isRollOver; - public UIPassWordField () { + public UIPassWordField() { super(); + addRollOverListener(); } - public UIPassWordField (String text) { + public UIPassWordField(String text) { super(text); + addRollOverListener(); } - public UIPassWordField (int columns) { + public UIPassWordField(int columns) { super(columns); + addRollOverListener(); } - public UIPassWordField (String text, int columns) { + public UIPassWordField(String text, int columns) { super(text, columns); + addRollOverListener(); } - public UIPassWordField (Document doc, String txt, int columns) { + public UIPassWordField(Document doc, String txt, int columns) { super(doc, txt, columns); + addRollOverListener(); + } + + private void addRollOverListener() { + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + isRollOver = true; + UIPassWordField.this.repaint(); + } + + @Override + public void mouseExited(MouseEvent e) { + isRollOver = false; + UIPassWordField.this.repaint(); + } + }); + } + + @Override + protected void paintBorder(Graphics g) { + if (isRollOver && this.isEnabled()) { + g.setColor(UIConstants.TEXT_FILED_BORDER_SELECTED); + g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); + } else { + super.paintBorder(g); + } } } \ No newline at end of file From e2ad022e9c2cc7e30be676b32958ab822ffd2017 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 6 Sep 2017 12:09:36 +0800 Subject: [PATCH 2/8] format --- .../com/fr/design/gui/ispinner/UISpinner.java | 549 +++++++++--------- .../design/gui/itextfield/UINumberField.java | 402 ++++++------- 2 files changed, 477 insertions(+), 474 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java b/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java index d2b85be2c..4e83b3e9e 100644 --- a/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java @@ -1,17 +1,5 @@ package com.fr.design.gui.ispinner; -import java.awt.*; -import java.awt.event.*; -import java.awt.geom.RoundRectangle2D; - -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.JTextComponent; - import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; @@ -21,183 +9,196 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextFieldUI; -import com.fr.stable.Constants; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.JTextComponent; +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.RoundRectangle2D; public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver { - protected double value; - private static final int SIZE = 20; - private static final int LEN = 13; - private UINumberField textField; - private UIButton preButton; - private UIButton nextButton; - private double minValue; - private double maxValue; - private double dierta; - private String spinnerName = ""; - private UIObserverListener uiObserverListener; - private GlobalNameListener globalNameListener = null; - - - public UISpinner(double minValue, double maxValue, double dierta) { - this.minValue = minValue; - this.maxValue = maxValue; - this.dierta = dierta; - initComponents(); - iniListener(); - } - - public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) { - this(minValue, maxValue, dierta); - textField.setValue(defaultValue); - } - - private void iniListener() { - if (shouldResponseChangeListener()) { - this.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - if (uiObserverListener == null) { - return; - } - uiObserverListener.doChange(); - } - }); - } - } - - /** - * 给组件分别加上FocusListener - * @param focusListener 监听事件 - */ - public void addUISpinnerFocusListenner(FocusListener focusListener) { - this.addFocusListener(focusListener); - this.textField.addFocusListener(focusListener); - this.preButton.addFocusListener(focusListener); - this.nextButton.addFocusListener(focusListener); - - } - - public double getValue() { - return value; - } - - public void setGlobalName(String name) { - spinnerName = name; - } - - public UINumberField getTextField() { - return textField; - } - - public void setValue(double value) { - if (globalNameListener != null && shouldResponseNameListener()) { - globalNameListener.setGlobalName(spinnerName); - } - value = value < minValue ? minValue : value; - value = value > maxValue ? maxValue : value; - if (value == this.value) { - return; - } - this.value = value; - - textField.getDocument().removeDocumentListener(docListener); - textField.setValue(value); - textField.getDocument().addDocumentListener(docListener); - fireStateChanged(); - } - - public void setTextFieldValue(double value) { - if (globalNameListener != null && shouldResponseNameListener()) { - globalNameListener.setGlobalName(spinnerName); - } - value = value < minValue ? minValue : value; - value = value > maxValue ? maxValue : value; - - if (value == this.value) { - return; - } - this.value = value; - fireStateChanged(); - } - - - public void setEnabled(boolean flag) { - super.setEnabled(flag); - this.textField.setEnabled(flag); - this.preButton.setEnabled(flag); - this.nextButton.setEnabled(flag); - } - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.height = SIZE; - return dim; - } - - /** - *增加 a ChangeListener to the listener list. - * @param l 监听事件 - */ - public void addChangeListener(ChangeListener l) { - this.listenerList.add(ChangeListener.class, l); - } - - /** - *移除 a ChangeListener from the listener list. - * @param l 监听事件 - */ - public void removeChangeListener(ChangeListener l) { - this.listenerList.remove(ChangeListener.class, l); - } - - // august: Process the listeners last to first - protected void fireStateChanged() { - Object[] listeners = listenerList.getListenerList(); - - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == ChangeListener.class) { - ((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this)); - } - } - } - - - private void initComponents() { - textField = initNumberField(); - textField.setMaxValue(maxValue); - textField.setMinValue(minValue); - setValue(value); - textField.setUI(new SpinnerTextFieldUI(textField)); - preButton = new UIButton(UIConstants.ARROW_UP_ICON){ + protected double value; + private static final int SIZE = 20; + private static final int LEN = 13; + private UINumberField textField; + private UIButton preButton; + private UIButton nextButton; + private double minValue; + private double maxValue; + private double dierta; + private String spinnerName = ""; + private UIObserverListener uiObserverListener; + private GlobalNameListener globalNameListener = null; + + + public UISpinner(double minValue, double maxValue, double dierta) { + this.minValue = minValue; + this.maxValue = maxValue; + this.dierta = dierta; + initComponents(); + iniListener(); + } + + public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) { + this(minValue, maxValue, dierta); + textField.setValue(defaultValue); + } + + private void iniListener() { + if (shouldResponseChangeListener()) { + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener == null) { + return; + } + uiObserverListener.doChange(); + } + }); + } + } + + /** + * 给组件分别加上FocusListener + * + * @param focusListener 监听事件 + */ + public void addUISpinnerFocusListenner(FocusListener focusListener) { + this.addFocusListener(focusListener); + this.textField.addFocusListener(focusListener); + this.preButton.addFocusListener(focusListener); + this.nextButton.addFocusListener(focusListener); + + } + + public double getValue() { + return value; + } + + public void setGlobalName(String name) { + spinnerName = name; + } + + public UINumberField getTextField() { + return textField; + } + + public void setValue(double value) { + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(spinnerName); + } + value = value < minValue ? minValue : value; + value = value > maxValue ? maxValue : value; + if (value == this.value) { + return; + } + this.value = value; + + textField.getDocument().removeDocumentListener(docListener); + textField.setValue(value); + textField.getDocument().addDocumentListener(docListener); + fireStateChanged(); + } + + public void setTextFieldValue(double value) { + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(spinnerName); + } + value = value < minValue ? minValue : value; + value = value > maxValue ? maxValue : value; + + if (value == this.value) { + return; + } + this.value = value; + fireStateChanged(); + } + + + public void setEnabled(boolean flag) { + super.setEnabled(flag); + this.textField.setEnabled(flag); + this.preButton.setEnabled(flag); + this.nextButton.setEnabled(flag); + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.height = SIZE; + return dim; + } + + /** + * 增加 a ChangeListener to the listener list. + * + * @param l 监听事件 + */ + public void addChangeListener(ChangeListener l) { + this.listenerList.add(ChangeListener.class, l); + } + + /** + * 移除 a ChangeListener from the listener list. + * + * @param l 监听事件 + */ + public void removeChangeListener(ChangeListener l) { + this.listenerList.remove(ChangeListener.class, l); + } + + // august: Process the listeners last to first + protected void fireStateChanged() { + Object[] listeners = listenerList.getListenerList(); + + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChangeListener.class) { + ((ChangeListener) listeners[i + 1]).stateChanged(new ChangeEvent(this)); + } + } + } + + + private void initComponents() { + textField = initNumberField(); + textField.setMaxValue(maxValue); + textField.setMinValue(minValue); + setValue(value); + textField.setUI(new SpinnerTextFieldUI(textField)); + preButton = new UIButton(UIConstants.ARROW_UP_ICON) { public boolean shouldResponseChangeListener() { return false; } }; - preButton.setRoundBorder(true, Constants.LEFT); - nextButton = new UIButton(UIConstants.ARROW_DOWN_ICON) { + preButton.setRoundBorder(true, Constants.LEFT); + nextButton = new UIButton(UIConstants.ARROW_DOWN_ICON) { public boolean shouldResponseChangeListener() { return false; } }; - nextButton.setRoundBorder(true, Constants.LEFT); - setLayout(new BorderLayout()); - add(textField, BorderLayout.CENTER); - JPanel arrowPane = new JPanel(); - arrowPane.setPreferredSize(new Dimension(LEN, SIZE)); - arrowPane.setLayout(new GridLayout(2, 1)); - preButton.setBounds(0, 1, 13, 10); - nextButton.setBounds(0, 10, 13, 10); - arrowPane.add(preButton); - arrowPane.add(nextButton); - add(arrowPane, BorderLayout.EAST); + nextButton.setRoundBorder(true, Constants.LEFT); + setLayout(new BorderLayout()); + add(textField, BorderLayout.CENTER); + JPanel arrowPane = new JPanel(); + arrowPane.setPreferredSize(new Dimension(LEN, SIZE)); + arrowPane.setLayout(new GridLayout(2, 1)); + preButton.setBounds(0, 1, 13, 10); + nextButton.setBounds(0, 10, 13, 10); + arrowPane.add(preButton); + arrowPane.add(nextButton); + add(arrowPane, BorderLayout.EAST); componentInitListeners(); - } + } - private void componentInitListeners(){ + private void componentInitListeners() { preButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -219,7 +220,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver } } }); - textField.getDocument().removeDocumentListener(docListener); + textField.getDocument().removeDocumentListener(docListener); textField.getDocument().addDocumentListener(docListener); textField.addFocusListener(new FocusAdapter() { @Override @@ -229,123 +230,125 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver }); } - protected UINumberField initNumberField() { - return new UINumberField(2) { - public boolean shouldResponseChangeListener() { - return false; - } - }; - } - - private DocumentListener docListener = new DocumentListener() { - @Override - public void removeUpdate(DocumentEvent e) { - setTextFieldValue(textField.getValue()); - } - - @Override - public void insertUpdate(DocumentEvent e) { - setTextFieldValue(textField.getValue()); - } - - @Override - public void changedUpdate(DocumentEvent e) { - setTextFieldValue(textField.getValue()); - } - }; - - /** - * 给组件登记一个观察者监听事件 - * @param listener 观察者监听事件 - */ - public void registerChangeListener(UIObserverListener listener) { - uiObserverListener = listener; - } + protected UINumberField initNumberField() { + return new UINumberField(2) { + public boolean shouldResponseChangeListener() { + return false; + } + }; + } + + private DocumentListener docListener = new DocumentListener() { + @Override + public void removeUpdate(DocumentEvent e) { + setTextFieldValue(textField.getValue()); + } + + @Override + public void insertUpdate(DocumentEvent e) { + setTextFieldValue(textField.getValue()); + } + + @Override + public void changedUpdate(DocumentEvent e) { + setTextFieldValue(textField.getValue()); + } + }; + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ - public boolean shouldResponseChangeListener() { - return true; - } + public boolean shouldResponseChangeListener() { + return true; + } /** * 给组件登记一个全局名字观察者监听事件 * * @param listener 观察者监听事件 */ - public void registerNameListener(GlobalNameListener listener) { - globalNameListener = listener; - } + public void registerNameListener(GlobalNameListener listener) { + globalNameListener = listener; + } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ - public boolean shouldResponseNameListener() { - return true; - } - - private class SpinnerTextFieldUI extends UITextFieldUI { - - public SpinnerTextFieldUI(UITextField textField) { - super(textField); - } - - @Override - public void paintBorder(Graphics2D g2d, int width, int height, - boolean isRound, int rectDirection) { - // do nothing - } - - protected void paintBackground(Graphics g) { - JTextComponent editor = getComponent(); - int width = editor.getWidth(); - int height = editor.getHeight(); - Shape oldClip = g.getClip(); - Shape roundShape = new RoundRectangle2D.Double(0, 0, width, height, UIConstants.ARC, UIConstants.ARC); - Graphics2D g2d = (Graphics2D) g; - g2d.clearRect(0, 0, width, height); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.clip(roundShape); - g2d.setColor(Color.WHITE); - g2d.fillRoundRect(1, 1, width - 2, height - 2, UIConstants.ARC, UIConstants.ARC); - if (isRollOver && isEnabled()) { - Shape shape = new RoundRectangle2D.Double(1, 1, width - 3, height - 3, UIConstants.ARC, UIConstants.ARC); - GUIPaintUtils.paintBorderShadow(g2d, 3, shape, UIConstants.HOVER_BLUE, Color.WHITE); - } else { - g2d.setColor(UIConstants.LINE_COLOR); - g2d.drawRoundRect(1, 1, width - 2, height - 2, UIConstants.ARC, UIConstants.ARC); - g2d.clearRect(width - 2, 0, 2, height); - g2d.setClip(oldClip); - g2d.drawLine(width - 2, 1, width, 1); - g2d.drawLine(width - 2, height - 1, width, height - 1); - } - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - } + public boolean shouldResponseNameListener() { + return true; + } + + private class SpinnerTextFieldUI extends UITextFieldUI { + + public SpinnerTextFieldUI(UITextField textField) { + super(textField); + } + + @Override + public void paintBorder(Graphics2D g2d, int width, int height, + boolean isRound, int rectDirection) { + // do nothing + } + + protected void paintBackground(Graphics g) { + JTextComponent editor = getComponent(); + int width = editor.getWidth(); + int height = editor.getHeight(); + Shape oldClip = g.getClip(); + Shape roundShape = new RoundRectangle2D.Double(0, 0, width, height, UIConstants.ARC, UIConstants.ARC); + Graphics2D g2d = (Graphics2D) g; + g2d.clearRect(0, 0, width, height); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.clip(roundShape); + g2d.setColor(Color.WHITE); + g2d.fillRoundRect(1, 1, width - 2, height - 2, UIConstants.ARC, UIConstants.ARC); + if (isRollOver && isEnabled()) { + Shape shape = new RoundRectangle2D.Double(1, 1, width - 3, height - 3, UIConstants.ARC, UIConstants.ARC); + GUIPaintUtils.paintBorderShadow(g2d, 3, shape, UIConstants.HOVER_BLUE, Color.WHITE); + } else { + g2d.setColor(UIConstants.LINE_COLOR); + g2d.drawRoundRect(1, 1, width - 2, height - 2, UIConstants.ARC, UIConstants.ARC); + g2d.clearRect(width - 2, 0, 2, height); + g2d.setClip(oldClip); + g2d.drawLine(width - 2, 1, width, 1); + g2d.drawLine(width - 2, height - 1, width, height - 1); + } + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } + + } /** - * 程序入口 测试 - * @param args 参数 + * 程序入口 测试 + * + * @param args 参数 */ - public static void main(String... args) { - LayoutManager layoutManager = null; - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(layoutManager); - - UISpinner bb = new UISpinner(0, 9, 1); - bb.setValue(4); - bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); - content.add(bb); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 400); - jf.setVisible(true); - } + public static void main(String... args) { + LayoutManager layoutManager = null; + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(layoutManager); + + UISpinner bb = new UISpinner(0, 9, 1); + bb.setValue(4); + bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); + content.add(bb); + GUICoreUtils.centerWindow(jf); + jf.setSize(400, 400); + jf.setVisible(true); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/itextfield/UINumberField.java b/designer_base/src/com/fr/design/gui/itextfield/UINumberField.java index 439e98d56..e0f571042 100644 --- a/designer_base/src/com/fr/design/gui/itextfield/UINumberField.java +++ b/designer_base/src/com/fr/design/gui/itextfield/UINumberField.java @@ -16,92 +16,92 @@ import java.awt.*; * Number Field. */ public class UINumberField extends UITextField { - public static final double ERROR_VALUE = Double.MAX_VALUE + 4.44; // peter:错误的值. - /** - * 整数部分的长度 - */ - private int maxIntegerLength = 24; - /** - * 小数部分的长度 - */ + public static final double ERROR_VALUE = Double.MAX_VALUE + 4.44; // peter:错误的值. + /** + * 整数部分的长度 + */ + private int maxIntegerLength = 24; + /** + * 小数部分的长度 + */ private static final int DEFAULTMAXDECIMALLENTH = 16; - private static final int TESTMAXVALUE = 100; - private static final int TESTMINVALUE = -10; - private int maxDecimalLength = 16; - private double minValue = -Double.MAX_VALUE; - private double maxValue = Double.MAX_VALUE; - - private boolean isContentChanged = false; - - public UINumberField() { - this(32, 16); - } - - public UINumberField(int columns) { - this(); - setColumns(columns); - } - - public UINumberField(int maxIntegerLength, int maxDecimalLength) { - this(maxIntegerLength, maxDecimalLength, -Double.MAX_VALUE, Double.MAX_VALUE); - } - - public UINumberField(int maxIntegerLength, int maxDecimalLength, double minValue, double maxValue) { - this.maxIntegerLength = maxIntegerLength; - this.maxDecimalLength = maxDecimalLength; - this.minValue = minValue; - this.maxValue = maxValue; - setFieldDocument(); - } - - public void setFieldDocument(){ + private static final int TESTMAXVALUE = 100; + private static final int TESTMINVALUE = -10; + private int maxDecimalLength = 16; + private double minValue = -Double.MAX_VALUE; + private double maxValue = Double.MAX_VALUE; + + private boolean isContentChanged = false; + + public UINumberField() { + this(32, 16); + } + + public UINumberField(int columns) { + this(); + setColumns(columns); + } + + public UINumberField(int maxIntegerLength, int maxDecimalLength) { + this(maxIntegerLength, maxDecimalLength, -Double.MAX_VALUE, Double.MAX_VALUE); + } + + public UINumberField(int maxIntegerLength, int maxDecimalLength, double minValue, double maxValue) { + this.maxIntegerLength = maxIntegerLength; + this.maxDecimalLength = maxDecimalLength; + this.minValue = minValue; + this.maxValue = maxValue; + setFieldDocument(); + } + + public void setFieldDocument() { setDocument(new NumberDocument()); initListener(); } - public int getMaxIntegerLength() { - return maxIntegerLength; - } - - public void setMaxIntegerLength(int maxIntegerLength) { - this.maxIntegerLength = maxIntegerLength; - } - - public int getMaxDecimalLength() { - return maxDecimalLength; - } - - public void setMaxDecimalLength(int maxDecimalLength) { - this.maxDecimalLength = maxDecimalLength; - } - - public double getMinValue() { - return minValue; - } - - public void setMinValue(double minValue) { - this.minValue = minValue; - } - - public double getMaxValue() { - return maxValue; - } - - public void setMaxValue(double maxValue) { - this.maxValue = maxValue; - } - - /** - * Set the value. - */ - public void setValue(double value) { - this.setText(Utils.doubleToString(value)); - } - - /** - * Return the value. - */ - public double getValue() throws NumberFormatException { + public int getMaxIntegerLength() { + return maxIntegerLength; + } + + public void setMaxIntegerLength(int maxIntegerLength) { + this.maxIntegerLength = maxIntegerLength; + } + + public int getMaxDecimalLength() { + return maxDecimalLength; + } + + public void setMaxDecimalLength(int maxDecimalLength) { + this.maxDecimalLength = maxDecimalLength; + } + + public double getMinValue() { + return minValue; + } + + public void setMinValue(double minValue) { + this.minValue = minValue; + } + + public double getMaxValue() { + return maxValue; + } + + public void setMaxValue(double maxValue) { + this.maxValue = maxValue; + } + + /** + * Set the value. + */ + public void setValue(double value) { + this.setText(Utils.doubleToString(value)); + } + + /** + * Return the value. + */ + public double getValue() throws NumberFormatException { try { if (this.getText().length() == 0) { return 0; @@ -113,134 +113,134 @@ public class UINumberField extends UITextField { } } - /** - * Retusn text value. - */ - public String getTextValue() { - return this.getText(); - } - - /** - * Set property integer. - * - * @param integer - * New value of property integer. - */ - public void setInteger(boolean integer) { - if (integer) { - this.maxDecimalLength = 0; - } else { - this.maxDecimalLength = DEFAULTMAXDECIMALLENTH; - } - } - - /** - * Check whether the content changed. - */ - public boolean isContentChanged() { - return isContentChanged; - } - - public void setisContentChanged(boolean isContentChanged){ + /** + * Retusn text value. + */ + public String getTextValue() { + return this.getText(); + } + + /** + * Set property integer. + * + * @param integer New value of property integer. + */ + public void setInteger(boolean integer) { + if (integer) { + this.maxDecimalLength = 0; + } else { + this.maxDecimalLength = DEFAULTMAXDECIMALLENTH; + } + } + + /** + * Check whether the content changed. + */ + public boolean isContentChanged() { + return isContentChanged; + } + + public void setisContentChanged(boolean isContentChanged) { this.isContentChanged = isContentChanged; } - - @Override - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 20); - } - class NumberDocument extends PlainDocument { - public NumberDocument() { - } + @Override + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 20); + } + + class NumberDocument extends PlainDocument { + public NumberDocument() { + } + public boolean checkString(int offset, String s, String str) { - return (ComparatorUtils.equals(s,"F") - || ComparatorUtils.equals(s,"f") - || ComparatorUtils.equals(s,"D") - || ComparatorUtils.equals(s,"d") - ||(ComparatorUtils.equals(str.trim(),"0") && !ComparatorUtils.equals(s.substring(0, 1),".") && offset != 0)// 第一位是0时,第二位只能为小数点 - ||(ComparatorUtils.equals(s,".") && maxDecimalLength == 0)); + return (ComparatorUtils.equals(s, "F") + || ComparatorUtils.equals(s, "f") + || ComparatorUtils.equals(s, "D") + || ComparatorUtils.equals(s, "d") + || (ComparatorUtils.equals(str.trim(), "0") && !ComparatorUtils.equals(s.substring(0, 1), ".") && offset != 0)// 第一位是0时,第二位只能为小数点 + || (ComparatorUtils.equals(s, ".") && maxDecimalLength == 0)); } - - public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { - String str = getText(0, getLength()); - - // 不能为f,F,d,D - if (checkString(offset,s, str) ) { - Toolkit.getDefaultToolkit().beep(); - return; - } - - String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); - if(notChange(strNew)) { - return; - } - setisContentChanged(true); - super.insertString(offset, s, a); - } - - // kunsnat: 这种限制输入 有个不好的地方, 比如删除时: 10.1 最大值限定100, 那么就删除中间的小数点之后变为101, 超出了100. - // 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难.. - private boolean notChange(String strNew) { - boolean noChange = false; - strNew = strNew.replaceFirst("-", StringUtils.EMPTY); // 控制能输入负数 - boolean isMinus = strNew.startsWith("-"); - String strIntPart; - String strDecPart = StringUtils.EMPTY; - int decPos = strNew.indexOf(CoreConstants.DOT); - if (decPos > -1) { - strIntPart = strNew.substring(0, decPos); - strDecPart = strNew.substring(decPos + 1); - } else { - strIntPart = strNew; - } - if (isOverMaxOrMinValue(strIntPart, strDecPart, strNew)) { - Toolkit.getDefaultToolkit().beep(); - noChange = true; - } - - try { - if (!ComparatorUtils.equals(strNew, StringUtils.EMPTY) && !ComparatorUtils.equals(strNew, "-")) {// 控制能输入负数 - double d = Double.parseDouble(strNew) * (isMinus ? -1 : 1); - if (d < minValue || d > maxValue) { - throw new Exception(); - } - } - } catch (Exception e) { - Toolkit.getDefaultToolkit().beep(); - noChange = true; - } - - return noChange; - } - - private boolean isOverMaxOrMinValue(String strIntPart, String strDecPart, String strNew) { - return strIntPart.length() > maxIntegerLength - || strDecPart.length() > maxDecimalLength - || (strNew.length() > 1 && ComparatorUtils.equals(strNew.substring(0, 1), "0") && !ComparatorUtils.equals(strNew.substring(1, 2),".")); - } - } + + public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { + String str = getText(0, getLength()); + + // 不能为f,F,d,D + if (checkString(offset, s, str)) { + Toolkit.getDefaultToolkit().beep(); + return; + } + + String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); + if (notChange(strNew)) { + return; + } + setisContentChanged(true); + super.insertString(offset, s, a); + } + + // kunsnat: 这种限制输入 有个不好的地方, 比如删除时: 10.1 最大值限定100, 那么就删除中间的小数点之后变为101, 超出了100. + // 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难.. + private boolean notChange(String strNew) { + boolean noChange = false; + strNew = strNew.replaceFirst("-", StringUtils.EMPTY); // 控制能输入负数 + boolean isMinus = strNew.startsWith("-"); + String strIntPart; + String strDecPart = StringUtils.EMPTY; + int decPos = strNew.indexOf(CoreConstants.DOT); + if (decPos > -1) { + strIntPart = strNew.substring(0, decPos); + strDecPart = strNew.substring(decPos + 1); + } else { + strIntPart = strNew; + } + if (isOverMaxOrMinValue(strIntPart, strDecPart, strNew)) { + Toolkit.getDefaultToolkit().beep(); + noChange = true; + } + + try { + if (!ComparatorUtils.equals(strNew, StringUtils.EMPTY) && !ComparatorUtils.equals(strNew, "-")) {// 控制能输入负数 + double d = Double.parseDouble(strNew) * (isMinus ? -1 : 1); + if (d < minValue || d > maxValue) { + throw new Exception(); + } + } + } catch (Exception e) { + Toolkit.getDefaultToolkit().beep(); + noChange = true; + } + + return noChange; + } + + private boolean isOverMaxOrMinValue(String strIntPart, String strDecPart, String strNew) { + return strIntPart.length() > maxIntegerLength + || strDecPart.length() > maxDecimalLength + || (strNew.length() > 1 && ComparatorUtils.equals(strNew.substring(0, 1), "0") && !ComparatorUtils.equals(strNew.substring(1, 2), ".")); + } + } /** * 测试程序 */ - public static void main(String[] args) { - JFrame frame = new JFrame(""); - frame.setSize(400, 320); - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); - UINumberField tt = new UINumberField(); - tt.setMinValue(0.0); - tt.setMaxValue(100.0); - frame.getContentPane().setLayout(new GridLayout(10, 2)); - frame.getContentPane().add(new UILabel("New JNumberField()")); - frame.getContentPane().add(tt); - frame.getContentPane().add(new UILabel("New JNumberField(2)")); - frame.getContentPane().add(new UILabel("New JNumberField(8,2)")); - frame.getContentPane().add(new UINumberField(8, 2)); - frame.getContentPane().add(new UILabel("New JNumberField(5,2,-10,100)")); - frame.getContentPane().add(new UINumberField(5, 2, TESTMINVALUE, TESTMAXVALUE)); - frame.setVisible(true); - } + public static void main(String[] args) { + JFrame frame = new JFrame(""); + frame.setSize(400, 320); + Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); + UINumberField tt = new UINumberField(); + tt.setMinValue(0.0); + tt.setMaxValue(100.0); + frame.getContentPane().setLayout(new GridLayout(10, 2)); + frame.getContentPane().add(new UILabel("New JNumberField()")); + frame.getContentPane().add(tt); + frame.getContentPane().add(new UILabel("New JNumberField(2)")); + frame.getContentPane().add(new UILabel("New JNumberField(8,2)")); + frame.getContentPane().add(new UINumberField(8, 2)); + frame.getContentPane().add(new UILabel("New JNumberField(5,2,-10,100)")); + frame.getContentPane().add(new UINumberField(5, 2, TESTMINVALUE, TESTMAXVALUE)); + frame.setVisible(true); + } } \ No newline at end of file From 49a5523ca111f185a093557d15eed34ed8788fb7 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 6 Sep 2017 12:22:37 +0800 Subject: [PATCH 3/8] =?UTF-8?q?Spinner=E7=9A=84=E8=BE=B9=E6=A1=86=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ispinner/UISpinner.java | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java b/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java index 4e83b3e9e..6a1894bc6 100644 --- a/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java @@ -7,10 +7,7 @@ import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.itextfield.UINumberField; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.gui.itextfield.UITextFieldUI; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; import javax.swing.*; @@ -18,10 +15,8 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import javax.swing.text.JTextComponent; import java.awt.*; import java.awt.event.*; -import java.awt.geom.RoundRectangle2D; public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver { @@ -172,7 +167,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver textField.setMaxValue(maxValue); textField.setMinValue(minValue); setValue(value); - textField.setUI(new SpinnerTextFieldUI(textField)); preButton = new UIButton(UIConstants.ARROW_UP_ICON) { public boolean shouldResponseChangeListener() { return false; @@ -291,46 +285,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver return true; } - private class SpinnerTextFieldUI extends UITextFieldUI { - - public SpinnerTextFieldUI(UITextField textField) { - super(textField); - } - - @Override - public void paintBorder(Graphics2D g2d, int width, int height, - boolean isRound, int rectDirection) { - // do nothing - } - - protected void paintBackground(Graphics g) { - JTextComponent editor = getComponent(); - int width = editor.getWidth(); - int height = editor.getHeight(); - Shape oldClip = g.getClip(); - Shape roundShape = new RoundRectangle2D.Double(0, 0, width, height, UIConstants.ARC, UIConstants.ARC); - Graphics2D g2d = (Graphics2D) g; - g2d.clearRect(0, 0, width, height); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.clip(roundShape); - g2d.setColor(Color.WHITE); - g2d.fillRoundRect(1, 1, width - 2, height - 2, UIConstants.ARC, UIConstants.ARC); - if (isRollOver && isEnabled()) { - Shape shape = new RoundRectangle2D.Double(1, 1, width - 3, height - 3, UIConstants.ARC, UIConstants.ARC); - GUIPaintUtils.paintBorderShadow(g2d, 3, shape, UIConstants.HOVER_BLUE, Color.WHITE); - } else { - g2d.setColor(UIConstants.LINE_COLOR); - g2d.drawRoundRect(1, 1, width - 2, height - 2, UIConstants.ARC, UIConstants.ARC); - g2d.clearRect(width - 2, 0, 2, height); - g2d.setClip(oldClip); - g2d.drawLine(width - 2, 1, width, 1); - g2d.drawLine(width - 2, height - 1, width, height - 1); - } - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - } - /** * 程序入口 测试 * From 088b7ad01f9fe43469003db5432c7c3ea1ad3e0a Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 6 Sep 2017 13:57:11 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=96=87=E5=AD=97tab=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settingpane/style/CustomStylePane.java | 2 - .../com/fr/design/gui/ibutton/UITabGroup.java | 87 +------------------ 2 files changed, 3 insertions(+), 86 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java index e12e8dacd..691221bda 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java @@ -10,11 +10,9 @@ import com.fr.design.gui.ibutton.FiveButtonLayout; import com.fr.design.gui.style.*; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.style.BorderUtils; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.*; import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; diff --git a/designer_base/src/com/fr/design/gui/ibutton/UITabGroup.java b/designer_base/src/com/fr/design/gui/ibutton/UITabGroup.java index 51e89437b..f528cff2e 100644 --- a/designer_base/src/com/fr/design/gui/ibutton/UITabGroup.java +++ b/designer_base/src/com/fr/design/gui/ibutton/UITabGroup.java @@ -1,12 +1,8 @@ package com.fr.design.gui.ibutton; -import java.awt.*; - -import javax.swing.BorderFactory; -import javax.swing.Icon; +import javax.swing.*; import javax.swing.border.Border; - -import com.fr.design.constants.UIConstants; +import java.awt.*; public class UITabGroup extends UIButtonGroup { private boolean isOneLineTab = false; @@ -46,83 +42,6 @@ public class UITabGroup extends UIButtonGroup { } } - @Override - protected void paintBorder(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - g2d.setColor(UIConstants.LINE_COLOR); - if (!isTwoLine()) { - int width = isDrawLine ? ORIGINAL_WIDTH : 0; - for (int i = 0; i < labelButtonList.size() - 1; i++) { - width += labelButtonList.get(i).getWidth() + 1; - int height = labelButtonList.get(i).getHeight(); - g.drawLine(width, 0, width, height); - } - - width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1; - if (isDrawLine) { - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.drawRoundRect(ORIGINAL_WIDTH, 0, width - ORIGINAL_WIDTH, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } else { - g2d.drawRect(0, 0, width, getHeight() - 1); - } - - } else if (labelButtonList.size() % 2 != 0) { - paintOddNumberButtons(g, g2d); - } else { - int width = ORIGINAL_WIDTH; - int number = labelButtonList.size() / 2; - for (int i = 0; i < number - 1; i++) { - width += labelButtonList.get(i).getWidth() + 1; - int height = labelButtonList.get(i).getHeight() * 2 + 1; - g.drawLine(width, 0, width, height); - } - width += labelButtonList.get(number - 1).getWidth() + 1; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.drawRoundRect(ORIGINAL_WIDTH, 0, width - ORIGINAL_WIDTH, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - - } - if (isDrawLine) { - g2d.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2); - } - } - - private void paintOddNumberButtons(Graphics g, Graphics2D g2d) { - int width = ORIGINAL_WIDTH; - int buttonHeight = labelButtonList.get(0).getHeight(); - int upButtonCount = labelButtonList.size() / 2 + 1; - for (int i = 0; i < upButtonCount - 1; i++) { - width += labelButtonList.get(i).getWidth() + 1; - int height = labelButtonList.get(i).getHeight() + 1; - g.drawLine(width, 0, width, height); - } - width += labelButtonList.get(upButtonCount - 1).getWidth() + 1; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.drawRoundRect(ORIGINAL_WIDTH, 0, width - ORIGINAL_WIDTH, buttonHeight + 1, UIConstants.ARC, UIConstants.ARC); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - int line2X = labelButtonList.get(upButtonCount).getX(); - int line2Y = labelButtonList.get(upButtonCount).getY(); - width = line2X; - width += labelButtonList.get(upButtonCount).getWidth(); - int height = labelButtonList.get(upButtonCount).getHeight() + 1; - g.drawLine(width, line2Y, width, line2Y + height); - for (int i = upButtonCount + 1; i < labelButtonList.size() - 1; i++) { - width += labelButtonList.get(i).getWidth() + 1; - height = labelButtonList.get(i).getHeight() + 1; - g.drawLine(width, line2Y, width, line2Y + height); - } - width += labelButtonList.get(upButtonCount).getWidth() + 1; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.drawRoundRect(line2X - 1, line2Y, width - line2X + 1, buttonHeight, UIConstants.ARC, UIConstants.ARC); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - - } - - protected boolean isTwoLine() { - return labelButtonList.size() >= BUTTON_NUMBER && !isOneLineTab; - } - public void setOneLineTab(boolean isOneLineTab) { this.isOneLineTab = isOneLineTab; } @@ -138,7 +57,7 @@ public class UITabGroup extends UIButtonGroup { @Override protected Border getGroupBorder() { if (!isDrawLine) { - return BorderFactory.createEmptyBorder(1, 1, 1, 1); + return BorderFactory.createEmptyBorder(0, 0, 0, 0); } return BorderFactory.createEmptyBorder(1, GAP, 1, GAP); } From 894c62256693ecafa28410c99a375af4ba64ccb8 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 6 Sep 2017 14:34:14 +0800 Subject: [PATCH 5/8] =?UTF-8?q?TextArea=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/gui/UILookAndFeel.java | 1 + .../fr/design/gui/itextarea/UITextArea.java | 4 +- .../fr/design/gui/itextarea/UITextAreaUI.java | 83 ++++++++----------- 3 files changed, 38 insertions(+), 50 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/UILookAndFeel.java b/designer_base/src/com/fr/design/gui/UILookAndFeel.java index 205abed29..d49cd9460 100644 --- a/designer_base/src/com/fr/design/gui/UILookAndFeel.java +++ b/designer_base/src/com/fr/design/gui/UILookAndFeel.java @@ -171,6 +171,7 @@ public class UILookAndFeel extends MetalLookAndFeel { table.put("FormattedTextField.border", new UITextFieldBorder()); table.put("TextField.border", new UITextFieldBorder()); table.put("PasswordField.border", new UITextFieldBorder()); + table.put("TextArea.border", new UITextFieldBorder()); } diff --git a/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java b/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java index 534be62ee..c731483bc 100644 --- a/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java +++ b/designer_base/src/com/fr/design/gui/itextarea/UITextArea.java @@ -4,6 +4,7 @@ import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.Constants; import javax.swing.*; import javax.swing.event.DocumentEvent; @@ -99,10 +100,9 @@ public class UITextArea extends JTextArea implements UIObserver { @Override protected void paintBorder(Graphics g) { - + getUI().paintBorder((Graphics2D) g, getWidth(), getHeight(), true, Constants.NULL); } - @Override /** * diff --git a/designer_base/src/com/fr/design/gui/itextarea/UITextAreaUI.java b/designer_base/src/com/fr/design/gui/itextarea/UITextAreaUI.java index d013d0de0..6e3f717dc 100644 --- a/designer_base/src/com/fr/design/gui/itextarea/UITextAreaUI.java +++ b/designer_base/src/com/fr/design/gui/itextarea/UITextAreaUI.java @@ -1,56 +1,43 @@ package com.fr.design.gui.itextarea; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.geom.RoundRectangle2D; - -import javax.swing.JComponent; -import javax.swing.plaf.basic.BasicTextAreaUI; -import javax.swing.text.JTextComponent; - import com.fr.design.constants.UIConstants; import com.fr.design.utils.gui.GUIPaintUtils; -public class UITextAreaUI extends BasicTextAreaUI { - protected boolean isRollOver; - private JComponent textField; - - public UITextAreaUI(final JComponent textField) { - super(); - this.textField = textField; - this.textField.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - isRollOver = true; - textField.repaint(); - } - - @Override - public void mouseExited(MouseEvent e) { - isRollOver = false; - textField.repaint(); - } - }); - } +import javax.swing.*; +import javax.swing.plaf.basic.BasicTextAreaUI; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; - @Override - protected void paintBackground(Graphics g) { - JTextComponent editor = getComponent(); - int width = editor.getWidth(); - int height = editor.getHeight(); - Graphics2D g2d = (Graphics2D)g; - g2d.clearRect(0, 0, width, height); - if(isRollOver && textField.isEnabled() && ((UITextArea)textField).isEditable()) { - Shape shape = new RoundRectangle2D.Double(1, 1, width - 3, height - 3, UIConstants.ARC, UIConstants.ARC); - GUIPaintUtils.paintBorderShadow(g2d, 3, shape, UIConstants.HOVER_BLUE, Color.WHITE); - } else { - g2d.setColor(UIConstants.LINE_COLOR); - g2d.drawRoundRect(1, 1, width - 2, height - 2, UIConstants.ARC, UIConstants.ARC); - } - } +public class UITextAreaUI extends BasicTextAreaUI { + protected boolean isRollOver; + private JComponent textField; + + public UITextAreaUI(final JComponent textField) { + super(); + this.textField = textField; + this.textField.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + isRollOver = true; + textField.repaint(); + } + + @Override + public void mouseExited(MouseEvent e) { + isRollOver = false; + textField.repaint(); + } + }); + } + + public void paintBorder(Graphics2D g2d, int width, int height, boolean isRound, int rectDirection) { + if (isRollOver && textField.isEnabled()) { + g2d.setColor(UIConstants.TEXT_FILED_BORDER_SELECTED); + g2d.drawRect(0, 0, width - 1, height - 1); + } else { + GUIPaintUtils.drawBorder(g2d, 0, 0, width, height, isRound, rectDirection); + } + } } \ No newline at end of file From f79a6d43b48cc079ce9165b36387fbb292d995f7 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 6 Sep 2017 16:49:48 +0800 Subject: [PATCH 6/8] =?UTF-8?q?UIButtonGroup=EF=BC=8CCustomStylePane=20bor?= =?UTF-8?q?der?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settingpane/style/CustomStylePane.java | 3 +- .../fr/design/gui/ibutton/UIButtonGroup.java | 28 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java index 691221bda..eab759333 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java @@ -6,7 +6,6 @@ import com.fr.base.Style; import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.MultiTabPane; -import com.fr.design.gui.ibutton.FiveButtonLayout; import com.fr.design.gui.style.*; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.style.BorderUtils; @@ -39,7 +38,7 @@ public class CustomStylePane extends MultiTabPane