aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/geom/RoundRectangle2D.java
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>2002-08-09 04:26:17 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2002-08-09 05:26:17 +0100
commit7bde45b2eb84502b62e77e46d947e46dcbd333d6 (patch)
treecdf9958b411887bead2263ea8ef0bdfc8eae6319 /libjava/java/awt/geom/RoundRectangle2D.java
parent097684ce62b505168739fc98e952f92a8719a1fa (diff)
downloadgcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.zip
gcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.tar.gz
gcc-7bde45b2eb84502b62e77e46d947e46dcbd333d6.tar.bz2
AWT/Swing merge from GNU Classpath.
From-SVN: r56147
Diffstat (limited to 'libjava/java/awt/geom/RoundRectangle2D.java')
-rw-r--r--libjava/java/awt/geom/RoundRectangle2D.java177
1 files changed, 88 insertions, 89 deletions
diff --git a/libjava/java/awt/geom/RoundRectangle2D.java b/libjava/java/awt/geom/RoundRectangle2D.java
index b518568..ec7e461 100644
--- a/libjava/java/awt/geom/RoundRectangle2D.java
+++ b/libjava/java/awt/geom/RoundRectangle2D.java
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation
+/* RoundRectangle2D.java -- represents a rectangle with rounded corners
+ Copyright (C) 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
@@ -43,10 +44,10 @@ package java.awt.geom;
public abstract class RoundRectangle2D extends RectangularShape
{
/** Return the arc height of this round rectangle. */
- public abstract double getArcHeight ();
+ public abstract double getArcHeight();
/** Return the arc width of this round rectangle. */
- public abstract double getArcWidth ();
+ public abstract double getArcWidth();
/** Set the values of this round rectangle
* @param x The x coordinate
@@ -56,13 +57,13 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param arcWidth The arc width
* @param arcHeight The arc height
*/
- public abstract void setRoundRect (double x, double y, double w, double h,
- double arcWidth, double arcHeight);
+ public abstract void setRoundRect(double x, double y, double w, double h,
+ double arcWidth, double arcHeight);
/** Create a RoundRectangle2D. This is protected because this class
* is abstract and cannot be instantiated.
*/
- protected RoundRectangle2D ()
+ protected RoundRectangle2D()
{
}
@@ -70,22 +71,22 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param x The x coordinate
* @param y The y coordinate
*/
- public boolean contains (double x, double y)
+ public boolean contains(double x, double y)
{
- double mx = getX ();
- double mw = getWidth ();
+ double mx = getX();
+ double mw = getWidth();
if (x < mx || x >= mx + mw)
return false;
- double my = getY ();
- double mh = getHeight ();
+ double my = getY();
+ double mh = getHeight();
if (y < my || y >= my + mh)
return false;
// Now check to see if the point is in range of an arc.
- double dy = Math.min (Math.abs (my - y), Math.abs (my + mh - y));
- double dx = Math.min (Math.abs (mx - x), Math.abs (mx + mw - x));
- double aw = getArcWidth ();
- double ah = getArcHeight ();
+ double dy = Math.min(Math.abs(my - y), Math.abs(my + mh - y));
+ double dx = Math.min(Math.abs(mx - x), Math.abs(mx + mw - x));
+ double aw = getArcWidth();
+ double ah = getArcHeight();
if (dx > aw || dy > ah)
return true;
@@ -105,18 +106,18 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param w The width
* @param h The height
*/
- public boolean contains (double x, double y, double w, double h)
+ public boolean contains(double x, double y, double w, double h)
{
// We have to check all four points here (for ordinary rectangles
// we can just check opposing corners).
- return (contains (x, y) && contains (x + w, h)
- && contains (x, y + h) && contains (x + w, y + h));
+ return (contains(x, y) && contains(x + w, h)
+ && contains(x, y + h) && contains(x + w, y + h));
}
/** Return a new path iterator which iterates over this rectangle.
* @param at An affine transform to apply to the object
*/
- public PathIterator getPathIterator (AffineTransform at)
+ public PathIterator getPathIterator(AffineTransform at)
{
// FIXME.
return null;
@@ -128,15 +129,15 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param w The width
* @param h The height
*/
- public boolean intersects (double x, double y, double w, double h)
+ public boolean intersects(double x, double y, double w, double h)
{
// Here we can use the same code we use for an ordinary rectangle.
- double mx = getX ();
- double mw = getWidth ();
+ double mx = getX();
+ double mw = getWidth();
if (x < mx || x >= mx + mw || x + w < mx || x + w >= mx + mw)
return false;
- double my = getY ();
- double mh = getHeight ();
+ double my = getY();
+ double mh = getHeight();
return y >= my && y < my + mh && y + h >= my && y + h < my + mh;
}
@@ -146,48 +147,47 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param w The width
* @param h The height
*/
- public void setFrame (double x, double y, double w, double h)
+ public void setFrame(double x, double y, double w, double h)
{
// This is a bit lame.
- setRoundRect (x, y, w, h, getArcWidth (), getArcHeight ());
+ setRoundRect(x, y, w, h, getArcWidth(), getArcHeight());
}
/** Set the values of this round rectangle to be the same as those
* of the argument.
* @param rr The round rectangle to copy
*/
- public void setRoundRect (RoundRectangle2D rr)
+ public void setRoundRect(RoundRectangle2D rr)
{
- setRoundRect (rr.getX (), rr.getY (), rr.getWidth (), rr.getHeight (),
- rr.getArcWidth (), rr.getArcHeight ());
+ setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(),
+ rr.getArcWidth(), rr.getArcHeight());
}
/** A subclass of RoundRectangle which keeps its parameters as
- * floats. */
- public static class Float extends RoundRectangle2D
+ * doubles. */
+ public static class Double extends RoundRectangle2D
{
/** The height of the corner arc. */
- public float archeight;
+ public double archeight;
/** The width of the corner arc. */
- public float arcwidth;
+ public double arcwidth;
/** The x coordinate of this object. */
- public float x;
+ public double x;
/** The y coordinate of this object. */
- public float y;
+ public double y;
/** The width of this object. */
- public float width;
+ public double width;
/** The height of this object. */
- public float height;
+ public double height;
/** Construct a new instance, with all parameters set to 0. */
- public Float ()
+ public Double()
{
- this (0, 0, 0, 0, 0, 0);
}
/** Construct a new instance with the given arguments.
@@ -198,8 +198,8 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param arcWidth The arc width
* @param arcHeight The arc height
*/
- public Float (float x, float y, float w, float h,
- float arcWidth, float arcHeight)
+ public Double(double x, double y, double w, double h,
+ double arcWidth, double arcHeight)
{
this.x = x;
this.y = y;
@@ -209,48 +209,48 @@ public abstract class RoundRectangle2D extends RectangularShape
this.archeight = arcHeight;
}
- public double getArcHeight ()
+ public double getArcHeight()
{
return archeight;
}
- public double getArcWidth ()
+ public double getArcWidth()
{
return arcwidth;
}
- public Rectangle2D getBounds2D ()
+ public Rectangle2D getBounds2D()
{
- return new Rectangle2D.Float (x, y, width, height);
+ return new Rectangle2D.Double(x, y, width, height);
}
- public double getX ()
+ public double getX()
{
return x;
}
- public double getY ()
+ public double getY()
{
return y;
}
- public double getWidth ()
+ public double getWidth()
{
return width;
}
- public double getHeight ()
+ public double getHeight()
{
return height;
}
- public boolean isEmpty ()
+ public boolean isEmpty()
{
return width <= 0 || height <= 0;
}
- public void setRoundRect (float x, float y, float w, float h,
- float arcWidth, float arcHeight)
+ public void setRoundRect(double x, double y, double w, double h,
+ double arcWidth, double arcHeight)
{
this.x = x;
this.y = y;
@@ -259,45 +259,33 @@ public abstract class RoundRectangle2D extends RectangularShape
this.arcwidth = arcWidth;
this.archeight = arcHeight;
}
-
- public void setRoundRect (double x, double y, double w, double h,
- double arcWidth, double arcHeight)
- {
- this.x = (float) x;
- this.y = (float) y;
- this.width = (float) w;
- this.height = (float) h;
- this.arcwidth = (float) arcWidth;
- this.archeight = (float) arcHeight;
- }
- }
+ } // class Double
/** A subclass of RoundRectangle which keeps its parameters as
- * doubles. */
- public static class Double extends RoundRectangle2D
+ * floats. */
+ public static class Float extends RoundRectangle2D
{
/** The height of the corner arc. */
- public double archeight;
+ public float archeight;
/** The width of the corner arc. */
- public double arcwidth;
+ public float arcwidth;
/** The x coordinate of this object. */
- public double x;
+ public float x;
/** The y coordinate of this object. */
- public double y;
+ public float y;
/** The width of this object. */
- public double width;
+ public float width;
/** The height of this object. */
- public double height;
+ public float height;
/** Construct a new instance, with all parameters set to 0. */
- public Double ()
+ public Float()
{
- this (0, 0, 0, 0, 0, 0);
}
/** Construct a new instance with the given arguments.
@@ -308,8 +296,8 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param arcWidth The arc width
* @param arcHeight The arc height
*/
- public Double (double x, double y, double w, double h,
- double arcWidth, double arcHeight)
+ public Float(float x, float y, float w, float h,
+ float arcWidth, float arcHeight)
{
this.x = x;
this.y = y;
@@ -319,48 +307,48 @@ public abstract class RoundRectangle2D extends RectangularShape
this.archeight = arcHeight;
}
- public double getArcHeight ()
+ public double getArcHeight()
{
return archeight;
}
- public double getArcWidth ()
+ public double getArcWidth()
{
return arcwidth;
}
- public Rectangle2D getBounds2D ()
+ public Rectangle2D getBounds2D()
{
- return new Rectangle2D.Double (x, y, width, height);
+ return new Rectangle2D.Float(x, y, width, height);
}
- public double getX ()
+ public double getX()
{
return x;
}
- public double getY ()
+ public double getY()
{
return y;
}
- public double getWidth ()
+ public double getWidth()
{
return width;
}
- public double getHeight ()
+ public double getHeight()
{
return height;
}
- public boolean isEmpty ()
+ public boolean isEmpty()
{
return width <= 0 || height <= 0;
}
- public void setRoundRect (double x, double y, double w, double h,
- double arcWidth, double arcHeight)
+ public void setRoundRect(float x, float y, float w, float h,
+ float arcWidth, float arcHeight)
{
this.x = x;
this.y = y;
@@ -369,5 +357,16 @@ public abstract class RoundRectangle2D extends RectangularShape
this.arcwidth = arcWidth;
this.archeight = arcHeight;
}
- }
-}
+
+ public void setRoundRect(double x, double y, double w, double h,
+ double arcWidth, double arcHeight)
+ {
+ this.x = (float) x;
+ this.y = (float) y;
+ this.width = (float) w;
+ this.height = (float) h;
+ this.arcwidth = (float) arcWidth;
+ this.archeight = (float) arcHeight;
+ }
+ } // class Float
+} // class RoundRectangle2D