jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java
author yan
Mon, 30 Jun 2014 16:32:36 +0400
changeset 25178 dbab904451e9
parent 22574 7f8ce0c8c20a
permissions -rw-r--r--
8046434: Fix doclint warnings from javax.swing.plaf.metal package Reviewed-by: alexsch Contributed-by: Andrei Eremeev <andrei.eremeev@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
     2
 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.metal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Polygon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.plaf.basic.BasicArrowButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * JButton object for Metal scrollbar arrows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 5506
diff changeset
    46
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @author Tom Santos
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @author Steve Wilson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
    53
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
public class MetalScrollButton extends BasicArrowButton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  private static Color shadowColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  private static Color highlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  private boolean isFreeStanding = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  private int buttonWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    62
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    63
         * Constructs an instance of {@code MetalScrollButton}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    64
         *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    65
         * @param direction the direction
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    66
         * @param width the width
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    67
         * @param freeStanding the free standing value
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    68
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        public MetalScrollButton( int direction, int width, boolean freeStanding )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            super( direction );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            shadowColor = UIManager.getColor("ScrollBar.darkShadow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            highlightColor = UIManager.getColor("ScrollBar.highlight");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            buttonWidth = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            isFreeStanding = freeStanding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    80
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    81
         * Sets the free standing value.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    82
         *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    83
         * @param freeStanding the free standing value
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
    84
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        public void setFreeStanding( boolean freeStanding )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            isFreeStanding = freeStanding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        public void paint( Graphics g )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            boolean leftToRight = MetalUtils.isLeftToRight(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            boolean isEnabled = getParent().isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            Color arrowColor = isEnabled ? MetalLookAndFeel.getControlInfo() : MetalLookAndFeel.getControlDisabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            boolean isPressed = getModel().isPressed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            int width = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            int height = getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            int w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            int h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            int arrowHeight = (height+1) / 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            int arrowWidth = (height+1) / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            if ( isPressed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                g.setColor( MetalLookAndFeel.getControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                g.setColor( getBackground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            g.fillRect( 0, 0, width, height );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            if ( getDirection() == NORTH )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    height +=1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    g.translate( 0, -1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    width += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                    if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                        g.translate( -1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                // Draw the arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                g.setColor( arrowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                int startY = ((h+1) - arrowHeight) / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                int startX = (w / 2);
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
   130
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                for (int line = 0; line < arrowHeight; line++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                    g.drawLine( startX-line, startY+line, startX +line+1, startY+line);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    g.setColor( highlightColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                    if ( !isPressed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                        g.drawLine( 1, 1, width - 3, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                        g.drawLine( 1, 1, 1, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                    g.drawLine( width - 1, 1, width - 1, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                    g.setColor( shadowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                    g.drawLine( 0, 0, width - 2, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    g.drawLine( 0, 0, 0, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                    g.drawLine( width - 2, 2, width - 2, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                    MetalUtils.drawDisabledBorder(g, 0, 0, width, height+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                    height -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                    g.translate( 0, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    width -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                        g.translate( 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            else if ( getDirection() == SOUTH )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                    height += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    width += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                        g.translate( -1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                // Draw the arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                g.setColor( arrowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                int startY = (((h+1) - arrowHeight) / 2)+ arrowHeight-1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                int startX = (w / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                for (int line = 0; line < arrowHeight; line++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                    g.drawLine( startX-line, startY-line, startX +line+1, startY-line);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    g.setColor( highlightColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    if ( !isPressed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                        g.drawLine( 1, 0, width - 3, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        g.drawLine( 1, 0, 1, height - 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    g.drawLine( 1, height - 1, width - 1, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    g.drawLine( width - 1, 0, width - 1, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    g.setColor( shadowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    g.drawLine( 0, 0, 0, height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    g.drawLine( width - 2, 0, width - 2, height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    g.drawLine( 2, height - 2, width - 2, height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    MetalUtils.drawDisabledBorder(g, 0,-1, width, height+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                    height -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    width -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                        g.translate( 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            else if ( getDirection() == EAST )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    height += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    width += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                // Draw the arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                g.setColor( arrowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                int startX = (((w+1) - arrowHeight) / 2) + arrowHeight-1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                int startY = (h / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                for (int line = 0; line < arrowHeight; line++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                    g.drawLine( startX-line, startY-line, startX -line, startY+line+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                    g.setColor( highlightColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                    if ( !isPressed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                        g.drawLine( 0, 1, width - 3, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                        g.drawLine( 0, 1, 0, height - 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                    g.drawLine( width - 1, 1, width - 1, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                    g.drawLine( 0, height - 1, width - 1, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    g.setColor( shadowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    g.drawLine( 0, 0,width - 2, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                    g.drawLine( width - 2, 2, width - 2, height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                    g.drawLine( 0, height - 2, width - 2, height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                    MetalUtils.drawDisabledBorder(g,-1,0, width+1, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                    height -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                    width -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            else if ( getDirection() == WEST )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                    height += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                    width += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                    g.translate( -1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                // Draw the arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                g.setColor( arrowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                int startX = (((w+1) - arrowHeight) / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                int startY = (h / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                for (int line = 0; line < arrowHeight; line++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    g.drawLine( startX+line, startY-line, startX +line, startY+line+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                if (isEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                    g.setColor( highlightColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                    if ( !isPressed )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                        g.drawLine( 1, 1, width - 1, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                        g.drawLine( 1, 1, 1, height - 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                    g.drawLine( 1, height - 1, width - 1, height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                    g.setColor( shadowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                    g.drawLine( 0, 0, width - 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                    g.drawLine( 0, 0, 0, height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                    g.drawLine( 2, height - 2, width - 1, height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                    MetalUtils.drawDisabledBorder(g,0,0, width+1, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                    height -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                    width -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    g.translate( 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        public Dimension getPreferredSize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            if ( getDirection() == NORTH )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                return new Dimension( buttonWidth, buttonWidth - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            else if ( getDirection() == SOUTH )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                return new Dimension( buttonWidth, buttonWidth - (isFreeStanding ? 1 : 2) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            else if ( getDirection() == EAST )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                return new Dimension( buttonWidth - (isFreeStanding ? 1 : 2), buttonWidth );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            else if ( getDirection() == WEST )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                return new Dimension( buttonWidth - 2, buttonWidth );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                return new Dimension( 0, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        public Dimension getMinimumSize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            return getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        public Dimension getMaximumSize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            return new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
   332
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
   333
         * Returns the width of the button.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
   334
         *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
   335
         * @return the width of the button
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 22574
diff changeset
   336
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        public int getButtonWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            return buttonWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
}