@ -14,13 +14,33 @@ 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.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.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.Point ;
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 ;
/ * *
/ * *
@ -51,7 +71,6 @@ public class JFormSliderPane 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 JFormSliderPane THIS ;
private UITextField showVal ;
private UITextField showVal ;
private JSpinner showValSpinner ;
private JSpinner showValSpinner ;
private UISlider slider ;
private UISlider slider ;
@ -62,7 +81,7 @@ public class JFormSliderPane extends JPanel {
private UISliderButton showValButton ;
private UISliderButton showValButton ;
private UIRadioButton twoHundredButton ;
private UIRadioButton twoHundredButton ;
private UIRadioButton oneHundredButton ;
private UIRadioButton oneHundredButton ;
private UIRadioButton S evenFiveButton;
private UIRadioButton s evenFiveButton;
private UIRadioButton fiveTenButton ;
private UIRadioButton fiveTenButton ;
private UIRadioButton twoFiveButton ;
private UIRadioButton twoFiveButton ;
private UIRadioButton selfAdaptButton ;
private UIRadioButton selfAdaptButton ;
@ -83,7 +102,7 @@ public class JFormSliderPane extends JPanel {
showValSpinner . setEditor ( editor ) ;
showValSpinner . setEditor ( editor ) ;
JFormattedTextField textField = ( ( JSpinner . NumberEditor ) showValSpinner . getEditor ( ) ) . getTextField ( ) ;
JFormattedTextField textField = ( ( JSpinner . NumberEditor ) showValSpinner . getEditor ( ) ) . getTextField ( ) ;
textField . setEditable ( true ) ;
textField . setEditable ( true ) ;
DefaultFormatterFactory factory = ( DefaultFormatterFactory ) textField . getFormatterFactory ( ) ;
DefaultFormatterFactory factory = ( DefaultFormatterFactory ) textField . getFormatterFactory ( ) ;
NumberFormatter formatter = ( NumberFormatter ) factory . getDefaultFormatter ( ) ;
NumberFormatter formatter = ( NumberFormatter ) factory . getDefaultFormatter ( ) ;
formatter . setAllowsInvalid ( false ) ;
formatter . setAllowsInvalid ( false ) ;
@ -91,7 +110,7 @@ public class JFormSliderPane 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 ) ;
@ -100,17 +119,13 @@ public class JFormSliderPane extends JPanel {
this . add ( panel , BorderLayout . NORTH ) ;
this . add ( panel , BorderLayout . NORTH ) ;
}
}
public static final JFormSliderPane getInstance ( ) {
public static JFormSliderPane getInstance ( ) {
// if (THIS == null) {
return new JFormSliderPane ( ) ;
// THIS = new JSliderPane();
// }
THIS = new JFormSliderPane ( ) ;
return THIS ;
}
}
private void initSlider ( ) {
private void initSlider ( ) {
slider = new UISlider ( 0 , HUNDRED , HALF_HUNDRED ) {
slider = new UISlider ( 0 , HUNDRED , HALF_HUNDRED ) {
public Point getToolTipLocation ( MouseEvent event ) {
public Point getToolTipLocation ( MouseEvent event ) {
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
}
}
} ;
} ;
@ -123,8 +138,8 @@ public class JFormSliderPane extends JPanel {
}
}
private void initShowValSpinner ( ) {
private void initShowValSpinner ( ) {
showValSpinner = new UIBasicSpinner ( new SpinnerNumberModel ( HUNDRED , 0 , FOUR_HUNDRED , 1 ) ) {
showValSpinner = new UIBasicSpinner ( new SpinnerNumberModel ( HUNDRED , 0 , FOUR_HUNDRED , 1 ) ) {
public Point getToolTipLocation ( MouseEvent event ) {
public Point getToolTipLocation ( MouseEvent event ) {
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
}
}
} ;
} ;
@ -134,16 +149,16 @@ public class JFormSliderPane extends JPanel {
}
}
private void initDownUpButton ( ) {
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" ) ) {
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 ) {
public Point getToolTipLocation ( MouseEvent event ) {
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
}
}
} ;
} ;
downButton . setOpaque ( false ) ;
downButton . setOpaque ( false ) ;
downButton . setBorderPainted ( false ) ;
downButton . setBorderPainted ( false ) ;
downButton . setToolTipText ( Inter . getLocText ( "FR-Designer_Scale_Down" ) ) ;
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 ) {
public Point getToolTipLocation ( MouseEvent event ) {
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
return new Point ( event . getX ( ) , event . getY ( ) - TOOLTIP_Y ) ;
}
}
} ;
} ;
@ -164,10 +179,11 @@ public class JFormSliderPane extends JPanel {
showValButton . addActionListener ( showValButtonActionListener ) ;
showValButton . addActionListener ( showValButtonActionListener ) ;
showValButton . setToolTipText ( Inter . getLocText ( "FR-Designer_Scale_Grade" ) ) ;
showValButton . setToolTipText ( Inter . getLocText ( "FR-Designer_Scale_Grade" ) ) ;
}
}
private void initUIRadioButton ( ) {
private void initUIRadioButton ( ) {
twoHundredButton = new UIRadioButton ( "200%" ) ;
twoHundredButton = new UIRadioButton ( "200%" ) ;
oneHundredButton = new UIRadioButton ( "100%" ) ;
oneHundredButton = new UIRadioButton ( "100%" ) ;
S evenFiveButton = new UIRadioButton ( "75%" ) ;
s evenFiveButton = 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" ) ) ;
@ -176,7 +192,7 @@ public class JFormSliderPane 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 ) ;
S evenFiveButton. addItemListener ( radioButtonItemListener ) ;
s evenFiveButton. addItemListener ( radioButtonItemListener ) ;
fiveTenButton . addItemListener ( radioButtonItemListener ) ;
fiveTenButton . addItemListener ( radioButtonItemListener ) ;
twoFiveButton . addItemListener ( radioButtonItemListener ) ;
twoFiveButton . addItemListener ( radioButtonItemListener ) ;
customButton . addItemListener ( new ItemListener ( ) {
customButton . addItemListener ( new ItemListener ( ) {
@ -194,7 +210,7 @@ public class JFormSliderPane extends JPanel {
ButtonGroup bg = new ButtonGroup ( ) ; // 初始化按钮组
ButtonGroup bg = new ButtonGroup ( ) ; // 初始化按钮组
bg . add ( twoHundredButton ) ; // 加入按钮组
bg . add ( twoHundredButton ) ; // 加入按钮组
bg . add ( oneHundredButton ) ;
bg . add ( oneHundredButton ) ;
bg . add ( S evenFiveButton) ;
bg . add ( s evenFiveButton) ;
bg . add ( fiveTenButton ) ;
bg . add ( fiveTenButton ) ;
bg . add ( twoFiveButton ) ;
bg . add ( twoFiveButton ) ;
bg . add ( selfAdaptButton ) ;
bg . add ( selfAdaptButton ) ;
@ -217,7 +233,7 @@ public class JFormSliderPane 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 ) ;
S evenFiveButton. setBackground ( BACK_COLOR ) ;
s evenFiveButton. 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);
@ -227,7 +243,7 @@ public class JFormSliderPane 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 [ ] { S evenFiveButton, null } ,
new Component [ ] { s evenFiveButton, null } ,
new Component [ ] { fiveTenButton , null } ,
new Component [ ] { fiveTenButton , null } ,
new Component [ ] { twoFiveButton , null } ,
new Component [ ] { twoFiveButton , null } ,
new Component [ ] { customButton , createSpinnerPanel ( ) }
new Component [ ] { customButton , createSpinnerPanel ( ) }
@ -247,14 +263,14 @@ public class JFormSliderPane 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 ( ) ;
@ -277,7 +293,7 @@ public class JFormSliderPane 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 ) {
@ -296,7 +312,7 @@ public class JFormSliderPane 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 ( ) ;
@ -312,7 +328,7 @@ public class JFormSliderPane 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 ) ;
}
}
}
}
@ -336,7 +352,7 @@ public class JFormSliderPane 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 ( ) ;