1 |
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation |
/* Dimension2D.java -- abstraction of a dimension |
2 |
|
Copyright (C) 1999, 2000, 2002 Free Software Foundation |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
35 |
obligated to do so. If you do not wish to do so, delete this |
obligated to do so. If you do not wish to do so, delete this |
36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
38 |
|
|
39 |
package java.awt.geom; |
package java.awt.geom; |
40 |
|
|
41 |
/** |
/** |
42 |
|
* This stores a dimension in 2-dimensional space - a width (along the x-axis) |
43 |
|
* and height (along the y-axis). The storage is left to subclasses. |
44 |
|
* |
45 |
* @author Per Bothner <bothner@cygnus.com> |
* @author Per Bothner <bothner@cygnus.com> |
46 |
* @date February, 1999. |
* @author Eric Blake <ebb9@email.byu.edu> |
47 |
*/ |
* @since 1.2 |
48 |
|
* @status updated to 1.4 |
|
/* Written using online API docs for JDK 1.2 beta from http://www.javasoft.com. |
|
|
* Status: Believed complete and correct. |
|
49 |
*/ |
*/ |
|
|
|
50 |
public abstract class Dimension2D implements Cloneable |
public abstract class Dimension2D implements Cloneable |
51 |
{ |
{ |
52 |
|
/** |
53 |
|
* The default constructor. |
54 |
|
*/ |
55 |
|
protected Dimension2D() |
56 |
|
{ |
57 |
|
} |
58 |
|
|
59 |
|
/** |
60 |
|
* Get the width of this dimension. A negative result, while legal, is |
61 |
|
* undefined in meaning. |
62 |
|
* |
63 |
|
* @return the width |
64 |
|
*/ |
65 |
public abstract double getWidth(); |
public abstract double getWidth(); |
|
public abstract double getHeight(); |
|
66 |
|
|
67 |
public abstract void setSize (double width, double height); |
/** |
68 |
|
* Get the height of this dimension. A negative result, while legal, is |
69 |
|
* undefined in meaning. |
70 |
|
* |
71 |
|
* @return the height |
72 |
|
*/ |
73 |
|
public abstract double getHeight(); |
74 |
|
|
75 |
public void setSize (Dimension2D dim) |
/** |
76 |
|
* Set the size of this dimension to the requested values. Loss of precision |
77 |
|
* may occur. |
78 |
|
* |
79 |
|
* @param w the new width |
80 |
|
* @param h the new height |
81 |
|
*/ |
82 |
|
public abstract void setSize(double w, double h); |
83 |
|
|
84 |
|
/** |
85 |
|
* Set the size of this dimension to the requested value. Loss of precision |
86 |
|
* may occur. |
87 |
|
* |
88 |
|
* @param d the dimension containing the new values |
89 |
|
* @throws NullPointerException if d is null |
90 |
|
*/ |
91 |
|
public void setSize(Dimension2D d) |
92 |
{ |
{ |
93 |
setSize(dim.getWidth(), dim.getHeight()); |
setSize(d.getWidth(), d.getHeight()); |
94 |
} |
} |
95 |
|
|
96 |
public Object clone () |
/** |
97 |
|
* Create a new dimension of the same run-time type with the same contents |
98 |
|
* as this one. |
99 |
|
* |
100 |
|
* @return the clone |
101 |
|
*/ |
102 |
|
public Object clone() |
103 |
{ |
{ |
104 |
try |
try |
105 |
{ |
{ |
106 |
return super.clone (); |
return super.clone(); |
107 |
} |
} |
108 |
catch (CloneNotSupportedException _) {return null;} |
catch (CloneNotSupportedException e) |
109 |
} |
{ |
110 |
|
throw (Error) new InternalError().initCause(e); // Impossible |
111 |
protected Dimension2D () |
} |
|
{ |
|
112 |
} |
} |
113 |
} |
} // class Dimension2D |