Package edu.cnu.mdi.graphics
Class SliderFactory
java.lang.Object
edu.cnu.mdi.graphics.SliderFactory
-
Method Summary
Modifier and TypeMethodDescriptionstatic JSlidercreateLabeledSlider(Container parent, float min, float max, float initial, float majorTick, float minorTick, Font font, boolean showValue, int numDec) Creates a self-contained panel containing a slider and an optional value label.static JSlidercreateLabeledSlider(Container parent, int min, int max, int initial, int majorTick, int minorTick, Font font, boolean showValue) Creates a self-contained panel containing a slider and an optional value label.
-
Method Details
-
createLabeledSlider
public static JSlider createLabeledSlider(Container parent, int min, int max, int initial, int majorTick, int minorTick, Font font, boolean showValue) Creates a self-contained panel containing a slider and an optional value label. This avoids hardcoding sizes and preserves the parent's layout.- Parameters:
parent- The container to which the slider panel will be added.min- The minimum value of the slider.max- The maximum value of the slider.initial- The initial value of the slider.majorTick- The major tick spacing for the slider.minorTick- The minor tick spacing for the slider, or 0 for none.font- The font to use for the slider and label.- Throws:
NullPointerException- ifparentisnullIllegalArgumentException- ifmin >= max, ifinitialis outside[min, max], ifmajorTick <= 0, or ifminorTick < 0
-
createLabeledSlider
public static JSlider createLabeledSlider(Container parent, float min, float max, float initial, float majorTick, float minorTick, Font font, boolean showValue, int numDec) Creates a self-contained panel containing a slider and an optional value label. This avoids hardcoding sizes and preserves the parent's layout. This method is for float values.- Parameters:
parent- The container to which the slider panel will be added.min- The minimum value of the slider.max- The maximum value of the slider.initial- The initial value of the slider.majorTick- The major tick spacing for the slider.minorTick- The minor tick spacing for the slider, or 0 for none.font- The font to use for the slider and label.numDec- The number of decimal places to display.- Throws:
NullPointerException- ifparentisnullIllegalArgumentException- if any ofmin,max,initial,majorTick, orminorTickis not finite; ifmin >= max,initialis outside[min, max],majorTick <= 0, orminorTick < 0; ifnumDecis outside[0, 6]; or ifnumDecis high enough relative to the range that scaling to an integer-backedJSliderwould collapse the range or tick spacing to zero
-