001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2003-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2001, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.resources.geometry;
018:
019: // J2SE dependencies
020: import java.awt.geom.Dimension2D;
021: import java.io.Serializable;
022:
023: /**
024: * Implement float and double version of {@link Dimension2D}. This class
025: * is only temporary; it will disappear if <em>JavaSoft</em> implements
026: * {@code Dimension2D.Float} and {@code Dimension2D.Double}.
027: *
028: * @since 2.0
029: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/resources/geometry/XDimension2D.java $
030: * @version $Id: XDimension2D.java 20874 2006-08-07 10:00:01Z jgarnett $
031: * @author Martin Desruisseaux
032: */
033: public final class XDimension2D {
034: /**
035: * Do not allow instantiation of this class.
036: */
037: private XDimension2D() {
038: }
039:
040: /**
041: * Implement float version of {@link Dimension2D}. This class is
042: * temporary; it will disappear if <em>JavaSoft</em> implements
043: * {@code Dimension2D.Float} and {@code Dimension2D.Double}.
044: *
045: * @version $Id: XDimension2D.java 20874 2006-08-07 10:00:01Z jgarnett $
046: * @author Martin Desruisseaux
047: */
048: public static final class Float extends Dimension2D implements
049: Serializable {
050: /**
051: * The width.
052: */
053: public float width;
054:
055: /**
056: * The height.
057: */
058: public float height;
059:
060: /**
061: * Construct a new dimension initialized to (0,0).
062: */
063: public Float() {
064: }
065:
066: /**
067: * Construct a new dimension with the specified values.
068: *
069: * @param w The width.
070: * @param h The height.
071: */
072: public Float(final float w, final float h) {
073: width = w;
074: height = h;
075: }
076:
077: /**
078: * Set width and height for this dimension.
079: *
080: * @param w The width.
081: * @param h The height.
082: */
083: public void setSize(final double w, final double h) {
084: width = (float) w;
085: height = (float) h;
086: }
087:
088: /**
089: * Returns the width.
090: */
091: public double getWidth() {
092: return width;
093: }
094:
095: /**
096: * Returns the height.
097: */
098: public double getHeight() {
099: return height;
100: }
101:
102: /**
103: * Returns a string representation of this dimension.
104: */
105: public String toString() {
106: return "Dimension2D[" + width + ',' + height + ']';
107: }
108: }
109:
110: /**
111: * Implement double version of {@link Dimension2D}. This class is
112: * temporary; it will disappear if <em>JavaSoft</em> implements
113: * {@code Dimension2D.Float} and {@code Dimension2D.Double}.
114: *
115: * @version $Id: XDimension2D.java 20874 2006-08-07 10:00:01Z jgarnett $
116: * @author Martin Desruisseaux
117: */
118: public static final class Double extends Dimension2D implements
119: Serializable {
120: /**
121: * The width.
122: */
123: public double width;
124:
125: /**
126: * The height.
127: */
128: public double height;
129:
130: /**
131: * Construct a new dimension initialized to (0,0).
132: */
133: public Double() {
134: }
135:
136: /**
137: * Construct a new dimension with the specified values.
138: *
139: * @param w The width.
140: * @param h The height.
141: */
142: public Double(final double w, final double h) {
143: width = w;
144: height = h;
145: }
146:
147: /**
148: * Set width and height for this dimension.
149: *
150: * @param w The width.
151: * @param h The height.
152: */
153: public void setSize(final double w, final double h) {
154: width = w;
155: height = h;
156: }
157:
158: /**
159: * Returns the width.
160: */
161: public double getWidth() {
162: return width;
163: }
164:
165: /**
166: * Returns the height.
167: */
168: public double getHeight() {
169: return height;
170: }
171:
172: /**
173: * Returns a string representation of this dimension.
174: */
175: public String toString() {
176: return "Dimension2D[" + width + ',' + height + ']';
177: }
178: }
179: }
|