|
|
|
@ -17,10 +17,7 @@ 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.ItemEvent; |
|
|
|
|
import java.awt.event.ItemListener; |
|
|
|
|
import java.awt.event.*; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -47,6 +44,7 @@ public class JFormSliderPane extends JPanel {
|
|
|
|
|
private static final int SHOWVALBUTTON_WIDTH = 40; |
|
|
|
|
private static final int SHOWVALBUTTON_HEIGHTH = 20; |
|
|
|
|
private static final int SLIDER_GAP = 5; |
|
|
|
|
private static final int TOOLTIP_Y = 25; |
|
|
|
|
private static final Color BACK_COLOR = new Color(245, 245, 247); |
|
|
|
|
public int showValue = 100; |
|
|
|
|
public double resolutionTimes = 1.0; |
|
|
|
@ -75,22 +73,68 @@ public class JFormSliderPane extends JPanel {
|
|
|
|
|
|
|
|
|
|
public JFormSliderPane() { |
|
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
slider = new UISlider(0, HUNDRED, HALF_HUNDRED); |
|
|
|
|
initSlider(); |
|
|
|
|
initShowValSpinner(); |
|
|
|
|
initDownUpButton(); |
|
|
|
|
initShowValButton(); |
|
|
|
|
initUIRadioButton(); |
|
|
|
|
initPane(); |
|
|
|
|
JPanel panel = new JPanel(new FlowLayout(1, 5, 0)); |
|
|
|
|
panel.add(downButton); |
|
|
|
|
panel.add(slider); |
|
|
|
|
panel.add(upButton); |
|
|
|
|
panel.add(showValButton); |
|
|
|
|
panel.setBackground(BACK_COLOR); |
|
|
|
|
this.add(panel, BorderLayout.NORTH); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static final JFormSliderPane getInstance() { |
|
|
|
|
// if (THIS == null) {
|
|
|
|
|
// THIS = new JSliderPane();
|
|
|
|
|
// }
|
|
|
|
|
THIS = new JFormSliderPane(); |
|
|
|
|
return THIS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initSlider() { |
|
|
|
|
slider = new UISlider(0, HUNDRED, HALF_HUNDRED){ |
|
|
|
|
public Point getToolTipLocation(MouseEvent event){ |
|
|
|
|
return new Point(event.getX(), event.getY() - TOOLTIP_Y); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
slider.setUI(new JSliderPaneUI(slider)); |
|
|
|
|
slider.addChangeListener(listener); |
|
|
|
|
slider.setPreferredSize(new Dimension(220, 20)); |
|
|
|
|
//去掉虚线框
|
|
|
|
|
slider.setFocusable(false); |
|
|
|
|
slider.setToolTipText(Inter.getLocText("FR-Designer_Scale_Slider")); |
|
|
|
|
showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initShowValSpinner() { |
|
|
|
|
showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1)){ |
|
|
|
|
public Point getToolTipLocation(MouseEvent event){ |
|
|
|
|
return new Point(event.getX(), event.getY() - TOOLTIP_Y); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
showValSpinner.setEnabled(true); |
|
|
|
|
showValSpinner.addChangeListener(showValSpinnerChangeListener); |
|
|
|
|
showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); |
|
|
|
|
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initDownUpButton() { |
|
|
|
|
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")){ |
|
|
|
|
public Point getToolTipLocation(MouseEvent event){ |
|
|
|
|
return new Point(event.getX(), event.getY() - TOOLTIP_Y); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
downButton.setOpaque(false); |
|
|
|
|
downButton.setBorderPainted(false); |
|
|
|
|
downButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Down")); |
|
|
|
|
upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")); |
|
|
|
|
upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")){ |
|
|
|
|
public Point getToolTipLocation(MouseEvent event){ |
|
|
|
|
return new Point(event.getX(), event.getY() - TOOLTIP_Y); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
upButton.setOpaque(false); |
|
|
|
|
upButton.setBorderPainted(false); |
|
|
|
|
upButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Up")); |
|
|
|
@ -98,7 +142,14 @@ public class JFormSliderPane extends JPanel {
|
|
|
|
|
upButton.setActionCommand("more"); |
|
|
|
|
downButton.addActionListener(buttonActionListener); |
|
|
|
|
upButton.addActionListener(buttonActionListener); |
|
|
|
|
showValButton = new JButton(showValSpinner.getValue() + "%"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initShowValButton() { |
|
|
|
|
showValButton = new JButton(showValSpinner.getValue() + "%"){ |
|
|
|
|
public Point getToolTipLocation(MouseEvent event){ |
|
|
|
|
return new Point(event.getX(), event.getY() - TOOLTIP_Y); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
showValButton.setOpaque(false); |
|
|
|
|
showValButton.setMargin(new Insets(0, 0, 0, 0)); |
|
|
|
|
showValButton.setFont(new Font("SimSun", Font.PLAIN, 12)); |
|
|
|
@ -106,27 +157,8 @@ public class JFormSliderPane extends JPanel {
|
|
|
|
|
showValButton.setBorderPainted(false); |
|
|
|
|
showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); |
|
|
|
|
showValButton.addActionListener(showValButtonActionListener); |
|
|
|
|
//TODO 先注释,需要自定义tooltip
|
|
|
|
|
showValButton.setToolTipText(Inter.getLocText("FR-Designer_Scale_Grade")); |
|
|
|
|
initUIRadioButton(); |
|
|
|
|
initPane(); |
|
|
|
|
JPanel panel = new JPanel(new FlowLayout(1, 5, 0)); |
|
|
|
|
panel.add(downButton); |
|
|
|
|
panel.add(slider); |
|
|
|
|
panel.add(upButton); |
|
|
|
|
panel.add(showValButton); |
|
|
|
|
panel.setBackground(BACK_COLOR); |
|
|
|
|
this.add(panel, BorderLayout.NORTH); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static final JFormSliderPane getInstance() { |
|
|
|
|
// if (THIS == null) {
|
|
|
|
|
// THIS = new JSliderPane();
|
|
|
|
|
// }
|
|
|
|
|
THIS = new JFormSliderPane(); |
|
|
|
|
return THIS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initUIRadioButton() { |
|
|
|
|
twoHundredButton = new UIRadioButton("200%"); |
|
|
|
|
oneHundredButton = new UIRadioButton("100%"); |
|
|
|
|