src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java

Print this page

        

*** 267,277 **** tickHeight + labelHeight + 4; int centerY = height / 2 - contentHeight / 2; centerY += valueHeight + 2; centerY += trackHeight + trackInsets.top + trackInsets.bottom; centerY += tickHeight + 2; ! JComponent label = slider.getLabelTable().elements().nextElement(); Dimension pref = label.getPreferredSize(); return centerY + label.getBaseline(pref.width, pref.height); } else { // VERTICAL Integer value = slider.getInverted() ? getLowestValue() : --- 267,277 ---- tickHeight + labelHeight + 4; int centerY = height / 2 - contentHeight / 2; centerY += valueHeight + 2; centerY += trackHeight + trackInsets.top + trackInsets.bottom; centerY += tickHeight + 2; ! JComponent label = (JComponent) slider.getLabelTable().elements().nextElement(); Dimension pref = label.getPreferredSize(); return centerY + label.getBaseline(pref.width, pref.height); } else { // VERTICAL Integer value = slider.getInverted() ? getLowestValue() :
*** 289,299 **** insetCache.bottom; int trackY = valueY + valueHeight; int trackHeight = contentHeight - valueHeight; int yPosition = yPositionForValue(value.intValue(), trackY, trackHeight); ! JComponent label = slider.getLabelTable().get(value); Dimension pref = label.getPreferredSize(); return yPosition - pref.height / 2 + label.getBaseline(pref.width, pref.height); } } --- 289,299 ---- insetCache.bottom; int trackY = valueY + valueHeight; int trackHeight = contentHeight - valueHeight; int yPosition = yPositionForValue(value.intValue(), trackY, trackHeight); ! JComponent label = (JComponent) slider.getLabelTable().get(value); Dimension pref = label.getPreferredSize(); return yPosition - pref.height / 2 + label.getBaseline(pref.width, pref.height); } }
*** 390,412 **** // Calculate the track rectangle. It is necessary for // xPositionForValue to return correct values. trackRect.x = insetCache.left; trackRect.width = contentRect.width; ! Dictionary<Integer, ? extends JComponent> dictionary = slider.getLabelTable(); if (dictionary != null) { int minValue = slider.getMinimum(); int maxValue = slider.getMaximum(); // Iterate through the keys in the dictionary and find the // first and last labels indices that fall within the // slider range. int firstLblIdx = Integer.MAX_VALUE; int lastLblIdx = Integer.MIN_VALUE; ! for (Enumeration<Integer> keys = dictionary.keys(); keys.hasMoreElements(); ) { ! int keyInt = keys.nextElement().intValue(); if (keyInt >= minValue && keyInt < firstLblIdx) { firstLblIdx = keyInt; } if (keyInt <= maxValue && keyInt > lastLblIdx) { lastLblIdx = keyInt; --- 390,413 ---- // Calculate the track rectangle. It is necessary for // xPositionForValue to return correct values. trackRect.x = insetCache.left; trackRect.width = contentRect.width; ! @SuppressWarnings("rawtypes") ! Dictionary dictionary = slider.getLabelTable(); if (dictionary != null) { int minValue = slider.getMinimum(); int maxValue = slider.getMaximum(); // Iterate through the keys in the dictionary and find the // first and last labels indices that fall within the // slider range. int firstLblIdx = Integer.MAX_VALUE; int lastLblIdx = Integer.MIN_VALUE; ! for (Enumeration<?> keys = dictionary.keys(); keys.hasMoreElements(); ) { ! int keyInt = ((Integer)keys.nextElement()).intValue(); if (keyInt >= minValue && keyInt < firstLblIdx) { firstLblIdx = keyInt; } if (keyInt <= maxValue && keyInt > lastLblIdx) { lastLblIdx = keyInt;
*** 515,525 **** * @return padding required to keep label visible. */ private int getPadForLabel(int i) { int pad = 0; ! JComponent c = slider.getLabelTable().get(i); if (c != null) { int centerX = xPositionForValue(i); int cHalfWidth = c.getPreferredSize().width / 2; if (centerX - cHalfWidth < insetCache.left) { pad = Math.max(pad, insetCache.left - (centerX - cHalfWidth)); --- 516,526 ---- * @return padding required to keep label visible. */ private int getPadForLabel(int i) { int pad = 0; ! JComponent c = (JComponent) slider.getLabelTable().get(i); if (c != null) { int centerX = xPositionForValue(i); int cHalfWidth = c.getPreferredSize().width / 2; if (centerX - cHalfWidth < insetCache.left) { pad = Math.max(pad, insetCache.left - (centerX - cHalfWidth));