1:
37:
38:
39: package ;
40:
41: import ;
42:
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64:
65: import ;
66: import ;
67: import ;
68: import ;
69: import ;
70: import ;
71: import ;
72: import ;
73: import ;
74: import ;
75: import ;
76: import ;
77: import ;
78: import ;
79: import ;
80: import ;
81: import ;
82:
83:
143: public class BasicSliderUI extends SliderUI
144: {
145:
152: public class ChangeHandler implements ChangeListener
153: {
154:
161: public void stateChanged(ChangeEvent e)
162: {
163:
164:
165:
166: calculateThumbLocation();
167: slider.repaint();
168: }
169: }
170:
171:
178: public class ComponentHandler extends ComponentAdapter
179: {
180:
187: public void componentResized(ComponentEvent e)
188: {
189: calculateGeometry();
190:
191: slider.revalidate();
192: slider.repaint();
193: }
194: }
195:
196:
203: public class FocusHandler implements FocusListener
204: {
205:
211: public void focusGained(FocusEvent e)
212: throws NotImplementedException
213: {
214:
215: }
216:
217:
223: public void focusLost(FocusEvent e)
224: throws NotImplementedException
225: {
226:
227: }
228: }
229:
230:
234: public class PropertyChangeHandler implements PropertyChangeListener
235: {
236:
242: public void propertyChange(PropertyChangeEvent e)
243: {
244:
245: if (e.getPropertyName().equals("orientation"))
246: recalculateIfOrientationChanged();
247: else if (e.getPropertyName().equals("model"))
248: {
249: BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue();
250: oldModel.removeChangeListener(changeListener);
251: slider.getModel().addChangeListener(changeListener);
252: calculateThumbLocation();
253: }
254: else if (e.getPropertyName().equals("paintTicks"))
255: calculateGeometry();
256:
257:
258:
259:
260:
261:
262:
263: slider.repaint();
264: }
265: }
266:
267:
276: public class ScrollListener implements ActionListener
277: {
278:
279: private transient int direction;
280:
281:
282: private transient boolean block;
283:
284:
287: public ScrollListener()
288: {
289: direction = POSITIVE_SCROLL;
290: block = false;
291: }
292:
293:
299: public ScrollListener(int dir, boolean block)
300: {
301: direction = dir;
302: this.block = block;
303: }
304:
305:
312: public void actionPerformed(ActionEvent e)
313: {
314: if (! trackListener.shouldScroll(direction))
315: {
316: scrollTimer.stop();
317: return;
318: }
319:
320: if (block)
321: scrollByBlock(direction);
322: else
323: scrollByUnit(direction);
324: }
325:
326:
331: public void setDirection(int direction)
332: {
333: this.direction = direction;
334: }
335:
336:
341: public void setScrollByBlock(boolean block)
342: {
343: this.block = block;
344: }
345: }
346:
347:
354: public class TrackListener extends MouseInputAdapter
355: {
356:
357: protected int currentMouseX;
358:
359:
360: protected int currentMouseY;
361:
362:
365: protected int offset;
366:
367:
374: public void mouseDragged(MouseEvent e)
375: {
376: if (slider.isEnabled())
377: {
378: currentMouseX = e.getX();
379: currentMouseY = e.getY();
380: if (slider.getValueIsAdjusting())
381: {
382: int value;
383: if (slider.getOrientation() == JSlider.HORIZONTAL)
384: value = valueForXPosition(currentMouseX) - offset;
385: else
386: value = valueForYPosition(currentMouseY) - offset;
387:
388: slider.setValue(value);
389: }
390: }
391: }
392:
393:
399: public void mouseMoved(MouseEvent e)
400: {
401:
402: }
403:
404:
412: public void mousePressed(MouseEvent e)
413: {
414: if (slider.isEnabled())
415: {
416: currentMouseX = e.getX();
417: currentMouseY = e.getY();
418:
419: int value;
420: if (slider.getOrientation() == JSlider.HORIZONTAL)
421: value = valueForXPosition(currentMouseX);
422: else
423: value = valueForYPosition(currentMouseY);
424:
425: if (slider.getSnapToTicks())
426: value = findClosestTick(value);
427:
428:
429:
430: if (! thumbRect.contains(e.getPoint()))
431: {
432:
433:
434: if (value > slider.getValue())
435: scrollDueToClickInTrack(POSITIVE_SCROLL);
436: else
437: scrollDueToClickInTrack(NEGATIVE_SCROLL);
438: }
439: else
440: {
441: slider.setValueIsAdjusting(true);
442: offset = value - slider.getValue();
443: }
444: }
445: }
446:
447:
453: public void mouseReleased(MouseEvent e)
454: {
455: if (slider.isEnabled())
456: {
457: currentMouseX = e.getX();
458: currentMouseY = e.getY();
459:
460: if (slider.getValueIsAdjusting())
461: {
462: slider.setValueIsAdjusting(false);
463: if (slider.getSnapToTicks())
464: slider.setValue(findClosestTick(slider.getValue()));
465: }
466: if (scrollTimer != null)
467: scrollTimer.stop();
468: }
469: }
470:
471:
478: public boolean shouldScroll(int direction)
479: {
480: int value;
481: if (slider.getOrientation() == JSlider.HORIZONTAL)
482: value = valueForXPosition(currentMouseX);
483: else
484: value = valueForYPosition(currentMouseY);
485:
486: if (direction == POSITIVE_SCROLL)
487: return (value > slider.getValue());
488: else
489: return (value < slider.getValue());
490: }
491: }
492:
493:
496: public class ActionScroller extends AbstractAction
497: {
498:
505: public ActionScroller(JSlider slider, int dir, boolean block)
506: {
507:
508: }
509:
510:
515: public void actionPerformed(ActionEvent event)
516: {
517:
518: }
519: }
520:
521:
522: protected ChangeListener changeListener;
523:
524:
525: protected PropertyChangeListener propertyChangeListener;
526:
527:
528: protected ScrollListener scrollListener;
529:
530:
531: protected ComponentListener componentListener;
532:
533:
534: protected FocusListener focusListener;
535:
536:
537: protected TrackListener trackListener;
538:
539:
540: protected Insets focusInsets;
541:
542:
543: protected Insets insetCache;
544:
545:
546: protected Rectangle contentRect;
547:
548:
549: protected Rectangle focusRect;
550:
551:
552: protected Rectangle thumbRect;
553:
554:
555: protected Rectangle tickRect;
556:
557:
558: protected Rectangle labelRect;
559:
560:
561: protected Rectangle trackRect;
562:
563:
564: public static final int MAX_SCROLL = 2;
565:
566:
567: public static final int MIN_SCROLL = -2;
568:
569:
570: public static final int NEGATIVE_SCROLL = -1;
571:
572:
573: public static final int POSITIVE_SCROLL = 1;
574:
575:
576: protected int trackBuffer;
577:
578:
579: protected boolean leftToRightCache;
580:
581:
582: protected Timer scrollTimer;
583:
584:
585: protected JSlider slider;
586:
587:
588: private transient Color shadowColor;
589:
590:
591: private transient Color highlightColor;
592:
593:
594: private transient Color focusColor;
595:
596:
601: public BasicSliderUI(JSlider b)
602: {
603: super();
604: }
605:
606:
612: protected Color getShadowColor()
613: {
614: return shadowColor;
615: }
616:
617:
623: protected Color getHighlightColor()
624: {
625: return highlightColor;
626: }
627:
628:
635: protected Color getFocusColor()
636: {
637: return focusColor;
638: }
639:
640:
648: public static ComponentUI createUI(JComponent b)
649: {
650: return new BasicSliderUI((JSlider) b);
651: }
652:
653:
660: public void installUI(JComponent c)
661: {
662: super.installUI(c);
663: if (c instanceof JSlider)
664: {
665: slider = (JSlider) c;
666:
667: focusRect = new Rectangle();
668: contentRect = new Rectangle();
669: thumbRect = new Rectangle();
670: trackRect = new Rectangle();
671: tickRect = new Rectangle();
672: labelRect = new Rectangle();
673:
674: insetCache = slider.getInsets();
675: leftToRightCache = ! slider.getInverted();
676:
677: scrollTimer = new Timer(200, null);
678: scrollTimer.setRepeats(true);
679:
680: installDefaults(slider);
681: installListeners(slider);
682: installKeyboardActions(slider);
683:
684: calculateFocusRect();
685:
686: calculateContentRect();
687: calculateThumbSize();
688: calculateTrackBuffer();
689: calculateTrackRect();
690: calculateThumbLocation();
691:
692: calculateTickRect();
693: calculateLabelRect();
694: }
695: }
696:
697:
704: public void uninstallUI(JComponent c)
705: {
706: super.uninstallUI(c);
707:
708: uninstallKeyboardActions(slider);
709: uninstallListeners(slider);
710:
711: scrollTimer = null;
712:
713: focusRect = null;
714: contentRect = null;
715: thumbRect = null;
716: trackRect = null;
717: tickRect = null;
718: labelRect = null;
719:
720: focusInsets = null;
721: }
722:
723:
729: protected void installDefaults(JSlider slider)
730: {
731: LookAndFeel.installColors(slider, "Slider.background",
732: "Slider.foreground");
733: LookAndFeel.installBorder(slider, "Slider.border");
734: shadowColor = UIManager.getColor("Slider.shadow");
735: highlightColor = UIManager.getColor("Slider.highlight");
736: focusColor = UIManager.getColor("Slider.focus");
737: focusInsets = UIManager.getInsets("Slider.focusInsets");
738: slider.setOpaque(true);
739: }
740:
741:
749: protected TrackListener createTrackListener(JSlider slider)
750: {
751: return new TrackListener();
752: }
753:
754:
762: protected ChangeListener createChangeListener(JSlider slider)
763: {
764: return new ChangeHandler();
765: }
766:
767:
775: protected ComponentListener createComponentListener(JSlider slider)
776: {
777: return new ComponentHandler();
778: }
779:
780:
788: protected FocusListener createFocusListener(JSlider slider)
789: {
790: return new FocusHandler();
791: }
792:
793:
801: protected ScrollListener createScrollListener(JSlider slider)
802: {
803: return new ScrollListener();
804: }
805:
806:
814: protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
815: {
816: return new PropertyChangeHandler();
817: }
818:
819:
825: protected void installListeners(JSlider slider)
826: {
827: propertyChangeListener = createPropertyChangeListener(slider);
828: componentListener = createComponentListener(slider);
829: trackListener = createTrackListener(slider);
830: focusListener = createFocusListener(slider);
831: changeListener = createChangeListener(slider);
832: scrollListener = createScrollListener(slider);
833:
834: slider.addPropertyChangeListener(propertyChangeListener);
835: slider.addComponentListener(componentListener);
836: slider.addMouseListener(trackListener);
837: slider.addMouseMotionListener(trackListener);
838: slider.addFocusListener(focusListener);
839: slider.getModel().addChangeListener(changeListener);
840:
841: scrollTimer.addActionListener(scrollListener);
842: }
843:
844:
850: protected void uninstallListeners(JSlider slider)
851: {
852: slider.removePropertyChangeListener(propertyChangeListener);
853: slider.removeComponentListener(componentListener);
854: slider.removeMouseListener(trackListener);
855: slider.removeMouseMotionListener(trackListener);
856: slider.removeFocusListener(focusListener);
857: slider.getModel().removeChangeListener(changeListener);
858:
859: scrollTimer.removeActionListener(scrollListener);
860:
861: propertyChangeListener = null;
862: componentListener = null;
863: trackListener = null;
864: focusListener = null;
865: changeListener = null;
866: scrollListener = null;
867: }
868:
869:
876: protected void installKeyboardActions(JSlider slider)
877: {
878: InputMap keyMap = getInputMap(JComponent.WHEN_FOCUSED);
879: SwingUtilities.replaceUIInputMap(slider, JComponent.WHEN_FOCUSED, keyMap);
880: ActionMap map = getActionMap();
881: SwingUtilities.replaceUIActionMap(slider, map);
882: }
883:
884:
891: protected void uninstallKeyboardActions(JSlider slider)
892: {
893: SwingUtilities.replaceUIActionMap(slider, null);
894: SwingUtilities.replaceUIInputMap(slider, JComponent.WHEN_FOCUSED, null);
895: }
896:
897:
911:
912:
918: public Dimension getPreferredHorizontalSize()
919: {
920: Insets insets = slider.getInsets();
921:
922:
923:
924: int width = getWidthOfWidestLabel() * (slider.getLabelTable() == null ? 0
925: : slider.getLabelTable().size());
926:
927:
928:
929: if (width < 200)
930: width = 200;
931:
932:
933:
934: width += insets.left + insets.right + focusInsets.left + focusInsets.right;
935:
936:
937: int height = getThumbSize().height;
938:
939: if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
940: || slider.getMinorTickSpacing() > 0)
941: height += getTickLength();
942:
943: if (slider.getPaintLabels())
944: height += getHeightOfTallestLabel();
945:
946: height += insets.top + insets.bottom + focusInsets.top
947: + focusInsets.bottom;
948:
949: return new Dimension(width, height);
950: }
951:
952:
958: public Dimension getPreferredVerticalSize()
959: {
960: Insets insets = slider.getInsets();
961:
962: int height = getHeightOfTallestLabel() * (slider.getLabelTable() == null
963: ? 0 : slider.getLabelTable()
964: .size());
965:
966: if (height < 200)
967: height = 200;
968:
969: height += insets.top + insets.bottom + focusInsets.top
970: + focusInsets.bottom;
971:
972: int width = getThumbSize().width;
973:
974: if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
975: || slider.getMinorTickSpacing() > 0)
976: width += getTickLength();
977:
978: if (slider.getPaintLabels())
979: width += getWidthOfWidestLabel();
980:
981: width += insets.left + insets.right + focusInsets.left + focusInsets.right;
982:
983: return new Dimension(width, height);
984: }
985:
986:
992: public Dimension getMinimumHorizontalSize()
993: {
994: Insets insets = slider.getInsets();
995:
996: int height = getThumbSize().height;
997:
998: if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
999: || slider.getMinorTickSpacing() > 0)
1000: height += getTickLength();
1001:
1002: if (slider.getPaintLabels())
1003: height += getHeightOfTallestLabel();
1004:
1005: height += insets.top + insets.bottom + focusInsets.top
1006: + focusInsets.bottom;
1007:
1008: return new Dimension(36, height);
1009: }
1010:
1011:
1017: public Dimension getMinimumVerticalSize()
1018: {
1019: Insets insets = slider.getInsets();
1020: int width = getThumbSize().width;
1021:
1022: if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
1023: || slider.getMinorTickSpacing() > 0)
1024: width += getTickLength();
1025:
1026: if (slider.getPaintLabels())
1027: width += getWidthOfWidestLabel();
1028:
1029: width += insets.left + insets.right + focusInsets.left + focusInsets.right;
1030:
1031: return new Dimension(width, 36);
1032: }
1033:
1034:
1043: public Dimension getPreferredSize(JComponent c)
1044: {
1045: if (slider.getOrientation() == JSlider.HORIZONTAL)
1046: return getPreferredHorizontalSize();
1047: else
1048: return getPreferredVerticalSize();
1049: }
1050:
1051:
1060: public Dimension getMinimumSize(JComponent c)
1061: {
1062: if (slider.getOrientation() == JSlider.HORIZONTAL)
1063: return getMinimumHorizontalSize();
1064: else
1065: return getMinimumVerticalSize();
1066: }
1067:
1068:
1076: public Dimension getMaximumSize(JComponent c)
1077: {
1078: Insets insets = slider.getInsets();
1079: if (slider.getOrientation() == JSlider.HORIZONTAL)
1080: {
1081:
1082: int height = getThumbSize().height;
1083:
1084: if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
1085: || slider.getMinorTickSpacing() > 0)
1086: height += getTickLength();
1087:
1088: if (slider.getPaintLabels())
1089: height += getHeightOfTallestLabel();
1090:
1091: height += insets.top + insets.bottom + focusInsets.top
1092: + focusInsets.bottom;
1093:
1094: return new Dimension(32767, height);
1095: }
1096: else
1097: {
1098: int width = getThumbSize().width;
1099:
1100: if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
1101: || slider.getMinorTickSpacing() > 0)
1102: width += getTickLength();
1103:
1104: if (slider.getPaintLabels())
1105: width += getWidthOfWidestLabel();
1106:
1107: width += insets.left + insets.right + focusInsets.left
1108: + focusInsets.right;
1109:
1110: return new Dimension(width, 32767);
1111: }
1112: }
1113:
1114:
1118: protected void calculateGeometry()
1119: {
1120: calculateFocusRect();
1121: calculateContentRect();
1122: calculateThumbSize();
1123: calculateTrackBuffer();
1124: calculateTrackRect();
1125: calculateTickRect();
1126: calculateLabelRect();
1127: calculateThumbLocation();
1128: }
1129:
1130:
1134: protected void calculateFocusRect()
1135: {
1136: insetCache = slider.getInsets();
1137: focusRect = SwingUtilities.calculateInnerArea(slider, focusRect);
1138: if (focusRect.width < 0)
1139: focusRect.width = 0;
1140: if (focusRect.height < 0)
1141: focusRect.height = 0;
1142: }
1143:
1144:
1148: protected void calculateThumbSize()
1149: {
1150: Dimension d = getThumbSize();
1151: thumbRect.width = d.width;
1152: thumbRect.height = d.height;
1153: if (slider.getOrientation() == JSlider.HORIZONTAL)
1154: thumbRect.y = trackRect.y;
1155: else
1156: thumbRect.x = trackRect.x;
1157: }
1158:
1159:
1164: protected void calculateContentRect()
1165: {
1166: contentRect.x = focusRect.x + focusInsets.left;
1167: contentRect.y = focusRect.y + focusInsets.top;
1168:
1169: contentRect.width = focusRect.width - focusInsets.left - focusInsets.right;
1170: contentRect.height = focusRect.height - focusInsets.top
1171: - focusInsets.bottom;
1172:
1173: if (contentRect.width < 0)
1174: contentRect.width = 0;
1175: if (contentRect.height < 0)
1176: contentRect.height = 0;
1177: }
1178:
1179:
1183: protected void calculateThumbLocation()
1184: {
1185: int value = slider.getValue();
1186:
1187: if (slider.getOrientation() == JSlider.HORIZONTAL)
1188: {
1189: thumbRect.x = xPositionForValue(value) - thumbRect.width / 2;
1190: thumbRect.y = trackRect.y;
1191: }
1192: else
1193: {
1194: thumbRect.x = trackRect.x;
1195: thumbRect.y = yPositionForValue(value) - thumbRect.height / 2;
1196: }
1197: }
1198:
1199:
1205: protected void calculateTrackBuffer()
1206: {
1207: if (slider.getOrientation() == JSlider.HORIZONTAL)
1208: {
1209: int w = Math.max(getWidthOfLowValueLabel(), getWidthOfHighValueLabel());
1210: trackBuffer = Math.max(thumbRect.width / 2, w / 2);
1211:
1212: }
1213: else
1214: {
1215: int h = Math.max(getHeightOfLowValueLabel(),
1216: getHeightOfHighValueLabel());
1217: trackBuffer = Math.max(thumbRect.height / 2, h / 2);
1218: }
1219: }
1220:
1221:
1231: protected Dimension getThumbSize()
1232: {
1233: if (slider.getOrientation() == JSlider.HORIZONTAL)
1234: return new Dimension(11, 20);
1235: else
1236: return new Dimension(20, 11);
1237: }
1238:
1239:
1243: protected void calculateTrackRect()
1244: {
1245: if (slider.getOrientation() == JSlider.HORIZONTAL)
1246: {
1247: trackRect.x = contentRect.x + trackBuffer;
1248: int h = getThumbSize().height;
1249: if (slider.getPaintTicks() && (slider.getMajorTickSpacing() > 0
1250: || slider.getMinorTickSpacing() > 0))
1251: h += getTickLength();
1252: if (slider.getPaintLabels())
1253: h += getHeightOfTallestLabel();
1254: trackRect.y = contentRect.y + (contentRect.height - h) / 2 - 1;
1255: trackRect.width = contentRect.width - 2 * trackBuffer;
1256: trackRect.height = thumbRect.height;
1257: }
1258: else
1259: {
1260: int w = getThumbSize().width;
1261: if (slider.getPaintTicks() && (slider.getMajorTickSpacing() > 0
1262: || slider.getMinorTickSpacing() > 0))
1263: w += getTickLength();
1264: if (slider.getPaintLabels())
1265: w += getWidthOfWidestLabel();
1266: trackRect.x = contentRect.x + (contentRect.width - w) / 2 - 1;
1267: trackRect.y = contentRect.y + trackBuffer;
1268: trackRect.width = thumbRect.width;
1269: trackRect.height = contentRect.height - 2 * trackBuffer;
1270: }
1271: }
1272:
1273:
1283: protected int getTickLength()
1284: {
1285: return 8;
1286: }
1287:
1288:
1292: protected void calculateTickRect()
1293: {
1294: if (slider.getOrientation() == JSlider.HORIZONTAL)
1295: {
1296: tickRect.x = trackRect.x;
1297: tickRect.y = trackRect.y + trackRect.height;
1298: tickRect.width = trackRect.width;
1299: tickRect.height = (slider.getPaintTicks() ? getTickLength() : 0);
1300:
1301: if (tickRect.y + tickRect.height > contentRect.y + contentRect.height)
1302: tickRect.height = contentRect.y + contentRect.height - tickRect.y;
1303: }
1304: else
1305: {
1306: tickRect.x = trackRect.x + trackRect.width;
1307: tickRect.y = trackRect.y;
1308: tickRect.width = (slider.getPaintTicks() ? getTickLength() : 0);
1309: tickRect.height = trackRect.height;
1310:
1311: if (tickRect.x + tickRect.width > contentRect.x + contentRect.width)
1312: tickRect.width = contentRect.x + contentRect.width - tickRect.x;
1313: }
1314: }
1315:
1316:
1320: protected void calculateLabelRect()
1321: {
1322: if (slider.getOrientation() == JSlider.HORIZONTAL)
1323: {
1324: labelRect.x = contentRect.x;
1325: labelRect.y = tickRect.y + tickRect.height;
1326: labelRect.width = contentRect.width;
1327: labelRect.height = getHeightOfTallestLabel();
1328: }
1329: else
1330: {
1331: labelRect.x = tickRect.x + tickRect.width;
1332: labelRect.y = contentRect.y;
1333: labelRect.width = getWidthOfWidestLabel();
1334: labelRect.height = contentRect.height;
1335: }
1336: }
1337:
1338:
1344: protected int getWidthOfWidestLabel()
1345: {
1346: int widest = 0;
1347: Component label;
1348:
1349: if (slider.getLabelTable() == null)
1350: return 0;
1351:
1352: Dimension pref;
1353: for (Enumeration list = slider.getLabelTable().elements();
1354: list.hasMoreElements();)
1355: {
1356: Object comp = list.nextElement();
1357: if (! (comp instanceof Component))
1358: continue;
1359: label = (Component) comp;
1360: pref = label.getPreferredSize();
1361: if (pref != null && pref.width > widest)
1362: widest = pref.width;
1363: }
1364: return widest;
1365: }
1366:
1367:
1373: protected int getHeightOfTallestLabel()
1374: {
1375: int tallest = 0;
1376: Component label;
1377:
1378: if (slider.getLabelTable() == null)
1379: return 0;
1380: Dimension pref;
1381: for (Enumeration list = slider.getLabelTable().elements();
1382: list.hasMoreElements();)
1383: {
1384: Object comp = list.nextElement();
1385: if (! (comp instanceof Component))
1386: continue;
1387: label = (Component) comp;
1388: pref = label.getPreferredSize();
1389: if (pref != null && pref.height > tallest)
1390: tallest = pref.height;
1391: }
1392: return tallest;
1393: }
1394:
1395:
1403: protected int getWidthOfHighValueLabel()
1404: {
1405: Component highValueLabel = getHighestValueLabel();
1406: if (highValueLabel != null)
1407: return highValueLabel.getPreferredSize().width;
1408: else
1409: return 0;
1410: }
1411:
1412:
1420: protected int getWidthOfLowValueLabel()
1421: {
1422: Component lowValueLabel = getLowestValueLabel();
1423: if (lowValueLabel != null)
1424: return lowValueLabel.getPreferredSize().width;
1425: else
1426: return 0;
1427: }
1428:
1429:
1435: protected int getHeightOfHighValueLabel()
1436: {
1437: Component highValueLabel = getHighestValueLabel();
1438: if (highValueLabel != null)
1439: return highValueLabel.getPreferredSize().height;
1440: else
1441: return 0;
1442: }
1443:
1444:
1450: protected int getHeightOfLowValueLabel()
1451: {
1452: Component lowValueLabel = getLowestValueLabel();
1453: if (lowValueLabel != null)
1454: return lowValueLabel.getPreferredSize().height;
1455: else
1456: return 0;
1457: }
1458:
1459:
1465: protected boolean drawInverted()
1466: {
1467: return slider.getInverted();
1468: }
1469:
1470:
1475: protected Component getLowestValueLabel()
1476: {
1477: Integer key = new Integer(Integer.MAX_VALUE);
1478: Integer tmpKey;
1479: Dictionary labelTable = slider.getLabelTable();
1480:
1481: if (labelTable == null)
1482: return null;
1483:
1484: for (Enumeration list = labelTable.keys(); list.hasMoreElements();)
1485: {
1486: Object value = list.nextElement();
1487: if (! (value instanceof Integer))
1488: continue;
1489: tmpKey = (Integer) value;
1490: if (tmpKey.intValue() < key.intValue())
1491: key = tmpKey;
1492: }
1493: Object comp = labelTable.get(key);
1494: if (! (comp instanceof Component))
1495: return null;
1496: return (Component) comp;
1497: }
1498:
1499:
1505: protected Component getHighestValueLabel()
1506: {
1507: Integer key = new Integer(Integer.MIN_VALUE);
1508: Integer tmpKey;
1509: Dictionary labelTable = slider.getLabelTable();
1510:
1511: if (labelTable == null)
1512: return null;
1513:
1514: for (Enumeration list = labelTable.keys(); list.hasMoreElements();)
1515: {
1516: Object value = list.nextElement();
1517: if (! (value instanceof Integer))
1518: continue;
1519: tmpKey = (Integer) value;
1520: if (tmpKey.intValue() > key.intValue())
1521: key = tmpKey;
1522: }
1523: Object comp = labelTable.get(key);
1524: if (! (comp instanceof Component))
1525: return null;
1526: return (Component) comp;
1527: }
1528:
1529:
1537: public void paint(Graphics g, JComponent c)
1538: {
1539:
1540: leftToRightCache = slider.getComponentOrientation()
1541: != ComponentOrientation.RIGHT_TO_LEFT;
1542:
1543: calculateGeometry();
1544:
1545: if (slider.getPaintTrack())
1546: paintTrack(g);
1547: if (slider.getPaintTicks())
1548: paintTicks(g);
1549: if (slider.getPaintLabels())
1550: paintLabels(g);
1551:
1552:
1553: paintThumb(g);
1554: }
1555:
1556:
1560: protected void recalculateIfInsetsChanged()
1561: {
1562:
1563:
1564: calculateFocusRect();
1565:
1566: calculateContentRect();
1567: calculateThumbSize();
1568: calculateTrackBuffer();
1569: calculateTrackRect();
1570: calculateThumbLocation();
1571:
1572: calculateTickRect();
1573: calculateLabelRect();
1574: }
1575:
1576:
1580: protected void recalculateIfOrientationChanged()
1581: {
1582:
1583:
1584: calculateThumbSize();
1585: calculateTrackBuffer();
1586: calculateTrackRect();
1587: calculateThumbLocation();
1588:
1589: calculateTickRect();
1590: calculateLabelRect();
1591: }
1592:
1593:
1600: public void paintFocus(Graphics g)
1601: {
1602: Color saved_color = g.getColor();
1603:
1604: g.setColor(getFocusColor());
1605:
1606: g.drawRect(focusRect.x, focusRect.y, focusRect.width, focusRect.height);
1607:
1608: g.setColor(saved_color);
1609: }
1610:
1611:
1637: public void paintTrack(Graphics g)
1638: {
1639: Color saved_color = g.getColor();
1640: int width;
1641: int height;
1642:
1643: Point a = new Point(trackRect.x, trackRect.y);
1644: Point b = new Point(a);
1645: Point c = new Point(a);
1646: Point d = new Point(a);
1647:
1648: if (slider.getOrientation() == JSlider.HORIZONTAL)
1649: {
1650: width = trackRect.width;
1651: height = (thumbRect.height / 4 == 0) ? 1 : thumbRect.height / 4;
1652:
1653: a.translate(0, (trackRect.height / 2) - (height / 2));
1654: b.translate(0, (trackRect.height / 2) + (height / 2));
1655: c.translate(trackRect.width, (trackRect.height / 2) + (height / 2));
1656: d.translate(trackRect.width, (trackRect.height / 2) - (height / 2));
1657: }
1658: else
1659: {
1660: width = (thumbRect.width / 4 == 0) ? 1 : thumbRect.width / 4;
1661: height = trackRect.height;
1662:
1663: a.translate((trackRect.width / 2) - (width / 2), 0);
1664: b.translate((trackRect.width / 2) - (width / 2), trackRect.height);
1665: c.translate((trackRect.width / 2) + (width / 2), trackRect.height);
1666: d.translate((trackRect.width / 2) + (width / 2), 0);
1667: }
1668: g.setColor(Color.GRAY);
1669: g.fillRect(a.x, a.y, width, height);
1670:
1671: g.setColor(getHighlightColor());
1672: g.drawLine(b.x, b.y, c.x, c.y);
1673: g.drawLine(c.x, c.y, d.x, d.y);
1674:
1675: g.setColor(getShadowColor());
1676: g.drawLine(b.x, b.y, a.x, a.y);
1677: g.drawLine(a.x, a.y, d.x, d.y);
1678:
1679: g.setColor(saved_color);
1680: }
1681:
1682:
1689: public void paintTicks(Graphics g)
1690: {
1691: int max = slider.getMaximum();
1692: int min = slider.getMinimum();
1693: int majorSpace = slider.getMajorTickSpacing();
1694: int minorSpace = slider.getMinorTickSpacing();
1695:
1696: if (majorSpace > 0)
1697: {
1698: if (slider.getOrientation() == JSlider.HORIZONTAL)
1699: {
1700: g.translate(0, tickRect.y);
1701: for (int i = min; i <= max; i += majorSpace)
1702: paintMajorTickForHorizSlider(g, tickRect, xPositionForValue(i));
1703: g.translate(0, -tickRect.y);
1704: }
1705: else
1706: {
1707: g.translate(tickRect.x, 0);
1708: for (int i = min; i <= max; i += majorSpace)
1709: paintMajorTickForVertSlider(g, tickRect, yPositionForValue(i));
1710: g.translate(-tickRect.x, 0);
1711: }
1712: }
1713: if (minorSpace > 0)
1714: {
1715: if (slider.getOrientation() == JSlider.HORIZONTAL)
1716: {
1717: g.translate(0, tickRect.y);
1718: for (int i = min; i <= max; i += minorSpace)
1719: paintMinorTickForHorizSlider(g, tickRect, xPositionForValue(i));
1720: g.translate(0, -tickRect.y);
1721: }
1722: else
1723: {
1724: g.translate(tickRect.x, 0);
1725: for (int i = min; i <= max; i += minorSpace)
1726: paintMinorTickForVertSlider(g, tickRect, yPositionForValue(i));
1727: g.translate(-tickRect.x, 0);
1728: }
1729: }
1730: }
1731:
1732:
1737:
1738:
1746: protected void paintMinorTickForHorizSlider(Graphics g,
1747: Rectangle tickBounds, int x)
1748: {
1749: int y = tickRect.height / 4;
1750: Color saved = g.getColor();
1751: g.setColor(Color.BLACK);
1752:
1753: g.drawLine(x, y, x, y + tickRect.height / 4);
1754: g.setColor(saved);
1755: }
1756:
1757:
1765: protected void paintMajorTickForHorizSlider(Graphics g,
1766: Rectangle tickBounds, int x)
1767: {
1768: int y = tickRect.height / 4;
1769: Color saved = g.getColor();
1770: g.setColor(Color.BLACK);
1771:
1772: g.drawLine(x, y, x, y + tickRect.height / 2);
1773: g.setColor(saved);
1774: }
1775:
1776:
1784: protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds,
1785: int y)
1786: {
1787: int x = tickRect.width / 4;
1788: Color saved = g.getColor();
1789: g.setColor(Color.BLACK);
1790:
1791: g.drawLine(x, y, x + tickRect.width / 4, y);
1792: g.setColor(saved);
1793: }
1794:
1795:
1803: protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds,
1804: int y)
1805: {
1806: int x = tickRect.width / 4;
1807: Color saved = g.getColor();
1808: g.setColor(Color.BLACK);
1809:
1810: g.drawLine(x, y, x + tickRect.width / 2, y);
1811: g.setColor(saved);
1812: }
1813:
1814:
1822: public void paintLabels(Graphics g)
1823: {
1824: if (slider.getLabelTable() != null)
1825: {
1826: Dictionary table = slider.getLabelTable();
1827: Integer tmpKey;
1828: Object key;
1829: Object element;
1830: Component label;
1831: if (slider.getOrientation() == JSlider.HORIZONTAL)
1832: {
1833: for (Enumeration list = table.keys(); list.hasMoreElements();)
1834: {
1835: key = list.nextElement();
1836: if (! (key instanceof Integer))
1837: continue;
1838: tmpKey = (Integer) key;
1839: element = table.get(tmpKey);
1840:
1841:
1842: if (! (element instanceof JLabel))
1843: continue;
1844: label = (Component) element;
1845: paintHorizontalLabel(g, tmpKey.intValue(), label);
1846: }
1847: }
1848: else
1849: {
1850: for (Enumeration list = table.keys(); list.hasMoreElements();)
1851: {
1852: key = list.nextElement();
1853: if (! (key instanceof Integer))
1854: continue;
1855: tmpKey = (Integer) key;
1856: element = table.get(tmpKey);
1857:
1858:
1859: if (! (element instanceof JLabel))
1860: continue;
1861: label = (Component) element;
1862: paintVerticalLabel(g, tmpKey.intValue(), label);
1863: }
1864: }
1865: }
1866: }
1867:
1868:
1879: protected void paintHorizontalLabel(Graphics g, int value, Component label)
1880: {
1881:
1882:
1883:
1884:
1885:
1886: Dimension dim = label.getPreferredSize();
1887: int w = (int) dim.getWidth();
1888: int h = (int) dim.getHeight();
1889:
1890: int max = slider.getMaximum();
1891: int min = slider.getMinimum();
1892:
1893: if (value > max || value < min)
1894: return;
1895:
1896:
1897:
1898:
1899:
1900:
1901:
1902:
1903: int xpos = xPositionForValue(value) - w / 2;
1904: int ypos = labelRect.y;
1905:
1906:
1907:
1908:
1909:
1910: if (xpos < 0)
1911: xpos = 0;
1912:
1913:
1914:
1915:
1916: if (xpos + w > labelRect.x + labelRect.width)
1917: w = labelRect.x + labelRect.width - xpos;
1918:
1919:
1920:
1921: if (h > labelRect.height)
1922: h = labelRect.height;
1923:
1924: label.setBounds(xpos, ypos, w, h);
1925: SwingUtilities.paintComponent(g, label, null, label.getBounds());
1926: }
1927:
1928:
1939: protected void paintVerticalLabel(Graphics g, int value, Component label)
1940: {
1941: Dimension dim = label.getPreferredSize();
1942: int w = (int) dim.getWidth();
1943: int h = (int) dim.getHeight();
1944:
1945: int max = slider.getMaximum();
1946: int min = slider.getMinimum();
1947:
1948: if (value > max || value < min)
1949: return;
1950:
1951: int xpos = labelRect.x;
1952: int ypos = yPositionForValue(value) - h / 2;
1953:
1954: if (ypos < 0)
1955: ypos = 0;
1956:
1957: if (ypos + h > labelRect.y + labelRect.height)
1958: h = labelRect.y + labelRect.height - ypos;
1959:
1960: if (w > labelRect.width)
1961: w = labelRect.width;
1962:
1963: label.setBounds(xpos, ypos, w, h);
1964: SwingUtilities.paintComponent(g, label, null, label.getBounds());
1965: }
1966:
1967:
1989: public void paintThumb(Graphics g)
1990: {
1991: Color saved_color = g.getColor();
1992:
1993: Point a = new Point(thumbRect.x, thumbRect.y);
1994: Point b = new Point(a);
1995: Point c = new Point(a);
1996: Point d = new Point(a);
1997: Point e = new Point(a);
1998:
1999: Polygon bright;
2000: Polygon light;
2001: Polygon dark;
2002: Polygon all;
2003:
2004:
2005: int turnPoint;
2006:
2007: if (slider.getOrientation() == JSlider.HORIZONTAL)
2008: {
2009: turnPoint = thumbRect.height * 3 / 4;
2010:
2011: b.translate(thumbRect.width - 1, 0);
2012: c.translate(thumbRect.width - 1, turnPoint);
2013: d.translate(thumbRect.width / 2 - 1, thumbRect.height - 1);
2014: e.translate(0, turnPoint);
2015:
2016: bright = new Polygon(new int[] { b.x - 1, a.x, e.x, d.x },
2017: new int[] { b.y, a.y, e.y, d.y }, 4);
2018:
2019: dark = new Polygon(new int[] { b.x, c.x, d.x + 1 },
2020: new int[] { b.y, c.y - 1, d.y }, 3);
2021:
2022: light = new Polygon(new int[] { b.x - 1, c.x - 1, d.x + 1 },
2023: new int[] { b.y + 1, c.y - 1, d.y - 1 }, 3);
2024:
2025: all = new Polygon(new int[] { a.x + 1, b.x - 2, c.x - 2, d.x, e.x + 1 },
2026: new int[] { a.y + 1, b.y + 1, c.y - 1, d.y - 1, e.y },
2027: 5);
2028: }
2029: else
2030: {
2031: turnPoint = thumbRect.width * 3 / 4 - 1;
2032:
2033: b.translate(turnPoint, 0);
2034: c.translate(thumbRect.width - 1, thumbRect.height / 2);
2035: d.translate(turnPoint, thumbRect.height - 1);
2036: e.translate(0, thumbRect.height - 1);
2037:
2038: bright = new Polygon(new int[] { c.x - 1, b.x, a.x, e.x },
2039: new int[] { c.y - 1, b.y, a.y, e.y - 1 }, 4);
2040:
2041: dark = new Polygon(new int[] { c.x, d.x, e.x },
2042: new int[] { c.y, d.y, e.y }, 3);
2043:
2044: light = new Polygon(new int[] { c.x - 1, d.x, e.x + 1},
2045: new int[] { c.y, d.y - 1, e.y - 1}, 3);
2046: all = new Polygon(new int[] { a.x + 1, b.x, c.x - 2, c.x - 2, d.x,
2047: e.x + 1 },
2048: new int[] { a.y + 1, b.y + 1, c.y - 1, c.y, d.y - 2,
2049: e.y - 2 }, 6);
2050: }
2051:
2052: g.setColor(Color.WHITE);
2053: g.drawPolyline(bright.xpoints, bright.ypoints, bright.npoints);
2054:
2055: g.setColor(Color.BLACK);
2056: g.drawPolyline(dark.xpoints, dark.ypoints, dark.npoints);
2057:
2058: g.setColor(Color.GRAY);
2059: g.drawPolyline(light.xpoints, light.ypoints, light.npoints);
2060:
2061: g.setColor(Color.LIGHT_GRAY);
2062: g.drawPolyline(all.xpoints, all.ypoints, all.npoints);
2063: g.fillPolygon(all);
2064:
2065: g.setColor(saved_color);
2066: }
2067:
2068:
2074: public void setThumbLocation(int x, int y)
2075: {
2076: thumbRect.x = x;
2077: thumbRect.y = y;
2078: }
2079:
2080:
2089: public void scrollByBlock(int direction)
2090: {
2091: int unit = (slider.getMaximum() - slider.getMinimum()) / 10;
2092: int moveTo = slider.getValue();
2093: if (direction > 0)
2094: moveTo += unit;
2095: else
2096: moveTo -= unit;
2097:
2098: if (slider.getSnapToTicks())
2099: moveTo = findClosestTick(moveTo);
2100:
2101: slider.setValue(moveTo);
2102: }
2103:
2104:
2113: public void scrollByUnit(int direction)
2114: {
2115: int moveTo = slider.getValue();
2116: if (direction > 0)
2117: moveTo++;
2118: else
2119: moveTo--;
2120:
2121: if (slider.getSnapToTicks())
2122: moveTo = findClosestTick(moveTo);
2123:
2124: slider.setValue(moveTo);
2125: }
2126:
2127:
2134: protected void scrollDueToClickInTrack(int dir)
2135: {
2136: scrollTimer.stop();
2137:
2138: scrollListener.setDirection(dir);
2139: scrollListener.setScrollByBlock(true);
2140:
2141: scrollTimer.start();
2142: }
2143:
2144:
2153: protected int xPositionForValue(int value)
2154: {
2155: double min = slider.getMinimum();
2156: if (value < min)
2157: value = (int) min;
2158: double max = slider.getMaximum();
2159: if (value > max)
2160: value = (int) max;
2161: double len = trackRect.width;
2162: if ((max - min) <= 0.0)
2163: return 0;
2164: int xPos = (int) ((value - min) / (max - min) * len + 0.5);
2165:
2166: if (drawInverted())
2167: return trackRect.x + Math.max(trackRect.width - xPos - 1, 0);
2168: else
2169: return trackRect.x + Math.min(xPos, trackRect.width - 1);
2170: }
2171:
2172:
2181: protected int yPositionForValue(int value)
2182: {
2183: double min = slider.getMinimum();
2184: if (value < min)
2185: value = (int) min;
2186: double max = slider.getMaximum();
2187: if (value > max)
2188: value = (int) max;
2189: int len = trackRect.height;
2190: if ((max - min) <= 0.0)
2191: return 0;
2192:
2193: int yPos = (int) ((value - min) / (max - min) * len + 0.5);
2194:
2195: if (! drawInverted())
2196: return trackRect.y + trackRect.height - Math.max(yPos, 1);
2197: else
2198: return trackRect.y + Math.min(yPos, trackRect.height - 1);
2199: }
2200:
2201:
2210: public int valueForYPosition(int yPos)
2211: {
2212: int min = slider.getMinimum();
2213: int max = slider.getMaximum();
2214: int len = trackRect.height;
2215:
2216: int value;
2217:
2218:
2219:
2220:
2221: if (len == 0)
2222: return ((max - min) / 2);
2223:
2224: if (! drawInverted())
2225: value = ((len - (yPos - trackRect.y)) * (max - min) / len + min);
2226: else
2227: value = ((yPos - trackRect.y) * (max - min) / len + min);
2228:
2229:
2230: if (value > max)
2231: value = max;
2232: else if (value < min)
2233: value = min;
2234: return value;
2235: }
2236:
2237:
2246: public int valueForXPosition(int xPos)
2247: {
2248: int min = slider.getMinimum();
2249: int max = slider.getMaximum();
2250: int len = trackRect.width;
2251:
2252: int value;
2253:
2254:
2255:
2256:
2257: if (len == 0)
2258: return ((max - min) / 2);
2259:
2260: if (! drawInverted())
2261: value = ((xPos - trackRect.x) * (max - min) / len + min);
2262: else
2263: value = ((len - (xPos - trackRect.x)) * (max - min) / len + min);
2264:
2265:
2266: if (value > max)
2267: value = max;
2268: else if (value < min)
2269: value = min;
2270: return value;
2271: }
2272:
2273:
2281: int findClosestTick(int value)
2282: {
2283: int min = slider.getMinimum();
2284: int max = slider.getMaximum();
2285: int majorSpace = slider.getMajorTickSpacing();
2286: int minorSpace = slider.getMinorTickSpacing();
2287:
2288:
2289:
2290:
2291:
2292:
2293: int minor = min - value;
2294: int major = min - value;
2295:
2296:
2297:
2298:
2299: if (majorSpace <= 0 && minorSpace <= 0)
2300: return value;
2301:
2302:
2303: if (majorSpace > 0)
2304: {
2305: int lowerBound = (value - min) / majorSpace;
2306: int majLower = majorSpace * lowerBound + min;
2307: int majHigher = majorSpace * (lowerBound + 1) + min;
2308:
2309: if (majHigher <= max && majHigher - value <= value - majLower)
2310: major = majHigher - value;
2311: else
2312: major = majLower - value;
2313: }
2314:
2315: if (minorSpace > 0)
2316: {
2317: int lowerBound = value / minorSpace;
2318: int minLower = minorSpace * lowerBound;
2319: int minHigher = minorSpace * (lowerBound + 1);
2320:
2321: if (minHigher <= max && minHigher - value <= value - minLower)
2322: minor = minHigher - value;
2323: else
2324: minor = minLower - value;
2325: }
2326:
2327:
2328: if (Math.abs(minor) > Math.abs(major))
2329: return value + major;
2330: else
2331: return value + minor;
2332: }
2333:
2334: InputMap getInputMap(int condition)
2335: {
2336: if (condition == JComponent.WHEN_FOCUSED)
2337: return (InputMap) UIManager.get("Slider.focusInputMap");
2338: return null;
2339: }
2340:
2341:
2348: ActionMap getActionMap()
2349: {
2350: ActionMap map = (ActionMap) UIManager.get("Slider.actionMap");
2351:
2352: if (map == null)
2353: {
2354: map = createActionMap();
2355: if (map != null)
2356: UIManager.put("Slider.actionMap", map);
2357: }
2358: return map;
2359: }
2360:
2361:
2371: ActionMap createActionMap()
2372: {
2373: ActionMap map = new ActionMapUIResource();
2374: map.put("positiveUnitIncrement",
2375: new AbstractAction("positiveUnitIncrement") {
2376: public void actionPerformed(ActionEvent event)
2377: {
2378: JSlider slider = (JSlider) event.getSource();
2379: BasicSliderUI ui = (BasicSliderUI) slider.getUI();
2380: if (slider.getInverted())
2381: ui.scrollByUnit(BasicSliderUI.NEGATIVE_SCROLL);
2382: else
2383: ui.scrollByUnit(BasicSliderUI.POSITIVE_SCROLL);
2384: }
2385: }
2386: );
2387: map.put("negativeUnitIncrement",
2388: new AbstractAction("negativeUnitIncrement") {
2389: public void actionPerformed(ActionEvent event)
2390: {
2391: JSlider slider = (JSlider) event.getSource();
2392: BasicSliderUI ui = (BasicSliderUI) slider.getUI();
2393: if (slider.getInverted())
2394: ui.scrollByUnit(BasicSliderUI.POSITIVE_SCROLL);
2395: else
2396: ui.scrollByUnit(BasicSliderUI.NEGATIVE_SCROLL);
2397: }
2398: }
2399: );
2400: map.put("positiveBlockIncrement",
2401: new AbstractAction("positiveBlockIncrement") {
2402: public void actionPerformed(ActionEvent event)
2403: {
2404: JSlider slider = (JSlider) event.getSource();
2405: BasicSliderUI ui = (BasicSliderUI) slider.getUI();
2406: if (slider.getInverted())
2407: ui.scrollByBlock(BasicSliderUI.NEGATIVE_SCROLL);
2408: else
2409: ui.scrollByBlock(BasicSliderUI.POSITIVE_SCROLL);
2410: }
2411: }
2412: );
2413: map.put("negativeBlockIncrement",
2414: new AbstractAction("negativeBlockIncrement") {
2415: public void actionPerformed(ActionEvent event)
2416: {
2417: JSlider slider = (JSlider) event.getSource();
2418: BasicSliderUI ui = (BasicSliderUI) slider.getUI();
2419: if (slider.getInverted())
2420: ui.scrollByBlock(BasicSliderUI.POSITIVE_SCROLL);
2421: else
2422: ui.scrollByBlock(BasicSliderUI.NEGATIVE_SCROLL);
2423: }
2424: }
2425: );
2426: map.put("minScroll",
2427: new AbstractAction("minScroll") {
2428: public void actionPerformed(ActionEvent event)
2429: {
2430: JSlider slider = (JSlider) event.getSource();
2431: if (slider.getInverted())
2432: slider.setValue(slider.getMaximum());
2433: else
2434: slider.setValue(slider.getMinimum());
2435: }
2436: }
2437: );
2438: map.put("maxScroll",
2439: new AbstractAction("maxScroll") {
2440: public void actionPerformed(ActionEvent event)
2441: {
2442: JSlider slider = (JSlider) event.getSource();
2443: if (slider.getInverted())
2444: slider.setValue(slider.getMinimum());
2445: else
2446: slider.setValue(slider.getMaximum());
2447: }
2448: }
2449: );
2450: return map;
2451: }
2452: }