jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollbar.java
author serb
Fri, 22 May 2015 23:26:00 +0300
changeset 30948 0a0972d3b58d
parent 25859 3317bb8137f4
child 32865 f9cb6e427f9e
permissions -rw-r--r--
6587235: Incorrect javadoc: "no parameter" in 2d source code Reviewed-by: azvegint, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21278
diff changeset
     2
 * Copyright (c) 2003, 2013, 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: 3938
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: 3938
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: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
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 sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.awt.X11GraphicsConfig;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 715
diff changeset
    33
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
* A simple vertical scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
abstract class XScrollbar {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 715
diff changeset
    40
    private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XScrollbar");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     * The thread that asynchronously tells the scrollbar to scroll.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * @see #startScrolling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static XScrollRepeater scroller = new XScrollRepeater(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * The repeater that used for concurrent scrolling of the vertical and horizontal scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * And so there is not static keyword
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * See 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private XScrollRepeater i_scroller = new XScrollRepeater(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    // Thumb length is always >= MIN_THUMB_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private final static int MIN_THUMB_H = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static final int ARROW_IND = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    XScrollbarClient sb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    //Use set methods to set scrollbar parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private int val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private int min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private int max;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private int vis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private int line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private int page;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private boolean needsRepaint = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private boolean pressed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private boolean dragging = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    Polygon firstArrow, secondArrow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    int width, height; // Dimensions of the visible part of the parent window
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    int barWidth, barLength; // Rotation-independent values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                             // equal to (width, height) for vertical,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                             // rotated by 90 for horizontal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                             // That is, barLength is always the length between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                             // the tips of the arrows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    int arrowArea;     // The area reserved for the scroll arrows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    int alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public static final int ALIGNMENT_VERTICAL = 1, ALIGNMENT_HORIZONTAL = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    int mode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    Point thumbOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private Rectangle prevThumb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public XScrollbar(int alignment, XScrollbarClient sb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        this.sb = sb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        this.alignment = alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public boolean needsRepaint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        return needsRepaint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    void notifyValue(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        notifyValue(v, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    void notifyValue(int v, final boolean isAdjusting) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        if (v < min) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            v = min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        } else if (v > max - vis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            v = max - vis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        final int value = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        final int mode = this.mode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if ((sb != null) && ((value != val)||(!pressed))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            SunToolkit.executeOnEventHandlerThread(sb.getEventSource(), new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                        sb.notifyValue(XScrollbar.this, mode, value, isAdjusting);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                });
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
    abstract protected void rebuildArrows();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public void setSize(int width, int height) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   121
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   122
            log.finer("Setting scroll bar " + this + " size to " + width + "x" + height);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   123
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        this.width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        this.height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Creates oriented directed arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    protected Polygon createArrowShape(boolean vertical, boolean up) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        Polygon arrow = new Polygon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        // TODO: this should be done polymorphically in subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        // FIXME: arrows overlap the thumb for very wide scrollbars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (vertical) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            int x = width / 2 - getArrowWidth()/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            int y1 = (up ? ARROW_IND : barLength - ARROW_IND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            int y2 = (up ? getArrowWidth() : barLength - getArrowWidth() - ARROW_IND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            arrow.addPoint(x + getArrowWidth()/2, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            arrow.addPoint(x + getArrowWidth(), y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            arrow.addPoint(x, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            arrow.addPoint(x + getArrowWidth()/2, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            int y = height / 2 - getArrowWidth()/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            int x1 = (up ? ARROW_IND : barLength - ARROW_IND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            int x2 = (up ? getArrowWidth() : barLength - getArrowWidth() - ARROW_IND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            arrow.addPoint(x1, y + getArrowWidth()/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            arrow.addPoint(x2, y + getArrowWidth());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            arrow.addPoint(x2, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            arrow.addPoint(x1, y + getArrowWidth()/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return arrow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Gets the area of the scroll track
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    protected abstract Rectangle getThumbArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * paint the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @param g the graphics context to paint into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param colors the colors to use when painting the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param paintAll paint the whole scrollbar if true, just the thumb is false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    void paint(Graphics g, Color colors[], boolean paintAll) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   167
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   168
            log.finer("Painting scrollbar " + this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   169
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        boolean useBufferedImage = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        Graphics2D g2 = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        BufferedImage buffer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (!(g instanceof Graphics2D)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            // Fix for 5045936, 5055171. While printing, g is an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            //   of sun.print.ProxyPrintGraphics which extends Graphics.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            //   So we use a separate buffered image and its graphics is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            //   always Graphics2D instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            X11GraphicsConfig graphicsConfig = (X11GraphicsConfig)(sb.getEventSource().getGraphicsConfiguration());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            buffer = graphicsConfig.createCompatibleImage(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            g2 = buffer.createGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            useBufferedImage = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            g2 = (Graphics2D)g;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            Rectangle thumbRect = calculateThumbRect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
//              if (prevH == thumbH && prevY == thumbPosY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
//                  return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
//              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            prevThumb = thumbRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            // TODO: Share Motif colors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            Color back = colors[XComponentPeer.BACKGROUND_COLOR];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            Color selectColor = new Color(MotifColorUtilities.calculateSelectFromBackground(back.getRed(),back.getGreen(),back.getBlue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            Color darkShadow = new Color(MotifColorUtilities.calculateBottomShadowFromBackground(back.getRed(),back.getGreen(),back.getBlue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            Color lightShadow = new Color(MotifColorUtilities.calculateTopShadowFromBackground(back.getRed(),back.getGreen(),back.getBlue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                XlibWrapper.XFlush(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            /* paint the background slightly darker */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            if (paintAll) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                // fill the entire background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                g2.setColor(selectColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                if (alignment == ALIGNMENT_HORIZONTAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    g2.fillRect(0, 0, thumbRect.x, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    g2.fillRect(thumbRect.x + thumbRect.width , 0, width - (thumbRect.x + thumbRect.width), height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                    g2.fillRect(0, 0, width, thumbRect.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                    g2.fillRect(0, thumbRect.y + thumbRect.height, width, height - (thumbRect.y + thumbRect.height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                // Paint edges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                // TODO: Share Motif 3d rect drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                g2.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                g2.drawLine(0, 0, width-1, 0);           // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                g2.drawLine(0, 0, 0, height-1);          // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                g2.setColor(lightShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                g2.drawLine(1, height-1, width-1, height-1); // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                g2.drawLine(width-1, 1, width-1, height-1);  // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                // Clear all thumb area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                g2.setColor(selectColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                Rectangle thumbArea = getThumbArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                g2.fill(thumbArea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            if (paintAll) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                // ************ paint the arrows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                 paintArrows(g2, colors[XComponentPeer.BACKGROUND_COLOR], darkShadow, lightShadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            // Thumb
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            g2.setColor(colors[XComponentPeer.BACKGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            g2.fillRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            g2.setColor(lightShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            g2.drawLine(thumbRect.x, thumbRect.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                       thumbRect.x + thumbRect.width, thumbRect.y); // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            g2.drawLine(thumbRect.x, thumbRect.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                       thumbRect.x, thumbRect.y+thumbRect.height); // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            g2.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            g2.drawLine(thumbRect.x+1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                       thumbRect.y+thumbRect.height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                       thumbRect.x+thumbRect.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                       thumbRect.y+thumbRect.height);  // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            g2.drawLine(thumbRect.x+thumbRect.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                       thumbRect.y+1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                       thumbRect.x+thumbRect.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                       thumbRect.y+thumbRect.height); // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            if (useBufferedImage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                g2.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        if (useBufferedImage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            g.drawImage(buffer, 0, 0, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            XlibWrapper.XFlush(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
      void paintArrows(Graphics2D g, Color background, Color darkShadow, Color lightShadow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
          g.setColor(background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        // paint firstArrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (pressed && (mode == AdjustmentEvent.UNIT_DECREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            g.fill(firstArrow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            g.setColor(lightShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            g.drawLine(firstArrow.xpoints[0],firstArrow.ypoints[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                    firstArrow.xpoints[1],firstArrow.ypoints[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            g.drawLine(firstArrow.xpoints[1],firstArrow.ypoints[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                    firstArrow.xpoints[2],firstArrow.ypoints[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            g.drawLine(firstArrow.xpoints[2],firstArrow.ypoints[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                    firstArrow.xpoints[0],firstArrow.ypoints[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            g.fill(firstArrow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            g.drawLine(firstArrow.xpoints[0],firstArrow.ypoints[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                    firstArrow.xpoints[1],firstArrow.ypoints[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            g.drawLine(firstArrow.xpoints[1],firstArrow.ypoints[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                    firstArrow.xpoints[2],firstArrow.ypoints[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            g.setColor(lightShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            g.drawLine(firstArrow.xpoints[2],firstArrow.ypoints[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                    firstArrow.xpoints[0],firstArrow.ypoints[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        g.setColor(background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        // paint second Arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if (pressed && (mode == AdjustmentEvent.UNIT_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            g.fill(secondArrow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            g.setColor(lightShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            g.drawLine(secondArrow.xpoints[0],secondArrow.ypoints[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                    secondArrow.xpoints[1],secondArrow.ypoints[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            g.drawLine(secondArrow.xpoints[1],secondArrow.ypoints[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                    secondArrow.xpoints[2],secondArrow.ypoints[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            g.drawLine(secondArrow.xpoints[2],secondArrow.ypoints[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                    secondArrow.xpoints[0],secondArrow.ypoints[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
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            g.fill(secondArrow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            g.drawLine(secondArrow.xpoints[0],secondArrow.ypoints[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                    secondArrow.xpoints[1],secondArrow.ypoints[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            g.setColor(lightShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            g.drawLine(secondArrow.xpoints[1],secondArrow.ypoints[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                    secondArrow.xpoints[2],secondArrow.ypoints[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            g.drawLine(secondArrow.xpoints[2],secondArrow.ypoints[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    secondArrow.xpoints[0],secondArrow.ypoints[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * Tell the scroller to start scrolling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    void startScrolling() {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   340
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   341
            log.finer("Start scrolling on " + this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   342
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        // Make sure that we scroll at least once
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        scroll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        // wake up the scroll repeater
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        if (scroller == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            // If there isn't a scroller, then create
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            // one and start it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            scroller = new XScrollRepeater(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            scroller.setScrollbar(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        scroller.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Tell the instance scroller to start scrolling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * See 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    void startScrollingInstance() {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   362
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   363
            log.finer("Start scrolling on " + this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   364
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        // Make sure that we scroll at least once
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        scroll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        i_scroller.setScrollbar(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        i_scroller.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * Tell the instance scroller to stop scrolling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * See 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    void stopScrollingInstance() {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   377
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
16839
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   378
            log.finer("Stop scrolling on " + this);
d0f2e97b7359 8010297: Missing isLoggable() checks in logging code
anthony
parents: 5506
diff changeset
   379
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        i_scroller.stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * The set method for mode property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * See 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    public void setMode(int mode){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        this.mode = mode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * Scroll one unit.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   394
     * @see #notifyValue
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    void scroll() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        switch (mode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
          case AdjustmentEvent.UNIT_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
              notifyValue(val - line);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
              return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
          case AdjustmentEvent.UNIT_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
              notifyValue(val + line);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
              return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
          case AdjustmentEvent.BLOCK_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
              notifyValue(val - page);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
              return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
          case AdjustmentEvent.BLOCK_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
              notifyValue(val + page);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
              return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    boolean isInArrow(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        // Mouse is considered to be in the arrow if it is anywhere in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        // arrow area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        int coord = (alignment == ALIGNMENT_HORIZONTAL ? x : y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        int arrAreaH = getArrowAreaWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        if (coord < arrAreaH || coord > barLength - arrAreaH + 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * Is x,y in the scroll thumb?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * If we ever cache the thumb rect, we may need to clone the result of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * calculateThumbRect().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    boolean isInThumb(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        Rectangle thumbRect = calculateThumbRect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        // If the mouse is in the shadow of the thumb or the shadow of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        // scroll track, treat it as hitting the thumb.  So, slightly enlarge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        // our rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        thumbRect.x -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        thumbRect.width += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        thumbRect.height += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        return thumbRect.contains(x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    abstract boolean beforeThumb(int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @see java.awt.event.MouseEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * MouseEvent.MOUSE_CLICKED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * MouseEvent.MOUSE_PRESSED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * MouseEvent.MOUSE_RELEASED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * MouseEvent.MOUSE_MOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * MouseEvent.MOUSE_ENTERED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * MouseEvent.MOUSE_EXITED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * MouseEvent.MOUSE_DRAGGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    public void handleMouseEvent(int id, int modifiers, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        if ((modifiers & InputEvent.BUTTON1_MASK) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 16839
diff changeset
   465
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
             String type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
             switch (id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                case MouseEvent.MOUSE_PRESSED:
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   469
                    type = "press";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                case MouseEvent.MOUSE_RELEASED:
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   472
                    type = "release";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                case MouseEvent.MOUSE_DRAGGED:
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   475
                    type = "drag";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                default:
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   478
                    type = "other";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
             log.finer("Mouse " + type + " event in scroll bar " + this +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                                                   "x = " + x + ", y = " + y +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                                                   ", on arrow: " + isInArrow(x, y) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                                                   ", on thumb: " + isInThumb(x, y) + ", before thumb: " + beforeThumb(x, y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                                                   + ", thumb rect" + calculateThumbRect());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        switch (id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
          case MouseEvent.MOUSE_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
              if (isInArrow(x, y)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                  pressed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                  if (beforeThumb(x, y)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                      mode = AdjustmentEvent.UNIT_DECREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                      mode = AdjustmentEvent.UNIT_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                  sb.repaintScrollbarRequest(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                  startScrolling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
              if (isInThumb(x, y)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                  mode = AdjustmentEvent.TRACK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
              } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                  if (beforeThumb(x, y)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                      mode = AdjustmentEvent.BLOCK_DECREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                      mode = AdjustmentEvent.BLOCK_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                  startScrolling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
              Rectangle pos = calculateThumbRect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
              thumbOffset = new Point(x - pos.x, y - pos.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
          case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
              pressed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
              sb.repaintScrollbarRequest(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
              scroller.stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
              if(dragging){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                  handleTrackEvent(x, y, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                  dragging=false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
          case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
              dragging = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
              handleTrackEvent(x, y, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    private void handleTrackEvent(int x, int y, boolean isAdjusting){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        if (mode == AdjustmentEvent.TRACK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            notifyValue(calculateCursorOffset(x, y), isAdjusting);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    private int calculateCursorOffset(int x, int y){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        if (alignment == ALIGNMENT_HORIZONTAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            if (dragging)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                return Math.max(0,(int)((x - (thumbOffset.x + getArrowAreaWidth()))/getScaleFactor())) + min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                return Math.max(0,(int)((x - (getArrowAreaWidth()))/getScaleFactor())) + min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            if (dragging)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                return Math.max(0,(int)((y - (thumbOffset.y + getArrowAreaWidth()))/getScaleFactor())) + min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                return Math.max(0,(int)((y - (getArrowAreaWidth()))/getScaleFactor())) + min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
  private void updateNeedsRepaint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        Rectangle thumbRect = calculateThumbRect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (!prevThumb.equals(thumbRect)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            needsRepaint = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        prevThumb = thumbRect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * Sets the values for this Scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * This method enforces the same constraints as in java.awt.Scrollbar:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * <LI> The maximum must be greater than the minimum </LI>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18178
diff changeset
   565
     * <LI> The value must be greater than or equal to the minimum
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *      and less than or equal to the maximum minus the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     *      visible amount </LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * <LI> The visible amount must be greater than 1 and less than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *      to the difference between the maximum and minimum values. </LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * Values which do not meet these criteria are quietly coerced to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * appropriate boundary value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @param value is the position in the current window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * @param visible is the amount visible per page
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * @param minimum is the minimum value of the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @param maximum is the maximum value of the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    synchronized void setValues(int value, int visible, int minimum, int maximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        if (maximum <= minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            maximum = minimum + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        if (visible > maximum - minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            visible = maximum - minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        if (visible < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            visible = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        if (value < minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            value = minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        if (value > maximum - visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            value = maximum - visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        this.val = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        this.vis = visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        this.min = minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        this.max = maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * Sets param of this Scrollbar to the specified values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @param value is the position in the current window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @param visible is the amount visible per page
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @param minimum is the minimum value of the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * @param maximum is the maximum value of the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * @param unitSize is the unit size for increment or decrement of the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * @see #setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    synchronized void setValues(int value, int visible, int minimum, int maximum,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                                int unitSize, int blockSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        /* Use setValues so that a consistent policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
         * relating minimum, maximum, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        setValues(value, visible, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        setUnitIncrement(unitSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        setBlockIncrement(blockSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * Returns the current value of this Scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @see #getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @see #getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    int getValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        return val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Sets the value of this Scrollbar to the specified value.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   631
     * @param newValue the new value of the Scrollbar. If this value is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * below the current minimum or above the current maximum minus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * the visible amount, it becomes the new one of those values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * @see #getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    synchronized void setValue(int newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        /* Use setValues so that a consistent policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
         * relating minimum, maximum, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        setValues(newValue, vis, min, max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * Returns the minimum value of this Scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * @see #getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * @see #getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    int getMinimum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        return min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * Sets the minimum value for this Scrollbar.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   655
     * @param newMinimum the minimum value of the scrollbar
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    synchronized void setMinimum(int newMinimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        /* Use setValues so that a consistent policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
         * relating minimum, maximum, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        setValues(val, vis, newMinimum, max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * Returns the maximum value of this Scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * @see #getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @see #getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    int getMaximum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        return max;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * Sets the maximum value for this Scrollbar.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   675
     * @param newMaximum the maximum value of the scrollbar
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    synchronized void setMaximum(int newMaximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        /* Use setValues so that a consistent policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
         * relating minimum, maximum, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        setValues(val, vis, min, newMaximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * Returns the visible amount of this Scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    int getVisibleAmount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        return vis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * Sets the visible amount of this Scrollbar, which is the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * of values represented by the width of the scroll bar's bubble.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   694
     * @param newAmount the amount visible per page
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    synchronized void setVisibleAmount(int newAmount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        setValues(val, newAmount, min, max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * Sets the unit increment for this scrollbar. This is the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * that will be added (subtracted) when the user hits the unit down
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * (up) gadgets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @param unitSize is the unit size for increment or decrement of the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    synchronized void setUnitIncrement(int unitSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        line = unitSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * Gets the unit increment for this scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    int getUnitIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        return line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * Sets the block increment for this scrollbar. This is the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * that will be added (subtracted) when the user hits the block down
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * (up) gadgets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * @param blockSize is the block size for increment or decrement of the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    synchronized void setBlockIncrement(int blockSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        page = blockSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * Gets the block increment for this scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    int getBlockIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        return page;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * Width of the arrow image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    int getArrowWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        return getArrowAreaWidth() - 2*ARROW_IND;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * Width of the area reserved for arrow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    int getArrowAreaWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        return arrowArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    void calculateArrowWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        if (barLength < 2*barWidth + MIN_THUMB_H + 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            arrowArea = (barLength - MIN_THUMB_H + 2*ARROW_IND)/2 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            arrowArea = barWidth - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * Returns the scale factor for the thumbArea ( thumbAreaH / (max - min)).
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   759
     * @see #getArrowAreaWidth
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    private double getScaleFactor(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        double f = (double)(barLength - 2*getArrowAreaWidth()) / Math.max(1,(max - min));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        return f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * Method to calculate the scroll thumb's size and position.  This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * based on CalcSliderRect in ScrollBar.c of Motif source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * If we ever cache the thumb rect, we'll need to use a clone in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * isInThumb().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    protected Rectangle calculateThumbRect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        float range;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        float trueSize;  // Area of scroll track
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        float factor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        float slideSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        int minSliderWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        int minSliderHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        int hitTheWall = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        int arrAreaH = getArrowAreaWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        Rectangle retVal = new Rectangle(0,0,0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        trueSize = barLength - 2*arrAreaH - 1;  // Same if vert or horiz
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        if (alignment == ALIGNMENT_HORIZONTAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            minSliderWidth = MIN_THUMB_H ;  // Base on user-set vis?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            minSliderHeight = height - 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        else {  // Vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            minSliderWidth = width - 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            minSliderHeight = MIN_THUMB_H ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        // Total number of user units displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            range = max - min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        // A naive notion of pixels per user unit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            factor = trueSize / range;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            // A naive notion of the size of the slider in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            // in thermo, slider_size is 0 ans is ignored
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            slideSize = vis * factor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        if (alignment == ALIGNMENT_HORIZONTAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            // Simulating MAX_SCROLLBAR_DIMENSION macro
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            int localVal = (int) (slideSize + 0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            int localMin = minSliderWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            if (localVal > localMin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                retVal.width = localVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                retVal.width = localMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                hitTheWall = localMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            retVal.height = minSliderHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        else {  // Vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            retVal.width = minSliderWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            // Simulating MAX_SCROLLBAR_DIMENSION macro
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            int localVal = (int) (slideSize + 0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            int localMin = minSliderHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
            if (localVal > localMin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                retVal.height = localVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                retVal.height = localMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                hitTheWall = localMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        if (hitTheWall != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            trueSize -= hitTheWall;  // Actual pixels available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            range -= vis;            // Actual range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
            factor = trueSize / range;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        if (alignment == ALIGNMENT_HORIZONTAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                    retVal.x = ((int) (((((float) val)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                        - ((float) min)) * factor) + 0.5))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                        + arrAreaH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                    retVal.y = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            retVal.x = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                    retVal.y = ((int) (((((float) val)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                        - ((float) min)) * factor) + 0.5))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                        + arrAreaH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        // There was one final adjustment here in the Motif function, which was
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18178
diff changeset
   855
        // noted to be for backward-compatibility.  It has been left out for now.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        return retVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        return getClass() + "[" + width + "x" + height + "," + barWidth + "x" + barLength + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
class XScrollRepeater implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * Time to pause before the first scroll repeat.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    static int beginPause = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    // Reminder - make this a user definable property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * Time to pause between each scroll repeat.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    static int repeatPause = 100;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    // Reminder - make this a user definable property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     * The scrollbar that we sending scrolling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    XScrollbar sb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * newScroll gets reset when a new scrollbar gets set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    boolean newScroll;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    boolean shouldSkip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * Creates a new scroll repeater.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * @param sb the scrollbar that this thread will scroll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    XScrollRepeater(XScrollbar sb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        this.setScrollbar(sb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        newScroll = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    public void start() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        shouldSkip = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        XToolkit.schedule(this, beginPause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    public void stop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            shouldSkip = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        XToolkit.remove(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * Sets the scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * @param sb the scrollbar that this thread will scroll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    public synchronized void setScrollbar(XScrollbar sb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        this.sb = sb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        newScroll = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    public void run () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            if (shouldSkip) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        sb.scroll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        XToolkit.schedule(this, repeatPause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
}