jdk/src/share/classes/java/awt/geom/GeneralPath.java
author flar
Fri, 29 Apr 2011 10:58:33 -0700
changeset 9465 d336b679b605
parent 5506 202f599c92aa
permissions -rw-r--r--
6522514: Extending Arc2D.Double and serializing the object causes InvalidClassException Reviewed-by: prr
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) 1996, 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
package java.awt.geom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Shape;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The {@code GeneralPath} class represents a geometric path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * constructed from straight lines, and quadratic and cubic
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * (Bézier) curves.  It can contain multiple subpaths.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * {@code GeneralPath} is a legacy final class which exactly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * implements the behavior of its superclass {@link Path2D.Float}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Together with {@link Path2D.Double}, the {@link Path2D} classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * provide full implementations of a general geometric path that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * support all of the functionality of the {@link Shape} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * {@link PathIterator} interfaces with the ability to explicitly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * select different levels of internal coordinate precision.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Use {@code Path2D.Float} (or this legacy {@code GeneralPath}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * subclass) when dealing with data that can be represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * and used with floating point precision.  Use {@code Path2D.Double}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * for data that requires the accuracy or range of double precision.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @author Jim Graham
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public final class GeneralPath extends Path2D.Float {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Constructs a new empty single precision {@code GeneralPath} object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * with a default winding rule of {@link #WIND_NON_ZERO}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public GeneralPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        super(WIND_NON_ZERO, INIT_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Constructs a new <code>GeneralPath</code> object with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * winding rule to control operations that require the interior of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * path to be defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @param rule the winding rule
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @see #WIND_EVEN_ODD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @see #WIND_NON_ZERO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public GeneralPath(int rule) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        super(rule, INIT_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Constructs a new <code>GeneralPath</code> object with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * winding rule and the specified initial capacity to store path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * This number is an initial guess as to how many path segments
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * will be added to the path, but the storage is expanded as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * needed to store whatever path segments are added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param rule the winding rule
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param initialCapacity the estimate for the number of path segments
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *                        in the path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @see #WIND_EVEN_ODD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @see #WIND_NON_ZERO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public GeneralPath(int rule, int initialCapacity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        super(rule, initialCapacity);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Constructs a new <code>GeneralPath</code> object from an arbitrary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * {@link Shape} object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * All of the initial geometry and the winding rule for this path are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * taken from the specified <code>Shape</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param s the specified <code>Shape</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public GeneralPath(Shape s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        super(s, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    GeneralPath(int windingRule,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                byte[] pointTypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                int numTypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                float[] pointCoords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                int numCoords)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // used to construct from native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        this.windingRule = windingRule;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        this.pointTypes = pointTypes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        this.numTypes = numTypes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        this.floatCoords = pointCoords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        this.numCoords = numCoords;
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
     * JDK 1.6 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    private static final long serialVersionUID = -8327096662768731142L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
}