jdk/src/share/classes/javax/swing/border/BevelBorder.java
author prr
Fri, 23 May 2014 09:05:24 -0700
changeset 24567 a0ebe5fd56ff
parent 24500 399b77799d66
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
     2
 * Copyright (c) 1997, 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
package javax.swing.border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.beans.ConstructorProperties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A class which implements a simple two-line bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 9035
diff changeset
    41
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
    47
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public class BevelBorder extends AbstractBorder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /** Raised bevel type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public static final int RAISED  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /** Lowered bevel type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public static final int LOWERED = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected int bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    protected Color highlightOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected Color highlightInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected Color shadowInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    protected Color shadowOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Creates a bevel border with the specified type and whose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * colors will be derived from the background color of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * component passed into the paintBorder method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public BevelBorder(int bevelType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        this.bevelType = bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Creates a bevel border with the specified type, highlight and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * shadow colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param highlight the color to use for the bevel highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param shadow the color to use for the bevel shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public BevelBorder(int bevelType, Color highlight, Color shadow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        this(bevelType, highlight.brighter(), highlight, shadow, shadow.brighter());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Creates a bevel border with the specified type, highlight and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * shadow colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param highlightOuterColor the color to use for the bevel outer highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @param highlightInnerColor the color to use for the bevel inner highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param shadowOuterColor the color to use for the bevel outer shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param shadowInnerColor the color to use for the bevel inner shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    @ConstructorProperties({"bevelType", "highlightOuterColor", "highlightInnerColor", "shadowOuterColor", "shadowInnerColor"})
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public BevelBorder(int bevelType, Color highlightOuterColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                       Color highlightInnerColor, Color shadowOuterColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                       Color shadowInnerColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        this(bevelType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this.highlightOuter = highlightOuterColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this.highlightInner = highlightInnerColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        this.shadowOuter = shadowOuterColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this.shadowInner = shadowInnerColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Paints the border for the specified component with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * position and size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param c the component for which this border is being painted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @param g the paint graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param x the x position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param y the y position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param width the width of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param height the height of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (bevelType == RAISED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
             paintRaisedBevel(c, g, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        } else if (bevelType == LOWERED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
             paintLoweredBevel(c, g, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Reinitialize the insets parameter with this Border's current Insets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param c the component for which this border insets value applies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @param insets the object to be reinitialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        insets.set(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Returns the outer highlight color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * when rendered on the specified component.  If no highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * color was specified at instantiation, the highlight color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * is derived from the specified component's background color.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   137
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param c the component for which the highlight may be derived
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   139
     * @return the outer highlight {@code Color}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public Color getHighlightOuterColor(Component c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        Color highlight = getHighlightOuterColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        return highlight != null? highlight :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                                       c.getBackground().brighter().brighter();
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
     * Returns the inner highlight color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * when rendered on the specified component.  If no highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * color was specified at instantiation, the highlight color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * is derived from the specified component's background color.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   153
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param c the component for which the highlight may be derived
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   155
     * @return the inner highlight {@code Color}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public Color getHighlightInnerColor(Component c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        Color highlight = getHighlightInnerColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return highlight != null? highlight :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                                       c.getBackground().brighter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * Returns the inner shadow color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * when rendered on the specified component.  If no shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * color was specified at instantiation, the shadow color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * is derived from the specified component's background color.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   169
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @param c the component for which the shadow may be derived
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   171
     * @return the inner shadow {@code Color}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public Color getShadowInnerColor(Component c)      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        Color shadow = getShadowInnerColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return shadow != null? shadow :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                    c.getBackground().darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Returns the outer shadow color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * when rendered on the specified component.  If no shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * color was specified at instantiation, the shadow color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * is derived from the specified component's background color.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   185
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param c the component for which the shadow may be derived
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   187
     * @return the outer shadow {@code Color}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public Color getShadowOuterColor(Component c)      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        Color shadow = getShadowOuterColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        return shadow != null? shadow :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                                    c.getBackground().darker().darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * Returns the outer highlight color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Will return null if no highlight color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * at instantiation.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   200
     *
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   201
     * @return the outer highlight {@code Color} or {@code null} if no highlight
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   202
     *         color was specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public Color getHighlightOuterColor()   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return highlightOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Returns the inner highlight color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Will return null if no highlight color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * at instantiation.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   213
     *
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   214
     * @return the inner highlight {@code Color} or {@code null} if no highlight
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   215
     *         color was specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public Color getHighlightInnerColor()   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return highlightInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Returns the inner shadow color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Will return null if no shadow color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * at instantiation.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   226
     *
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   227
     * @return the inner shadow {@code Color} or {@code null} if no shadow color
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   228
     *         was specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public Color getShadowInnerColor()      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return shadowInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Returns the outer shadow color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Will return null if no shadow color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * at instantiation.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   239
     *
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   240
     * @return the outer shadow {@code Color} or {@code null} if no shadow color
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   241
     *         was specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public Color getShadowOuterColor()      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return shadowOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * Returns the type of the bevel border.
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   250
     *
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   251
     * @return the bevel border type, either {@code RAISED} or {@code LOWERED}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public int getBevelType()       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /**
24500
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   258
     * Returns whether or not the border is opaque. This implementation
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   259
     * returns {@code true}.
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   260
     *
399b77799d66 8040893: Add block tags for @return and @param to swing border classes
yan
parents: 22574
diff changeset
   261
     * @return true
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public boolean isBorderOpaque() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    protected void paintRaisedBevel(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                    int width, int height)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        int h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        int w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        g.setColor(getHighlightOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        g.drawLine(0, 0, 0, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        g.drawLine(1, 0, w-2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        g.setColor(getHighlightInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        g.drawLine(1, 1, 1, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        g.drawLine(2, 1, w-3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        g.setColor(getShadowOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        g.drawLine(0, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        g.drawLine(w-1, 0, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        g.setColor(getShadowInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        g.drawLine(1, h-2, w-2, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        g.drawLine(w-2, 1, w-2, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    protected void paintLoweredBevel(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                                        int width, int height)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        int h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        int w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        g.setColor(getShadowInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        g.drawLine(0, 0, 0, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        g.drawLine(1, 0, w-1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        g.setColor(getShadowOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        g.drawLine(1, 1, 1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        g.drawLine(2, 1, w-2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        g.setColor(getHighlightOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        g.drawLine(1, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        g.drawLine(w-1, 1, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        g.setColor(getHighlightInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        g.drawLine(2, h-2, w-2, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        g.drawLine(w-2, 2, w-2, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
}