Browse Source

REPORT-1096 不继承UIButton

master
plough 8 years ago
parent
commit
35198fa0d9
  1. 2
      designer_base/src/com/fr/design/style/color/ColorSelectPane.java
  2. 5
      designer_base/src/com/fr/design/style/color/CustomChooserPanel.java
  3. 4
      designer_base/src/com/fr/design/style/color/NewColorSelectPane.java
  4. 43
      designer_base/src/com/fr/design/style/color/PickColorButton.java
  5. 46
      designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java

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

@ -106,7 +106,7 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7
// 取色按钮
PickColorButton pickColorButton = new PickColorButton(this, PickColorButton.IconType.ICON16, true);
UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON16, true);
row1Pane.add(pickColorButton, BorderLayout.WEST);
// 最近使用

5
designer_base/src/com/fr/design/style/color/CustomChooserPanel.java

@ -12,7 +12,6 @@ import java.awt.Image;
import java.awt.Point;
import java.awt.event.*;
import java.awt.image.MemoryImageSource;
import javax.swing.Timer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -20,7 +19,6 @@ import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import javax.swing.colorchooser.AbstractColorChooserPanel;
@ -31,6 +29,7 @@ import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.islider.UISlider;
@ -710,7 +709,7 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec
hexPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 8, 0));
hexPanel.add(new UILabel("#"));
hexPanel.add(field);
PickColorButton pickColorButton = new PickColorButton(this, PickColorButton.IconType.ICON18, true);
UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON18, true);
hexPanel.add(pickColorButton);
mainPanel.add(hslAndRgbPanel, BorderLayout.CENTER);

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

@ -17,7 +17,6 @@ import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.BaseUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.gui.ibutton.UIButton;
@ -87,8 +86,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
centerPane.add(row1Pane);
// 取色按钮
PickColorButton pickColorButton = new PickColorButton(this, PickColorButton.IconType.ICON16);
UIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON16);
row1Pane.add(pickColorButton, BorderLayout.WEST);
// 最近使用

43
designer_base/src/com/fr/design/style/color/PickColorButton.java

@ -1,43 +0,0 @@
package com.fr.design.style.color;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by plough on 2016/12/22.
*/
public class PickColorButton extends UIButton {
public PickColorButton(final ColorSelectable colorSelectable, IconType iconType){
this(colorSelectable, iconType, false);
}
public PickColorButton(final ColorSelectable colorSelectable, IconType iconType, final Boolean setColorRealTime) {
super();
if (iconType == IconType.ICON16) {
this.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker16.png"));
this.setPreferredSize(new Dimension(16, 16));
} else {
this.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker18.png"));
this.setPreferredSize(new Dimension(18, 18));
}
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ColorPicker colorPicker = new ColorPicker(colorSelectable, setColorRealTime);
colorPicker.start();
}
});
}
// 取色器按钮使用的图标
public enum IconType {
ICON16, ICON18
}
}

46
designer_base/src/com/fr/design/style/color/PickColorButtonFactory.java

@ -0,0 +1,46 @@
package com.fr.design.style.color;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by plough on 2016/12/22.
*/
public class PickColorButtonFactory {
public static UIButton getPickColorButton(ColorSelectable colorSelectable, IconType iconType) {
return getPickColorButton(colorSelectable, iconType, false);
}
public static UIButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final Boolean setColorRealTime) {
UIButton pickColorButton = new UIButton();
if (iconType == IconType.ICON16) {
pickColorButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker16.png"));
pickColorButton.setPreferredSize(new Dimension(16, 16));
} else {
pickColorButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/gui/colorPicker/colorPicker18.png"));
pickColorButton.setPreferredSize(new Dimension(18, 18));
}
pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
pickColorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ColorPicker colorPicker = new ColorPicker(colorSelectable, setColorRealTime);
colorPicker.start();
}
});
return pickColorButton;
}
// 取色器按钮使用的图标
public enum IconType {
ICON16, ICON18
}
}
Loading…
Cancel
Save