src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -267,11 +267,11 @@
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();
+ 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() :
@@ -289,11 +289,11 @@
insetCache.bottom;
int trackY = valueY + valueHeight;
int trackHeight = contentHeight - valueHeight;
int yPosition = yPositionForValue(value.intValue(), trackY,
trackHeight);
- JComponent label = (JComponent) slider.getLabelTable().get(value);
+ JComponent label = slider.getLabelTable().get(value);
Dimension pref = label.getPreferredSize();
return yPosition - pref.height / 2 +
label.getBaseline(pref.width, pref.height);
}
}
@@ -390,23 +390,23 @@
// Calculate the track rectangle. It is necessary for
// xPositionForValue to return correct values.
trackRect.x = insetCache.left;
trackRect.width = contentRect.width;
- Dictionary dictionary = slider.getLabelTable();
+ Dictionary<Integer, 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 keys = dictionary.keys();
+ for (Enumeration<Integer> keys = dictionary.keys();
keys.hasMoreElements(); ) {
- int keyInt = ((Integer)keys.nextElement()).intValue();
+ int keyInt = keys.nextElement().intValue();
if (keyInt >= minValue && keyInt < firstLblIdx) {
firstLblIdx = keyInt;
}
if (keyInt <= maxValue && keyInt > lastLblIdx) {
lastLblIdx = keyInt;
@@ -515,11 +515,11 @@
* @return padding required to keep label visible.
*/
private int getPadForLabel(int i) {
int pad = 0;
- JComponent c = (JComponent) slider.getLabelTable().get(i);
+ 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));