28 import javax.swing.plaf.basic.BasicSliderUI;
29
30 import java.awt.Graphics;
31 import java.awt.Dimension;
32 import java.awt.Rectangle;
33 import java.awt.Color;
34 import java.beans.*;
35
36 import javax.swing.*;
37 import javax.swing.plaf.*;
38
39 /**
40 * A Java L&F implementation of SliderUI.
41 * <p>
42 * <strong>Warning:</strong>
43 * Serialized objects of this class will not be compatible with
44 * future Swing releases. The current serialization support is
45 * appropriate for short term storage or RMI between applications running
46 * the same version of Swing. As of 1.4, support for long term storage
47 * of all JavaBeans™
48 * has been added to the <code>java.beans</code> package.
49 * Please see {@link java.beans.XMLEncoder}.
50 *
51 * @author Tom Santos
52 */
53 @SuppressWarnings("serial") // Same-version serialization only
54 public class MetalSliderUI extends BasicSliderUI {
55
56 /**
57 * The buffer of a tick.
58 */
59 protected final int TICK_BUFFER = 4;
60
61 /**
62 * The value of the property {@code JSlider.isFilled}.
63 * By default, {@code false} if the property is not set,
64 * {@code true} for Ocean theme.
65 */
66 protected boolean filledSlider = false;
67
68 // NOTE: these next five variables are currently unused.
76 */
77 protected static Color highlightColor;
78
79 /**
80 * The color of dark shadow.
81 */
82 protected static Color darkShadowColor;
83
84 /**
85 * The width of a track.
86 */
87 protected static int trackWidth;
88
89 /**
90 * The length of a tick.
91 */
92 protected static int tickLength;
93 private int safeLength;
94
95 /**
96 * A default horizontal thumb <code>Icon</code>. This field might not be
97 * used. To change the <code>Icon</code> used by this delegate directly set it
98 * using the <code>Slider.horizontalThumbIcon</code> UIManager property.
99 */
100 protected static Icon horizThumbIcon;
101
102 /**
103 * A default vertical thumb <code>Icon</code>. This field might not be
104 * used. To change the <code>Icon</code> used by this delegate directly set it
105 * using the <code>Slider.verticalThumbIcon</code> UIManager property.
106 */
107 protected static Icon vertThumbIcon;
108
109 private static Icon SAFE_HORIZ_THUMB_ICON;
110 private static Icon SAFE_VERT_THUMB_ICON;
111
112 /**
113 * Property for {@code JSlider.isFilled}.
114 */
115 protected final String SLIDER_FILL = "JSlider.isFilled";
116
117 /**
118 * Constructs a {@code MetalSliderUI} instance.
119 *
120 * @param c a component
121 * @return a {@code MetalSliderUI} instance
122 */
123 public static ComponentUI createUI(JComponent c) {
124 return new MetalSliderUI();
125 }
|
28 import javax.swing.plaf.basic.BasicSliderUI;
29
30 import java.awt.Graphics;
31 import java.awt.Dimension;
32 import java.awt.Rectangle;
33 import java.awt.Color;
34 import java.beans.*;
35
36 import javax.swing.*;
37 import javax.swing.plaf.*;
38
39 /**
40 * A Java L&F implementation of SliderUI.
41 * <p>
42 * <strong>Warning:</strong>
43 * Serialized objects of this class will not be compatible with
44 * future Swing releases. The current serialization support is
45 * appropriate for short term storage or RMI between applications running
46 * the same version of Swing. As of 1.4, support for long term storage
47 * of all JavaBeans™
48 * has been added to the {@code java.beans} package.
49 * Please see {@link java.beans.XMLEncoder}.
50 *
51 * @author Tom Santos
52 */
53 @SuppressWarnings("serial") // Same-version serialization only
54 public class MetalSliderUI extends BasicSliderUI {
55
56 /**
57 * The buffer of a tick.
58 */
59 protected final int TICK_BUFFER = 4;
60
61 /**
62 * The value of the property {@code JSlider.isFilled}.
63 * By default, {@code false} if the property is not set,
64 * {@code true} for Ocean theme.
65 */
66 protected boolean filledSlider = false;
67
68 // NOTE: these next five variables are currently unused.
76 */
77 protected static Color highlightColor;
78
79 /**
80 * The color of dark shadow.
81 */
82 protected static Color darkShadowColor;
83
84 /**
85 * The width of a track.
86 */
87 protected static int trackWidth;
88
89 /**
90 * The length of a tick.
91 */
92 protected static int tickLength;
93 private int safeLength;
94
95 /**
96 * A default horizontal thumb {@code Icon}. This field might not be
97 * used. To change the {@code Icon} used by this delegate directly set it
98 * using the {@code Slider.horizontalThumbIcon} UIManager property.
99 */
100 protected static Icon horizThumbIcon;
101
102 /**
103 * A default vertical thumb {@code Icon}. This field might not be
104 * used. To change the {@code Icon} used by this delegate directly set it
105 * using the {@code Slider.verticalThumbIcon} UIManager property.
106 */
107 protected static Icon vertThumbIcon;
108
109 private static Icon SAFE_HORIZ_THUMB_ICON;
110 private static Icon SAFE_VERT_THUMB_ICON;
111
112 /**
113 * Property for {@code JSlider.isFilled}.
114 */
115 protected final String SLIDER_FILL = "JSlider.isFilled";
116
117 /**
118 * Constructs a {@code MetalSliderUI} instance.
119 *
120 * @param c a component
121 * @return a {@code MetalSliderUI} instance
122 */
123 public static ComponentUI createUI(JComponent c) {
124 return new MetalSliderUI();
125 }
|