1 /*
   2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.awt.geom;
  27 
  28 /**
  29  * The {@code Dimension2D} class is to encapsulate a width
  30  * and a height dimension.
  31  * <p>
  32  * This class is only the abstract superclass for all objects that
  33  * store a 2D dimension.
  34  * The actual storage representation of the sizes is left to
  35  * the subclass.
  36  *
  37  * @author      Jim Graham
  38  * @since 1.2
  39  */
  40 public abstract class Dimension2D implements Cloneable {
  41 
  42     /**
  43      * This is an abstract class that cannot be instantiated directly.
  44      * Type-specific implementation subclasses are available for
  45      * instantiation and provide a number of formats for storing
  46      * the information necessary to satisfy the various accessor
  47      * methods below.
  48      *
  49      * @see java.awt.Dimension
  50      * @since 1.2
  51      */
  52     protected Dimension2D() {
  53     }
  54 
  55     /**
  56      * Returns the width of this {@code Dimension} in double
  57      * precision.
  58      * @return the width of this {@code Dimension}.
  59      * @since 1.2
  60      */
  61     public abstract double getWidth();
  62 
  63     /**
  64      * Returns the height of this {@code Dimension} in double
  65      * precision.
  66      * @return the height of this {@code Dimension}.
  67      * @since 1.2
  68      */
  69     public abstract double getHeight();
  70 
  71     /**
  72      * Sets the size of this {@code Dimension} object to the
  73      * specified width and height.
  74      * This method is included for completeness, to parallel the
  75      * {@link java.awt.Component#getSize getSize} method of
  76      * {@link java.awt.Component}.
  77      * @param width  the new width for the {@code Dimension}
  78      * object
  79      * @param height  the new height for the {@code Dimension}
  80      * object
  81      * @since 1.2
  82      */
  83     public abstract void setSize(double width, double height);
  84 
  85     /**
  86      * Sets the size of this {@code Dimension2D} object to
  87      * match the specified size.
  88      * This method is included for completeness, to parallel the
  89      * {@code getSize} method of {@code Component}.
  90      * @param d  the new size for the {@code Dimension2D}
  91      * object
  92      * @since 1.2
  93      */
  94     public void setSize(Dimension2D d) {
  95         setSize(d.getWidth(), d.getHeight());
  96     }
  97 
  98     /**
  99      * Creates a new object of the same class as this object.
 100      *
 101      * @return     a clone of this instance.
 102      * @exception  OutOfMemoryError            if there is not enough memory.
 103      * @see        java.lang.Cloneable
 104      * @since      1.2
 105      */
 106     public Object clone() {
 107         try {
 108             return super.clone();
 109         } catch (CloneNotSupportedException e) {
 110             // this shouldn't happen, since we are Cloneable
 111             throw new InternalError(e);
 112         }
 113     }
 114 }
--- EOF ---