jdk/src/share/classes/java/awt/geom/Dimension2D.java
author sherman
Tue, 30 Aug 2011 11:53:11 -0700
changeset 10419 12c063b39232
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
7084245: Update usages of InternalError to use exception chaining Summary: to use new InternalError constructor with cause chainning Reviewed-by: alanb, ksrini, xuelei, neugens Contributed-by: sebastian.sickelmann@gmx.de
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) 1997, 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
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The <code>Dimension2D</code> class is to encapsulate a width
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * and a height dimension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * This class is only the abstract superclass for all objects that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * store a 2D dimension.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * The actual storage representation of the sizes is left to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * the subclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @author      Jim Graham
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public abstract class Dimension2D implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * This is an abstract class that cannot be instantiated directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * Type-specific implementation subclasses are available for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * instantiation and provide a number of formats for storing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * the information necessary to satisfy the various accessor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * methods below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * @see java.awt.Dimension
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    protected Dimension2D() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Returns the width of this <code>Dimension</code> in double
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * precision.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @return the width of this <code>Dimension</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public abstract double getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Returns the height of this <code>Dimension</code> in double
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * precision.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @return the height of this <code>Dimension</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public abstract double getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Sets the size of this <code>Dimension</code> object to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * specified width and height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * This method is included for completeness, to parallel the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * {@link java.awt.Component#getSize getSize} method of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * {@link java.awt.Component}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @param width  the new width for the <code>Dimension</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @param height  the new height for the <code>Dimension</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public abstract void setSize(double width, double height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Sets the size of this <code>Dimension2D</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * match the specified size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * This method is included for completeness, to parallel the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * <code>getSize</code> method of <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param d  the new size for the <code>Dimension2D</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public void setSize(Dimension2D d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        setSize(d.getWidth(), d.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Creates a new object of the same class as this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @return     a clone of this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @exception  OutOfMemoryError            if there is not enough memory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @see        java.lang.Cloneable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @since      1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            return super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            // this shouldn't happen, since we are Cloneable
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
   111
            throw new InternalError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
}