KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > geom > Dimension2D


1 /*
2  * @(#)Dimension2D.java 1.13 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.awt.geom;
9
10 /**
11  * The <code>Dimension2D</code> class is to encapsulate a width
12  * and a height dimension.
13  * <p>
14  * This class is only the abstract superclass for all objects that
15  * store a 2D dimension.
16  * The actual storage representation of the sizes is left to
17  * the subclass.
18  *
19  * @version 1.13, 12/19/03
20  * @author Jim Graham
21  */

22 public abstract class Dimension2D implements Cloneable JavaDoc {
23     /**
24      * This is an abstract class that cannot be instantiated directly.
25      * Type-specific implementation subclasses are available for
26      * instantiation and provide a number of formats for storing
27      * the information necessary to satisfy the various accessor
28      * methods below.
29      *
30      * @see java.awt.Dimension
31      */

32     protected Dimension2D() {
33     }
34
35     /**
36      * Returns the width of this <code>Dimension</code> in double
37      * precision.
38      * @return the width of this <code>Dimension</code>.
39      */

40     public abstract double getWidth();
41
42     /**
43      * Returns the height of this <code>Dimension</code> in double
44      * precision.
45      * @return the height of this <code>Dimension</code>.
46      */

47     public abstract double getHeight();
48
49     /**
50      * Sets the size of this <code>Dimension</code> object to the
51      * specified width and height.
52      * This method is included for completeness, to parallel the
53      * {@link java.awt.Component#getSize getSize} method of
54      * {@link java.awt.Component}.
55      * @param width the new width for the <code>Dimension</code>
56      * object
57      * @param height the new height for the <code>Dimension</code>
58      * object
59      */

60     public abstract void setSize(double width, double height);
61
62     /**
63      * Sets the size of this <code>Dimension2D</code> object to
64      * match the specified size.
65      * This method is included for completeness, to parallel the
66      * <code>getSize</code> method of <code>Component</code>.
67      * @param d the new size for the <code>Dimension2D</code>
68      * object
69      */

70     public void setSize(Dimension2D JavaDoc d) {
71     setSize(d.getWidth(), d.getHeight());
72     }
73
74     /**
75      * Creates a new object of the same class as this object.
76      *
77      * @return a clone of this instance.
78      * @exception OutOfMemoryError if there is not enough memory.
79      * @see java.lang.Cloneable
80      * @since 1.2
81      */

82     public Object JavaDoc clone() {
83     try {
84         return super.clone();
85     } catch (CloneNotSupportedException JavaDoc e) {
86         // this shouldn't happen, since we are Cloneable
87
throw new InternalError JavaDoc();
88     }
89     }
90 }
91
Popular Tags