/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A Basic L&F implementation of SliderUI.
*
* @author Tom Santos
*/
// Old actions forward to an instance of this.
protected boolean leftToRightCache = true;
private transient boolean isDragging;
private int lastValue;
// Colors
/**
* Whther or not sameLabelBaselines is up to date.
*/
private boolean checkedLabelBaselines;
/**
* Whether or not all the entries in the labeltable have the same
* baseline.
*/
private boolean sameLabelBaselines;
return shadowColor;
}
return highlightColor;
}
return focusColor;
}
/**
* Returns true if the user is dragging the slider.
*
* @return true if the user is dragging the slider
* @since 1.5
*/
protected boolean isDragging() {
return isDragging;
}
/////////////////////////////////////////////////////////////////////////////
// ComponentUI Interface Implementation methods
/////////////////////////////////////////////////////////////////////////////
return new BasicSliderUI((JSlider)b);
}
}
checkedLabelBaselines = false;
isDragging = false;
contentRect = new Rectangle();
calculateGeometry(); // This figures out where the labels, ticks, track, and thumb are.
}
if ( c != slider )
throw new IllegalComponentStateException(
this + " was asked to deinstall() "
+ c + " when it only knows about "
+ slider + ".");
scrollTimer.stop();
scrollTimer = null;
insetCache = null;
leftToRightCache = true;
contentRect = null;
}
"Slider.foreground", "Slider.font");
// use default if missing so that BasicSliderUI can be used in other
// LAFs like Nimbus
}
focusInsets = null;
}
return new TrackListener();
}
return getHandler();
}
return getHandler();
}
return getHandler();
}
return new ScrollListener();
}
return getHandler();
}
}
return handler;
}
}
}
"Slider.actionMap");
}
"Slider.focusInputMap");
"Slider.focusInputMap.RightToLeft")) == null)) {
return keyMap;
} else {
return rtlKeyMap;
}
}
return null;
}
/**
* Populates ComboBox's actions.
*/
}
null);
}
/**
* Returns the baseline.
*
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
int tickLength = getTickLength();
int centerSpacing = thumbHeight;
if (slider.getPaintTicks()) {
}
// Assume uniform labels.
int trackHeight = thumbHeight;
int tickHeight = tickLength;
if (!slider.getPaintTicks()) {
tickHeight = 0;
}
}
else { // vertical
thumbHeight / 2);
}
}
}
return 0;
}
/**
* Returns an enum indicating how the baseline of the component
* changes as the size changes.
*
* @throws NullPointerException {@inheritDoc}
* @see javax.swing.JComponent#getBaseline(int, int)
* @since 1.6
*/
JComponent c) {
super.getBaselineResizeBehavior(c);
// NOTE: BasicSpinner really provides for CENTER_OFFSET, but
// so that getBaseline() doesn't implement the contract
// for CENTER_OFFSET as defined in Component.
}
/**
* Returns true if all the labels from the label table have the same
* baseline.
*
* @return true if all the labels from the label table have the
* same baseline
* @since 1.6
*/
protected boolean labelsHaveSameBaselines() {
if (!checkedLabelBaselines) {
checkedLabelBaselines = true;
if (dictionary != null) {
sameLabelBaselines = true;
int baseline = -1;
while (elements.hasMoreElements()) {
if (labelBaseline >= 0) {
if (baseline == -1) {
}
else if (baseline != labelBaseline) {
sameLabelBaselines = false;
break;
}
}
else {
sameLabelBaselines = false;
break;
}
}
}
else {
sameLabelBaselines = false;
}
}
return sameLabelBaselines;
}
this, "Slider.horizontalSize");
}
return horizDim;
}
this, "Slider.verticalSize");
}
return vertDim;
}
this, "Slider.minimumHorizontalSize");
if (minHorizDim == null) {
}
return minHorizDim;
}
this, "Slider.minimumVerticalSize");
if (minVertDim == null) {
}
return minVertDim;
}
Dimension d;
d = new Dimension(getPreferredVerticalSize());
}
else {
d = new Dimension(getPreferredHorizontalSize());
}
return d;
}
Dimension d;
d = new Dimension(getMinimumVerticalSize());
}
else {
d = new Dimension(getMinimumHorizontalSize());
}
return d;
}
Dimension d = getPreferredSize(c);
}
else {
}
return d;
}
protected void calculateGeometry() {
}
protected void calculateFocusRect() {
}
protected void calculateThumbSize() {
}
protected void calculateContentRect() {
}
private int getTickSpacing() {
int result;
if (minorTickSpacing > 0) {
} else if (majorTickSpacing > 0) {
} else {
result = 0;
}
return result;
}
protected void calculateThumbLocation() {
if ( slider.getSnapToTicks() ) {
int snappedValue = sliderValue;
int tickSpacing = getTickSpacing();
if ( tickSpacing != 0 ) {
// If it's not on a tick, change the value
// This is the fix for the bug #6401380
whichTick --;
}
}
if( snappedValue != sliderValue ) {
}
}
}
}
else {
}
}
protected void calculateTrackBuffer() {
}
else {
}
}
else {
}
else {
}
}
}
protected void calculateTrackRect() {
int centerSpacing; // used to center sliders added using BorderLayout.CENTER (bug 4275631)
}
else {
} else {
}
}
}
/**
* Gets the height of the tick area for horizontal sliders and the width of the
* tick area for vertical sliders. BasicSliderUI uses the returned value to
* determine the tick area rectangle. If you want to give your ticks some room,
* make this larger than you need and paint your ticks away from the sides in paintTicks().
*/
protected int getTickLength() {
return 8;
}
protected void calculateTickRect() {
}
else {
}
else {
}
}
}
protected void calculateLabelRect() {
if ( slider.getPaintLabels() ) {
}
else {
}
else {
}
}
}
else {
}
else {
}
else {
}
}
}
}
}
else {
}
return size;
}
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().propertyChange(e);
}
}
protected int getWidthOfWidestLabel() {
int widest = 0;
if ( dictionary != null ) {
while ( keys.hasMoreElements() ) {
}
}
return widest;
}
protected int getHeightOfTallestLabel() {
int tallest = 0;
if ( dictionary != null ) {
while ( keys.hasMoreElements() ) {
}
}
return tallest;
}
protected int getWidthOfHighValueLabel() {
int width = 0;
}
return width;
}
protected int getWidthOfLowValueLabel() {
int width = 0;
}
return width;
}
protected int getHeightOfHighValueLabel() {
int height = 0;
}
return height;
}
protected int getHeightOfLowValueLabel() {
int height = 0;
}
return height;
}
protected boolean drawInverted() {
return slider.getInverted();
} else {
return !slider.getInverted();
}
} else {
return slider.getInverted();
}
}
/**
* Returns the biggest value that has an entry in the label table.
*
* @return biggest value that has an entry in the label table, or
* null.
* @since 1.6
*/
if (dictionary == null) {
return null;
}
while (keys.hasMoreElements()) {
max = i;
}
}
return max;
}
/**
* Returns the smallest value that has an entry in the label table.
*
* @return smallest value that has an entry in the label table, or
* null.
* @since 1.6
*/
if (dictionary == null) {
return null;
}
while (keys.hasMoreElements()) {
min = i;
}
}
return min;
}
/**
* Returns the label that corresponds to the highest slider value in the label table.
* @see JSlider#setLabelTable
*/
}
return null;
}
/**
* Returns the label that corresponds to the lowest slider value in the label table.
* @see JSlider#setLabelTable
*/
}
return null;
}
paintTrack( g );
}
paintTicks( g );
}
paintLabels( g );
}
paintFocus( g );
}
paintThumb( g );
}
}
protected void recalculateIfInsetsChanged() {
}
}
protected void recalculateIfOrientationChanged() {
if ( ltr!=leftToRightCache ) {
}
}
g.setColor( getFocusColor() );
}
g.setColor(getShadowColor());
g.setColor(getHighlightColor());
}
else {
g.setColor(getShadowColor());
g.setColor(getHighlightColor());
}
}
// Overflow checking
break;
}
}
}
// Overflow checking
break;
}
}
}
} else {
int offset = 0;
}
// Overflow checking
break;
}
}
}
}
}
// Overflow checking
break;
}
}
}
}
}
}
}
}
}
}
if ( dictionary != null ) {
while ( keys.hasMoreElements() ) {
// Register Slider as an image observer. It allows to catch notifications about
// image changes (e.g. gif animation)
}
}
}
else {
int offset = 0;
}
}
}
}
}
}
/**
* Called for every label in the label table. Used to draw the labels for horizontal sliders.
* The graphics have been translated to labelRect.y already.
* @see JSlider#setLabelTable
*/
}
/**
* Called for every label in the label table. Used to draw the labels for vertical sliders.
* The graphics have been translated to labelRect.x already.
* @see JSlider#setLabelTable
*/
}
int w = knobBounds.width;
int h = knobBounds.height;
}
else {
}
// "plain" version
g.setColor(shadowColor);
}
int cw = w / 2;
g.fillPolygon(p);
g.setColor(shadowColor);
}
else { // vertical
int cw = h / 2;
g.fillPolygon(p);
g.setColor(shadowColor);
}
else {
g.fillPolygon(p);
g.setColor(shadowColor);
}
}
}
// Used exclusively by setThumbLocation()
public void setThumbLocation(int x, int y) {
thumbRect.setLocation( x, y );
SwingUtilities.computeUnion( thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height, unionRect );
}
synchronized(slider) {
int blockIncrement =
if (blockIncrement == 0) {
blockIncrement = 1;
}
if (slider.getSnapToTicks()) {
int tickSpacing = getTickSpacing();
if (blockIncrement < tickSpacing) {
}
}
}
}
synchronized(slider) {
if (slider.getSnapToTicks()) {
delta *= getTickSpacing();
}
}
}
/**
* This function is called when a mousePressed was detected in the track, not
* in the thumb. The default behavior is to scroll by block. You can
* override this method to stop it from scrolling or to add additional behavior.
*/
scrollByBlock( dir );
}
int xPosition;
if ( !drawInverted() ) {
}
else {
}
return xPosition;
}
}
/**
* Returns the y location for the specified value. No checking is
* done on the arguments. In particular if <code>trackHeight</code> is
* negative undefined results may occur.
*
* @param value the slider value to get the location for
* @param trackY y-origin of the track
* @param trackHeight the height of the track
* @since 1.6
*/
int yPosition;
if ( !drawInverted() ) {
}
else {
}
return yPosition;
}
/**
* Returns the value at the y position. If {@code yPos} is beyond the
* track at the the bottom or the top, this method sets the value to either
* the minimum or maximum value of the slider, depending on if the slider
* is inverted or not.
*/
int value;
}
else if ( yPos >= trackBottom ) {
}
else {
}
return value;
}
/**
* Returns the value at the x position. If {@code xPos} is beyond the
* track at the left or the right, this method sets the value to either the
* minimum or maximum value of the slider, depending on if the slider is
* inverted or not.
*/
int value;
}
else if ( xPos >= trackRight ) {
}
else {
}
return value;
}
// Change Handler
if (!isDragging) {
}
}
// Component Handler
}
// Focus Handler
// Property Change Handler
if (propertyName == "orientation" ||
propertyName == "inverted" ||
propertyName == "labelTable" ||
propertyName == "majorTickSpacing" ||
propertyName == "minorTickSpacing" ||
propertyName == "paintTicks" ||
propertyName == "paintTrack" ||
propertyName == "font" ||
propertyName == "paintLabels" ||
propertyName == "Slider.paintThumbArrowShape") {
checkedLabelBaselines = false;
} else if (propertyName == "componentOrientation") {
} else if (propertyName == "model") {
}
}
}
/////////////////////////////////////////////////////////////////////////
/// Model Listener Class
/////////////////////////////////////////////////////////////////////////
/**
* Data model listener.
*
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of <Foo>.
*/
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().stateChanged(e);
}
}
/////////////////////////////////////////////////////////////////////////
/// Track Listener Class
/////////////////////////////////////////////////////////////////////////
/**
* Track mouse movements.
*
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of <Foo>.
*/
protected transient int offset;
return;
}
offset = 0;
scrollTimer.stop();
isDragging = false;
slider.setValueIsAdjusting(false);
}
/**
* If the mouse is pressed above the "thumb" component
* then reduce the scrollbars value by one page ("page up"),
* otherwise increase it by one page. If there is no
* thumb then page up if the mouse is in the upper half
* of the track.
*/
return;
}
// We should recalculate geometry just before
// calculation of the thumb movement direction.
// It is important for the case, when JSlider
// is a cell editor in JTable. See 6348946.
currentMouseX = e.getX();
currentMouseY = e.getY();
if (slider.isRequestFocusEnabled()) {
}
// Clicked in the Thumb area?
&& !SwingUtilities.isLeftMouseButton(e)) {
return;
}
switch (slider.getOrientation()) {
break;
case JSlider.HORIZONTAL:
break;
}
isDragging = true;
return;
}
if (!SwingUtilities.isLeftMouseButton(e)) {
return;
}
isDragging = false;
slider.setValueIsAdjusting(true);
int direction = POSITIVE_SCROLL;
switch (slider.getOrientation()) {
if ( !drawInverted() ) {
}
else {
}
}
else {
if ( !drawInverted() ) {
}
else {
}
}
break;
case JSlider.HORIZONTAL:
if ( !drawInverted() ) {
}
else {
}
}
else {
if ( !drawInverted() ) {
}
else {
}
}
break;
}
if (shouldScroll(direction)) {
}
if (shouldScroll(direction)) {
scrollTimer.stop();
scrollTimer.start();
}
}
if (r.y <= currentMouseY) {
return false;
}
}
else if (r.y + r.height >= currentMouseY) {
return false;
}
}
else {
if (r.x + r.width >= currentMouseX) {
return false;
}
}
else if (r.x <= currentMouseX) {
return false;
}
}
slider.getMaximum()) {
return false;
}
slider.getMinimum()) {
return false;
}
return true;
}
/**
* of the thumb relative to the origin of the track.
*/
int thumbMiddle;
return;
}
currentMouseX = e.getX();
currentMouseY = e.getY();
if (!isDragging) {
return;
}
slider.setValueIsAdjusting(true);
switch (slider.getOrientation()) {
if (drawInverted()) {
trackBottom = vMax;
}
else {
}
break;
case JSlider.HORIZONTAL:
if (drawInverted()) {
}
else {
trackRight = hMax;
}
break;
}
}
}
/**
* Scroll-event listener.
*
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of <Foo>.
*/
// changed this class to public to avoid bogus IllegalAccessException
// bug in InternetExplorer browser. It was protected. Work around
// for 4109432
boolean useBlockIncrement;
public ScrollListener() {
useBlockIncrement = true;
}
}
}
this.useBlockIncrement = block;
}
if (useBlockIncrement) {
}
else {
}
}
}
}
/**
* Listener for resizing events.
* <p>
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of <Foo>.
*/
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().componentResized(e);
}
}
/**
* Focus-change listener.
* <p>
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of <Foo>.
*/
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
getHandler().focusGained(e);
}
getHandler().focusLost(e);
}
}
/**
* As of Java 2 platform v1.3 this undocumented class is no longer used.
* The recommended approach to creating bindings is to use a
* combination of an <code>ActionMap</code>, to contain the action,
* and an <code>InputMap</code> to contain the mapping from KeyStroke
* to action description. The InputMap is is usually described in the
* LookAndFeel tables.
* <p>
* Please refer to the key bindings specification for further details.
* <p>
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of <Foo>.
*/
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Actions. If you need to add
// new functionality add it to the Actions, but make sure this
// class calls into the Actions.
int dir;
boolean block;
}
}
public boolean isEnabled() {
boolean b = true;
}
return b;
}
}
/**
* A static version of the above.
*/
// NOTE: This class exists only for backward compatability. All
// its functionality has been moved into Actions. If you need to add
// new functionality add it to the Actions, but make sure this
// class calls into the Actions.
int dir;
boolean block;
}
return;
}
}
}
"positiveUnitIncrement";
"positiveBlockIncrement";
"negativeUnitIncrement";
"negativeBlockIncrement";
Actions() {
super(null);
}
super(name);
}
return;
}
if (POSITIVE_UNIT_INCREMENT == name) {
} else if (NEGATIVE_UNIT_INCREMENT == name) {
} else if (POSITIVE_BLOCK_INCREMENT == name) {
} else if (NEGATIVE_BLOCK_INCREMENT == name) {
} else if (MIN_SCROLL_INCREMENT == name) {
} else if (MAX_SCROLL_INCREMENT == name) {
}
}
boolean isBlock) {
if (invert) {
}
if (isBlock) {
} else {
}
} else { // MIN or MAX
if (invert) {
}
}
}
}
}