home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / geom / Dimension2D.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.3 KB  |  79 lines

  1. /*
  2.  * @(#)Dimension2D.java    1.4 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.geom;
  16.  
  17. /**
  18.  * A class to encapsulate a width and a height Dimension.
  19.  * <p>
  20.  * This class is only the abstract superclass for all objects which
  21.  * store a 2D dimension.
  22.  * The actual storage representation of the sizes is left to
  23.  * the subclass.
  24.  * 
  25.  * @version 10 Feb 1997
  26.  * @author    Jim Graham
  27.  */
  28. public abstract class Dimension2D implements Cloneable {
  29.     protected Dimension2D() {
  30.     }
  31.  
  32.     /**
  33.      * Returns the width of this dimension in double precision.
  34.      */
  35.     public abstract double getWidth();
  36.  
  37.     /**
  38.      * Returns the height of this dimension in double precision.
  39.      */
  40.     public abstract double getHeight();
  41.  
  42.     /**
  43.      * Set the size of this Dimension object to the specified width
  44.      * and height.
  45.      * This method is included for completeness, to parallel the
  46.      * getSize method of Component.
  47.      * @param width  the new width for the Dimension object
  48.      * @param height  the new height for the Dimension object
  49.      */
  50.     public abstract void setSize(double width, double height);
  51.  
  52.     /**
  53.      * Set the size of this Dimension object to match the specified size.
  54.      * This method is included for completeness, to parallel the
  55.      * getSize method of Component.
  56.      * @param d  the new size for the Dimension object
  57.      */
  58.     public void setSize(Dimension2D d) {
  59.     setSize(d.getWidth(), d.getHeight());
  60.     }
  61.  
  62.     /**
  63.      * Creates a new object of the same class as this object.
  64.      *
  65.      * @return     a clone of this instance.
  66.      * @exception  OutOfMemoryError            if there is not enough memory.
  67.      * @see        java.lang.Cloneable
  68.      * @since      JDK1.2
  69.      */
  70.     public Object clone() {
  71.     try {
  72.         return super.clone();
  73.     } catch (CloneNotSupportedException e) {
  74.         // this shouldn't happen, since we are Cloneable
  75.         throw new InternalError();
  76.     }
  77.     }
  78. }
  79.