|
|
@ -15,15 +15,38 @@ import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
|
|
|
import javax.swing.ButtonGroup; |
|
|
|
|
|
|
|
import javax.swing.JButton; |
|
|
|
|
|
|
|
import javax.swing.JFormattedTextField; |
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
|
|
|
|
import javax.swing.JRadioButton; |
|
|
|
|
|
|
|
import javax.swing.JSeparator; |
|
|
|
|
|
|
|
import javax.swing.JSpinner; |
|
|
|
|
|
|
|
import javax.swing.SpinnerNumberModel; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.plaf.basic.BasicSliderUI; |
|
|
|
import javax.swing.plaf.basic.BasicSliderUI; |
|
|
|
import javax.swing.text.BadLocationException; |
|
|
|
|
|
|
|
import javax.swing.text.DefaultFormatterFactory; |
|
|
|
import javax.swing.text.DefaultFormatterFactory; |
|
|
|
import javax.swing.text.NumberFormatter; |
|
|
|
import javax.swing.text.NumberFormatter; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
|
|
|
import java.awt.EventQueue; |
|
|
|
|
|
|
|
import java.awt.FlowLayout; |
|
|
|
|
|
|
|
import java.awt.Font; |
|
|
|
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
|
|
|
import java.awt.Point; |
|
|
|
|
|
|
|
import java.awt.Rectangle; |
|
|
|
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import java.awt.event.ItemEvent; |
|
|
|
|
|
|
|
import java.awt.event.ItemListener; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -55,7 +78,6 @@ public class JSliderPane extends JPanel { |
|
|
|
private static final Color BACK_COLOR = new Color(245, 245, 247); |
|
|
|
private static final Color BACK_COLOR = new Color(245, 245, 247); |
|
|
|
public int showValue = 100; |
|
|
|
public int showValue = 100; |
|
|
|
public double resolutionTimes = 1.0; |
|
|
|
public double resolutionTimes = 1.0; |
|
|
|
private static JSliderPane THIS; |
|
|
|
|
|
|
|
private UITextField showVal; |
|
|
|
private UITextField showVal; |
|
|
|
private JSpinner showValSpinner; |
|
|
|
private JSpinner showValSpinner; |
|
|
|
private UISlider slider; |
|
|
|
private UISlider slider; |
|
|
@ -66,12 +88,14 @@ public class JSliderPane extends JPanel { |
|
|
|
private UISliderButton showValButton; |
|
|
|
private UISliderButton showValButton; |
|
|
|
private UIRadioButton twoHundredButton; |
|
|
|
private UIRadioButton twoHundredButton; |
|
|
|
private UIRadioButton oneHundredButton; |
|
|
|
private UIRadioButton oneHundredButton; |
|
|
|
private UIRadioButton SevenFiveButton; |
|
|
|
private UIRadioButton sevenFiveButton; |
|
|
|
private UIRadioButton fiveTenButton; |
|
|
|
private UIRadioButton fiveTenButton; |
|
|
|
private UIRadioButton twoFiveButton; |
|
|
|
private UIRadioButton twoFiveButton; |
|
|
|
private UIRadioButton selfAdaptButton; |
|
|
|
private UIRadioButton selfAdaptButton; |
|
|
|
private UIRadioButton customButton; |
|
|
|
private UIRadioButton customButton; |
|
|
|
//拖动条处理和button、直接输入不一样
|
|
|
|
/** |
|
|
|
|
|
|
|
* 拖动条处理和button、直接输入不一样 |
|
|
|
|
|
|
|
*/ |
|
|
|
private boolean isButtonOrIsTxt = true; |
|
|
|
private boolean isButtonOrIsTxt = true; |
|
|
|
private PopupPane dialog; |
|
|
|
private PopupPane dialog; |
|
|
|
private int upButtonX; |
|
|
|
private int upButtonX; |
|
|
@ -95,7 +119,7 @@ public class JSliderPane extends JPanel { |
|
|
|
initShowValButton(); |
|
|
|
initShowValButton(); |
|
|
|
initUIRadioButton(); |
|
|
|
initUIRadioButton(); |
|
|
|
initPane(); |
|
|
|
initPane(); |
|
|
|
JPanel panel = new JPanel(new FlowLayout(1, 0, 0)); |
|
|
|
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); |
|
|
|
panel.add(downButton); |
|
|
|
panel.add(downButton); |
|
|
|
panel.add(slider); |
|
|
|
panel.add(slider); |
|
|
|
panel.add(upButton); |
|
|
|
panel.add(upButton); |
|
|
@ -105,12 +129,8 @@ public class JSliderPane extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final JSliderPane getInstance() { |
|
|
|
public static JSliderPane getInstance() { |
|
|
|
// if (THIS == null) {
|
|
|
|
return new JSliderPane(); |
|
|
|
// THIS = new JSliderPane();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
THIS = new JSliderPane(); |
|
|
|
|
|
|
|
return THIS; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initSlider() { |
|
|
|
private void initSlider() { |
|
|
@ -174,7 +194,7 @@ public class JSliderPane extends JPanel { |
|
|
|
private void initUIRadioButton() { |
|
|
|
private void initUIRadioButton() { |
|
|
|
twoHundredButton = new UIRadioButton("200%"); |
|
|
|
twoHundredButton = new UIRadioButton("200%"); |
|
|
|
oneHundredButton = new UIRadioButton("100%"); |
|
|
|
oneHundredButton = new UIRadioButton("100%"); |
|
|
|
SevenFiveButton = new UIRadioButton("75%"); |
|
|
|
sevenFiveButton = new UIRadioButton("75%"); |
|
|
|
fiveTenButton = new UIRadioButton("50%"); |
|
|
|
fiveTenButton = new UIRadioButton("50%"); |
|
|
|
twoFiveButton = new UIRadioButton("25%"); |
|
|
|
twoFiveButton = new UIRadioButton("25%"); |
|
|
|
selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton")); |
|
|
|
selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton")); |
|
|
@ -183,7 +203,7 @@ public class JSliderPane extends JPanel { |
|
|
|
customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); |
|
|
|
customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); |
|
|
|
twoHundredButton.addItemListener(radioButtonItemListener); |
|
|
|
twoHundredButton.addItemListener(radioButtonItemListener); |
|
|
|
oneHundredButton.addItemListener(radioButtonItemListener); |
|
|
|
oneHundredButton.addItemListener(radioButtonItemListener); |
|
|
|
SevenFiveButton.addItemListener(radioButtonItemListener); |
|
|
|
sevenFiveButton.addItemListener(radioButtonItemListener); |
|
|
|
fiveTenButton.addItemListener(radioButtonItemListener); |
|
|
|
fiveTenButton.addItemListener(radioButtonItemListener); |
|
|
|
twoFiveButton.addItemListener(radioButtonItemListener); |
|
|
|
twoFiveButton.addItemListener(radioButtonItemListener); |
|
|
|
customButton.addItemListener(new ItemListener() { |
|
|
|
customButton.addItemListener(new ItemListener() { |
|
|
@ -201,7 +221,7 @@ public class JSliderPane extends JPanel { |
|
|
|
ButtonGroup bg = new ButtonGroup();// 初始化按钮组
|
|
|
|
ButtonGroup bg = new ButtonGroup();// 初始化按钮组
|
|
|
|
bg.add(twoHundredButton);// 加入按钮组
|
|
|
|
bg.add(twoHundredButton);// 加入按钮组
|
|
|
|
bg.add(oneHundredButton); |
|
|
|
bg.add(oneHundredButton); |
|
|
|
bg.add(SevenFiveButton); |
|
|
|
bg.add(sevenFiveButton); |
|
|
|
bg.add(fiveTenButton); |
|
|
|
bg.add(fiveTenButton); |
|
|
|
bg.add(twoFiveButton); |
|
|
|
bg.add(twoFiveButton); |
|
|
|
bg.add(selfAdaptButton); |
|
|
|
bg.add(selfAdaptButton); |
|
|
@ -224,7 +244,7 @@ public class JSliderPane extends JPanel { |
|
|
|
septPane.setBackground(BACK_COLOR); |
|
|
|
septPane.setBackground(BACK_COLOR); |
|
|
|
twoHundredButton.setBackground(BACK_COLOR); |
|
|
|
twoHundredButton.setBackground(BACK_COLOR); |
|
|
|
oneHundredButton.setBackground(BACK_COLOR); |
|
|
|
oneHundredButton.setBackground(BACK_COLOR); |
|
|
|
SevenFiveButton.setBackground(BACK_COLOR); |
|
|
|
sevenFiveButton.setBackground(BACK_COLOR); |
|
|
|
fiveTenButton.setBackground(BACK_COLOR); |
|
|
|
fiveTenButton.setBackground(BACK_COLOR); |
|
|
|
twoFiveButton.setBackground(BACK_COLOR); |
|
|
|
twoFiveButton.setBackground(BACK_COLOR); |
|
|
|
selfAdaptButton.setBackground(BACK_COLOR); |
|
|
|
selfAdaptButton.setBackground(BACK_COLOR); |
|
|
@ -234,7 +254,7 @@ public class JSliderPane extends JPanel { |
|
|
|
new Component[]{septPane, null}, |
|
|
|
new Component[]{septPane, null}, |
|
|
|
new Component[]{twoHundredButton, null}, |
|
|
|
new Component[]{twoHundredButton, null}, |
|
|
|
new Component[]{oneHundredButton, null}, |
|
|
|
new Component[]{oneHundredButton, null}, |
|
|
|
new Component[]{SevenFiveButton, null}, |
|
|
|
new Component[]{sevenFiveButton, null}, |
|
|
|
new Component[]{fiveTenButton, null}, |
|
|
|
new Component[]{fiveTenButton, null}, |
|
|
|
new Component[]{twoFiveButton, null}, |
|
|
|
new Component[]{twoFiveButton, null}, |
|
|
|
new Component[]{selfAdaptButton, null}, |
|
|
|
new Component[]{selfAdaptButton, null}, |
|
|
@ -255,14 +275,14 @@ public class JSliderPane extends JPanel { |
|
|
|
return spinnerPanel; |
|
|
|
return spinnerPanel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ActionListener showValButtonActionListener = new ActionListener() { |
|
|
|
private ActionListener showValButtonActionListener = new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
popupDialog(); |
|
|
|
popupDialog(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
ChangeListener showValSpinnerChangeListener = new ChangeListener() { |
|
|
|
private ChangeListener showValSpinnerChangeListener = new ChangeListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); |
|
|
|
int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); |
|
|
@ -285,7 +305,7 @@ public class JSliderPane extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//定义一个监听器,用于监听所有滑动条
|
|
|
|
//定义一个监听器,用于监听所有滑动条
|
|
|
|
ChangeListener listener = new ChangeListener() { |
|
|
|
private ChangeListener listener = new ChangeListener() { |
|
|
|
public void stateChanged(ChangeEvent event) { |
|
|
|
public void stateChanged(ChangeEvent event) { |
|
|
|
//取出滑动条的值,并在文本中显示出来
|
|
|
|
//取出滑动条的值,并在文本中显示出来
|
|
|
|
if (!isButtonOrIsTxt) { |
|
|
|
if (!isButtonOrIsTxt) { |
|
|
@ -305,7 +325,7 @@ public class JSliderPane extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
ItemListener radioButtonItemListener = new ItemListener() { |
|
|
|
private ItemListener radioButtonItemListener = new ItemListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
JRadioButton temp = (JRadioButton) e.getSource(); |
|
|
|
JRadioButton temp = (JRadioButton) e.getSource(); |
|
|
@ -321,7 +341,7 @@ public class JSliderPane extends JPanel { |
|
|
|
slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); |
|
|
|
slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); |
|
|
|
} else if (showValue < HUNDRED) { |
|
|
|
} else if (showValue < HUNDRED) { |
|
|
|
slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); |
|
|
|
slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); |
|
|
|
} else if (showValue == HUNDRED) { |
|
|
|
} else { |
|
|
|
slider.setValue(HALF_HUNDRED); |
|
|
|
slider.setValue(HALF_HUNDRED); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -349,7 +369,7 @@ public class JSliderPane extends JPanel { |
|
|
|
return b1.divide(b2, scale).doubleValue(); |
|
|
|
return b1.divide(b2, scale).doubleValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ActionListener buttonActionListener = new ActionListener() { |
|
|
|
private ActionListener buttonActionListener = new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
showValue = (int) showValSpinner.getValue(); |
|
|
|
showValue = (int) showValSpinner.getValue(); |
|
|
@ -386,7 +406,7 @@ public class JSliderPane extends JPanel { |
|
|
|
} else if (value < HALF_HUNDRED) { |
|
|
|
} else if (value < HALF_HUNDRED) { |
|
|
|
times = (int) Math.round(ONEPOINTEIGHT * value + TEN); |
|
|
|
times = (int) Math.round(ONEPOINTEIGHT * value + TEN); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
times = (int) (SIX * value - TWO_HUNDRED); |
|
|
|
times = SIX * value - TWO_HUNDRED; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -444,11 +464,9 @@ class JSliderPaneUI extends BasicSliderUI { |
|
|
|
super(b); |
|
|
|
super(b); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** */ |
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 绘制指示物 |
|
|
|
* 绘制指示物 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
public void paintThumb(Graphics g) { |
|
|
|
public void paintThumb(Graphics g) { |
|
|
|
Rectangle knobBounds = thumbRect; |
|
|
|
Rectangle knobBounds = thumbRect; |
|
|
|
int w = knobBounds.width; |
|
|
|
int w = knobBounds.width; |
|
|
@ -460,7 +478,6 @@ class JSliderPaneUI extends BasicSliderUI { |
|
|
|
g2d.fillRoundRect(0, SIX, FOUR, 9, 2, 2); |
|
|
|
g2d.fillRoundRect(0, SIX, FOUR, 9, 2, 2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** */ |
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 绘制刻度轨迹 |
|
|
|
* 绘制刻度轨迹 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|