home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 2.3 KB | 79 lines |
- /*
- * @(#)Dimension2D.java 1.4 98/03/18
- *
- * Copyright 1997, 1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- package java.awt.geom;
-
- /**
- * A class to encapsulate a width and a height Dimension.
- * <p>
- * This class is only the abstract superclass for all objects which
- * store a 2D dimension.
- * The actual storage representation of the sizes is left to
- * the subclass.
- *
- * @version 10 Feb 1997
- * @author Jim Graham
- */
- public abstract class Dimension2D implements Cloneable {
- protected Dimension2D() {
- }
-
- /**
- * Returns the width of this dimension in double precision.
- */
- public abstract double getWidth();
-
- /**
- * Returns the height of this dimension in double precision.
- */
- public abstract double getHeight();
-
- /**
- * Set the size of this Dimension object to the specified width
- * and height.
- * This method is included for completeness, to parallel the
- * getSize method of Component.
- * @param width the new width for the Dimension object
- * @param height the new height for the Dimension object
- */
- public abstract void setSize(double width, double height);
-
- /**
- * Set the size of this Dimension object to match the specified size.
- * This method is included for completeness, to parallel the
- * getSize method of Component.
- * @param d the new size for the Dimension object
- */
- public void setSize(Dimension2D d) {
- setSize(d.getWidth(), d.getHeight());
- }
-
- /**
- * Creates a new object of the same class as this object.
- *
- * @return a clone of this instance.
- * @exception OutOfMemoryError if there is not enough memory.
- * @see java.lang.Cloneable
- * @since JDK1.2
- */
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- // this shouldn't happen, since we are Cloneable
- throw new InternalError();
- }
- }
- }
-