jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java
author serb
Mon, 07 Apr 2014 15:34:27 +0400
changeset 24163 d56df89854c4
parent 23715 54ae9dd9df73
child 25178 dbab904451e9
permissions -rw-r--r--
8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F Reviewed-by: pchelko, flar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
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
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    28
import java.awt.Color;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Dimension;
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    30
import java.awt.Graphics;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Rectangle;
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    32
import java.beans.PropertyChangeEvent;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    33
import java.beans.PropertyChangeListener;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    35
import javax.swing.JButton;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    36
import javax.swing.JComponent;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    37
import javax.swing.JScrollBar;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    38
import javax.swing.UIManager;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    39
import javax.swing.plaf.ComponentUI;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    40
import javax.swing.plaf.basic.BasicScrollBarUI;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    42
import static sun.swing.SwingUtilities2.drawHLine;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    43
import static sun.swing.SwingUtilities2.drawRect;
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
    44
import static sun.swing.SwingUtilities2.drawVLine;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Implementation of ScrollBarUI for the Metal Look and Feel
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
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public class MetalScrollBarUI extends BasicScrollBarUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static Color shadowColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static Color highlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static Color darkShadowColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private static Color thumbColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static Color thumbShadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static Color thumbHighlightColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    protected MetalBumps bumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    protected MetalScrollButton increaseButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected MetalScrollButton decreaseButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    protected  int scrollBarWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public static final String FREE_STANDING_PROP = "JScrollBar.isFreeStanding";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    protected boolean isFreeStanding = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static ComponentUI createUI( JComponent c )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return new MetalScrollBarUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        scrollBarWidth = ((Integer)(UIManager.get( "ScrollBar.width" ))).intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        super.installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        bumps = new MetalBumps( 10, 10, thumbHighlightColor, thumbShadow, thumbColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    protected void installListeners(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        super.installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        ((ScrollBarListener)propertyChangeListener).handlePropertyChange( scrollbar.getClientProperty( FREE_STANDING_PROP ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    protected PropertyChangeListener createPropertyChangeListener(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        return new ScrollBarListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    protected void configureScrollBarColors()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        super.configureScrollBarColors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        shadowColor         = UIManager.getColor("ScrollBar.shadow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        highlightColor      = UIManager.getColor("ScrollBar.highlight");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        darkShadowColor     = UIManager.getColor("ScrollBar.darkShadow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        thumbColor          = UIManager.getColor("ScrollBar.thumb");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        thumbShadow         = UIManager.getColor("ScrollBar.thumbShadow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public Dimension getPreferredSize( JComponent c )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        if ( scrollbar.getOrientation() == JScrollBar.VERTICAL )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            return new Dimension( scrollBarWidth, scrollBarWidth * 3 + 10 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        else  // Horizontal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            return new Dimension( scrollBarWidth * 3 + 10, scrollBarWidth );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /** Returns the view that represents the decrease view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    protected JButton createDecreaseButton( int orientation )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        decreaseButton = new MetalScrollButton( orientation, scrollBarWidth, isFreeStanding );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        return decreaseButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /** Returns the view that represents the increase view. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    protected JButton createIncreaseButton( int orientation )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        increaseButton =  new MetalScrollButton( orientation, scrollBarWidth, isFreeStanding );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return increaseButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    protected void paintTrack( Graphics g, JComponent c, Rectangle trackBounds )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        g.translate( trackBounds.x, trackBounds.y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        boolean leftToRight = MetalUtils.isLeftToRight(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        if ( scrollbar.getOrientation() == JScrollBar.VERTICAL )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                trackBounds.width += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                    g.translate( -1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            if ( c.isEnabled() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                g.setColor( darkShadowColor );
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   151
                drawVLine(g, 0, 0, trackBounds.height - 1);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   152
                drawVLine(g, trackBounds.width - 2, 0, trackBounds.height - 1);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   153
                drawHLine(g, 2, trackBounds.width - 1, trackBounds.height - 1);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   154
                drawHLine(g, 2, trackBounds.width - 2, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                g.setColor( shadowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                //      g.setColor( Color.red);
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   158
                drawVLine(g, 1, 1, trackBounds.height - 2);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   159
                drawHLine(g, 1, trackBounds.width - 3, 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                if (scrollbar.getValue() != scrollbar.getMaximum()) {  // thumb shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    int y = thumbRect.y + thumbRect.height - trackBounds.y;
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   162
                    drawHLine(g, 1, trackBounds.width - 1, y);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                g.setColor(highlightColor);
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   165
                drawVLine(g, trackBounds.width - 1, 0, trackBounds.height - 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                trackBounds.width -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    g.translate( 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        else  // HORIZONTAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                trackBounds.height += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            if ( c.isEnabled() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                g.setColor( darkShadowColor );
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   185
                drawHLine(g, 0, trackBounds.width - 1, 0);  // top
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   186
                drawVLine(g, 0, 2, trackBounds.height - 2); // left
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   187
                drawHLine(g, 0, trackBounds.width - 1, trackBounds.height - 2 ); // bottom
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   188
                drawVLine(g, trackBounds.width - 1, 2,  trackBounds.height - 1 ); // right
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                g.setColor( shadowColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                //      g.setColor( Color.red);
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   192
                drawHLine(g, 1, trackBounds.width - 2, 1 );  // top
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   193
                drawVLine(g, 1, 1, trackBounds.height - 3 ); // left
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   194
                drawHLine(g, 0, trackBounds.width - 1, trackBounds.height - 1 ); // bottom
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                if (scrollbar.getValue() != scrollbar.getMaximum()) {  // thumb shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    int x = thumbRect.x + thumbRect.width - trackBounds.x;
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   197
                    drawVLine(g, x, 1, trackBounds.height-1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                MetalUtils.drawDisabledBorder(g, 0, 0, trackBounds.width, trackBounds.height );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                trackBounds.height -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        g.translate( -trackBounds.x, -trackBounds.y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    protected void paintThumb( Graphics g, JComponent c, Rectangle thumbBounds )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        if (!c.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            oceanPaintThumb(g, c, thumbBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        boolean leftToRight = MetalUtils.isLeftToRight(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        g.translate( thumbBounds.x, thumbBounds.y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        if ( scrollbar.getOrientation() == JScrollBar.VERTICAL )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                thumbBounds.width += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                    g.translate( -1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            g.setColor( thumbColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            g.fillRect( 0, 0, thumbBounds.width - 2, thumbBounds.height - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            g.setColor( thumbShadow );
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   239
            drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            g.setColor( thumbHighlightColor );
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   242
            drawHLine(g, 1, thumbBounds.width - 3, 1);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   243
            drawVLine(g, 1, 1, thumbBounds.height - 2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            bumps.setBumpArea( thumbBounds.width - 6, thumbBounds.height - 7 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            bumps.paintIcon( c, g, 3, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                thumbBounds.width -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                if ( !leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                    g.translate( 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        else  // HORIZONTAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                thumbBounds.height += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            g.setColor( thumbColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            g.fillRect( 0, 0, thumbBounds.width - 1, thumbBounds.height - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            g.setColor( thumbShadow );
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   265
            drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            g.setColor( thumbHighlightColor );
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   268
            drawHLine(g, 1, thumbBounds.width - 3, 1);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   269
            drawVLine(g, 1, 1, thumbBounds.height - 3);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            bumps.setBumpArea( thumbBounds.width - 7, thumbBounds.height - 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            bumps.paintIcon( c, g, 4, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                thumbBounds.height -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        g.translate( -thumbBounds.x, -thumbBounds.y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    private void oceanPaintThumb(Graphics g, JComponent c,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                                   Rectangle thumbBounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        boolean leftToRight = MetalUtils.isLeftToRight(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        g.translate(thumbBounds.x, thumbBounds.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            if (!isFreeStanding) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                thumbBounds.width += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                if (!leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                    g.translate(-1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            if (thumbColor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                g.setColor(thumbColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                g.fillRect(0, 0, thumbBounds.width - 2,thumbBounds.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            g.setColor(thumbShadow);
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   302
            drawRect(g, 0, 0, thumbBounds.width - 2, thumbBounds.height - 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            g.setColor(thumbHighlightColor);
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   305
            drawHLine(g, 1, thumbBounds.width - 3, 1);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   306
            drawVLine(g, 1, 1, thumbBounds.height - 2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            MetalUtils.drawGradient(c, g, "ScrollBar.gradient", 2, 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                                    thumbBounds.width - 4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                                    thumbBounds.height - 3, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            int gripSize = thumbBounds.width - 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            if (gripSize > 2 && thumbBounds.height >= 10) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                int gripY = thumbBounds.height / 2 - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                for (int counter = 0; counter < 6; counter += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                    g.fillRect(4, counter + gripY, gripSize, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                gripY++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                for (int counter = 0; counter < 6; counter += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                    g.fillRect(5, counter + gripY, gripSize, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            if (!isFreeStanding) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                thumbBounds.width -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                if (!leftToRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                    g.translate(1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        else { // HORIZONTAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            if (!isFreeStanding) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                thumbBounds.height += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            if (thumbColor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                g.setColor(thumbColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                g.fillRect(0, 0, thumbBounds.width - 1,thumbBounds.height - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            g.setColor(thumbShadow);
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   344
            drawRect(g, 0, 0, thumbBounds.width - 1, thumbBounds.height - 2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            g.setColor(thumbHighlightColor);
24163
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   347
            drawHLine(g, 1, thumbBounds.width - 2, 1);
d56df89854c4 8032219: [macosx] Scrollbars looks bad under retina in Motif and Metal L&F
serb
parents: 23715
diff changeset
   348
            drawVLine(g, 1, 1, thumbBounds.height - 3);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            MetalUtils.drawGradient(c, g, "ScrollBar.gradient", 2, 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                                    thumbBounds.width - 3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                                    thumbBounds.height - 4, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            int gripSize = thumbBounds.height - 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            if (gripSize > 2 && thumbBounds.width >= 10) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                int gripX = thumbBounds.width / 2 - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                for (int counter = 0; counter < 6; counter += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                    g.fillRect(gripX + counter, 4, 1, gripSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                gripX++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                for (int counter = 0; counter < 6; counter += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                    g.fillRect(gripX + counter, 5, 1, gripSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            if (!isFreeStanding) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                thumbBounds.height -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        g.translate( -thumbBounds.x, -thumbBounds.y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    protected Dimension getMinimumThumbSize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return new Dimension( scrollBarWidth, scrollBarWidth );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
      * This is overridden only to increase the invalid area.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      * ensures that the "Shadow" below the thumb is invalidated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    protected void setThumbBounds(int x, int y, int width, int height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        /* If the thumbs bounds haven't changed, we're done.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        if ((thumbRect.x == x) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            (thumbRect.y == y) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            (thumbRect.width == width) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            (thumbRect.height == height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        /* Update thumbRect, and repaint the union of x,y,w,h and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
         * the old thumbRect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        int minX = Math.min(x, thumbRect.x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        int minY = Math.min(y, thumbRect.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        int maxX = Math.max(x + width, thumbRect.x + thumbRect.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        int maxY = Math.max(y + height, thumbRect.y + thumbRect.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        thumbRect.setBounds(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        scrollbar.repaint(minX, minY, (maxX - minX)+1, (maxY - minY)+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    class ScrollBarListener extends BasicScrollBarUI.PropertyChangeHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        public void propertyChange(PropertyChangeEvent e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            String name = e.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            if ( name.equals( FREE_STANDING_PROP ) )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                handlePropertyChange( e.getNewValue() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                super.propertyChange( e );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        public void handlePropertyChange( Object newValue )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            if ( newValue != null )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                boolean temp = ((Boolean)newValue).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                boolean becameFlush = temp == false && isFreeStanding == true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                boolean becameNormal = temp == true && isFreeStanding == false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                isFreeStanding = temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                if ( becameFlush ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                    toFlush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                else if ( becameNormal ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    toFreeStanding();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                if ( !isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                    isFreeStanding = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                    toFreeStanding();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                // This commented-out block is used for testing flush scrollbars.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                if ( isFreeStanding ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                    isFreeStanding = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                    toFlush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            if ( increaseButton != null )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                increaseButton.setFreeStanding( isFreeStanding );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            if ( decreaseButton != null )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                decreaseButton.setFreeStanding( isFreeStanding );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        protected void toFlush() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            scrollBarWidth -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        protected void toFreeStanding() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            scrollBarWidth += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    } // end class ScrollBarListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
}