jdk/src/share/classes/java/awt/font/ShapeGraphicAttribute.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * The original version of this source code and documentation is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * of IBM. These materials are provided under terms of a License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Agreement between Taligent and Sun. This technology is protected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * by multiple US and International patents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * This notice and attribution to Taligent may not be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Taligent is a registered trademark of Taligent, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
package java.awt.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.awt.Shape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.awt.Graphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.awt.Shape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.awt.geom.AffineTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.awt.geom.Rectangle2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The <code>ShapeGraphicAttribute</code> class is an implementation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * {@link GraphicAttribute} that draws shapes in a {@link TextLayout}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see GraphicAttribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public final class ShapeGraphicAttribute extends GraphicAttribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private Shape fShape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private boolean fStroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * A key indicating the shape should be stroked with a 1-pixel wide stroke.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public static final boolean STROKE = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * A key indicating the shape should be filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public static final boolean FILL = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    // cache shape bounds, since GeneralPath doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private Rectangle2D fShapeBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * Constructs a <code>ShapeGraphicAttribute</code> for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * {@link Shape}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @param shape the <code>Shape</code> to render.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * <code>Shape</code> is rendered with its origin at the origin of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * this <code>ShapeGraphicAttribute</code> in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * host <code>TextLayout</code>.  This object maintains a reference to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * <code>shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @param alignment one of the alignments from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param stroke <code>true</code> if the <code>Shape</code> should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * stroked; <code>false</code> if the <code>Shape</code> should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public ShapeGraphicAttribute(Shape shape,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                 int alignment,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                                 boolean stroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        super(alignment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        fShape = shape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        fStroke = stroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        fShapeBounds = fShape.getBounds2D();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Returns the ascent of this <code>ShapeGraphicAttribute</code>.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * ascent of a <code>ShapeGraphicAttribute</code> is the positive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * distance from the origin of its <code>Shape</code> to the top of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * bounds of its <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @return the ascent of this <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public float getAscent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        return (float) Math.max(0, -fShapeBounds.getMinY());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Returns the descent of this <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * The descent of a <code>ShapeGraphicAttribute</code> is the distance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * from the origin of its <code>Shape</code> to the bottom of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * bounds of its <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @return the descent of this <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public float getDescent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        return (float) Math.max(0, fShapeBounds.getMaxY());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Returns the advance of this <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * The advance of a <code>ShapeGraphicAttribute</code> is the distance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * from the origin of its <code>Shape</code> to the right side of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * bounds of its <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @return the advance of this <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public float getAdvance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        return (float) Math.max(0, fShapeBounds.getMaxX());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public void draw(Graphics2D graphics, float x, float y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // translating graphics to draw Shape !!!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        graphics.translate((int)x, (int)y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            if (fStroke == STROKE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                // REMIND: set stroke to correct size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                graphics.draw(fShape);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                graphics.fill(fShape);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            graphics.translate(-(int)x, -(int)y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * Returns a {@link Rectangle2D} that encloses all of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * bits drawn by this <code>ShapeGraphicAttribute</code> relative to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * the rendering position.  A graphic can be rendered beyond its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * origin, ascent, descent, or advance;  but if it does, this method's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * implementation should indicate where the graphic is rendered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @return a <code>Rectangle2D</code> that encloses all of the bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * rendered by this <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public Rectangle2D getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        Rectangle2D.Float bounds = new Rectangle2D.Float();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        bounds.setRect(fShapeBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (fStroke == STROKE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            ++bounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            ++bounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return bounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Return a {@link java.awt.Shape} that represents the region that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * this <code>ShapeGraphicAttribute</code> renders.  This is used when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * {@link TextLayout} is requested to return the outline of the text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * The (untransformed) shape must not extend outside the rectangular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * bounds returned by <code>getBounds</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @param tx an optional {@link AffineTransform} to apply to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *   this <code>ShapeGraphicAttribute</code>. This can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @return the <code>Shape</code> representing this graphic attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *   suitable for stroking or filling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public Shape getOutline(AffineTransform tx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        return tx == null ? fShape : tx.createTransformedShape(fShape);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Returns a hashcode for this <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @return  a hash code value for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return fShape.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * Compares this <code>ShapeGraphicAttribute</code> to the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * <code>Object</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @param rhs the <code>Object</code> to compare for equality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @return <code>true</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * <code>ShapeGraphicAttribute</code> equals <code>rhs</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public boolean equals(Object rhs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            return equals((ShapeGraphicAttribute) rhs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        catch(ClassCastException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            return false;
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Compares this <code>ShapeGraphicAttribute</code> to the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <code>ShapeGraphicAttribute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param rhs the <code>ShapeGraphicAttribute</code> to compare for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * equality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @return <code>true</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * <code>ShapeGraphicAttribute</code> equals <code>rhs</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public boolean equals(ShapeGraphicAttribute rhs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (rhs == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        if (this == rhs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        if (fStroke != rhs.fStroke) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (getAlignment() != rhs.getAlignment()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        if (!fShape.equals(rhs.fShape)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
}