0N/A/*
2362N/A * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.java.swing.plaf.motif;
0N/A
0N/Aimport java.awt.*;
0N/Aimport java.awt.event.*;
0N/A
0N/Aimport javax.swing.*;
0N/Aimport javax.swing.event.*;
0N/Aimport javax.swing.plaf.*;
0N/A
0N/Aimport javax.swing.plaf.basic.BasicSliderUI;
0N/A
0N/A/**
0N/A * Motif Slider
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is appropriate
0N/A * for short term storage or RMI between applications running the same
0N/A * version of Swing. A future release of Swing will provide support for
0N/A * long term persistence.
0N/A *
0N/A * @author Jeff Dinkins
0N/A */
0N/Apublic class MotifSliderUI extends BasicSliderUI {
0N/A
0N/A static final Dimension PREFERRED_HORIZONTAL_SIZE = new Dimension(164, 15);
0N/A static final Dimension PREFERRED_VERTICAL_SIZE = new Dimension(15, 164);
0N/A
0N/A static final Dimension MINIMUM_HORIZONTAL_SIZE = new Dimension(43, 15);
0N/A static final Dimension MINIMUM_VERTICAL_SIZE = new Dimension(15, 43);
0N/A
0N/A /**
0N/A * MotifSliderUI Constructor
0N/A */
0N/A public MotifSliderUI(JSlider b) {
0N/A super(b);
0N/A }
0N/A
0N/A /**
0N/A * create a MotifSliderUI object
0N/A */
0N/A public static ComponentUI createUI(JComponent b) {
0N/A return new MotifSliderUI((JSlider)b);
0N/A }
0N/A
0N/A public Dimension getPreferredHorizontalSize() {
0N/A return PREFERRED_HORIZONTAL_SIZE;
0N/A }
0N/A
0N/A public Dimension getPreferredVerticalSize() {
0N/A return PREFERRED_VERTICAL_SIZE;
0N/A }
0N/A
0N/A public Dimension getMinimumHorizontalSize() {
0N/A return MINIMUM_HORIZONTAL_SIZE;
0N/A }
0N/A
0N/A public Dimension getMinimumVerticalSize() {
0N/A return MINIMUM_VERTICAL_SIZE;
0N/A }
0N/A
0N/A protected Dimension getThumbSize() {
0N/A if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
0N/A return new Dimension( 30, 15 );
0N/A }
0N/A else {
0N/A return new Dimension( 15, 30 );
0N/A }
0N/A }
0N/A
0N/A public void paintFocus(Graphics g) {
0N/A }
0N/A
0N/A public void paintTrack(Graphics g) {
0N/A }
0N/A
0N/A public void paintThumb(Graphics g) {
0N/A Rectangle knobBounds = thumbRect;
0N/A
0N/A int x = knobBounds.x;
0N/A int y = knobBounds.y;
0N/A int w = knobBounds.width;
0N/A int h = knobBounds.height;
0N/A
0N/A if ( slider.isEnabled() ) {
0N/A g.setColor(slider.getForeground());
0N/A }
0N/A else {
0N/A // PENDING(jeff) - the thumb should be dithered when disabled
0N/A g.setColor(slider.getForeground().darker());
0N/A }
0N/A
0N/A if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
0N/A g.translate(x, knobBounds.y-1);
0N/A
0N/A // fill
0N/A g.fillRect(0, 1, w, h - 1);
0N/A
0N/A // highlight
0N/A g.setColor(getHighlightColor());
0N/A g.drawLine(0, 1, w - 1, 1); // top
0N/A g.drawLine(0, 1, 0, h); // left
0N/A g.drawLine(w/2, 2, w/2, h-1); // center
0N/A
0N/A // shadow
0N/A g.setColor(getShadowColor());
0N/A g.drawLine(0, h, w - 1, h); // bottom
0N/A g.drawLine(w - 1, 1, w - 1, h); // right
0N/A g.drawLine(w/2 - 1, 2, w/2 - 1, h); // center
0N/A
0N/A g.translate(-x, -(knobBounds.y-1));
0N/A }
0N/A else {
0N/A g.translate(knobBounds.x-1, 0);
0N/A
0N/A // fill
0N/A g.fillRect(1, y, w - 1, h);
0N/A
0N/A // highlight
0N/A g.setColor(getHighlightColor());
0N/A g.drawLine(1, y, w, y); // top
0N/A g.drawLine(1, y+1, 1, y+h-1); // left
0N/A g.drawLine(2, y+h/2, w-1, y+h/2); // center
0N/A
0N/A // shadow
0N/A g.setColor(getShadowColor());
0N/A g.drawLine(2, y+h-1, w, y+h-1); // bottom
0N/A g.drawLine(w, y+h-1, w, y); // right
0N/A g.drawLine(2, y+h/2-1, w-1, y+h/2-1); // center
0N/A
0N/A g.translate(-(knobBounds.x-1), 0);
0N/A }
0N/A }
0N/A}