AWT/Swing merge from GNU Classpath.
From-SVN: r56147
This commit is contained in:
parent
097684ce62
commit
7bde45b2eb
490 changed files with 86038 additions and 9753 deletions
|
@ -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,130 +147,20 @@ 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 ());
|
||||
}
|
||||
|
||||
/** A subclass of RoundRectangle which keeps its parameters as
|
||||
* floats. */
|
||||
public static class Float extends RoundRectangle2D
|
||||
{
|
||||
/** The height of the corner arc. */
|
||||
public float archeight;
|
||||
|
||||
/** The width of the corner arc. */
|
||||
public float arcwidth;
|
||||
|
||||
/** The x coordinate of this object. */
|
||||
public float x;
|
||||
|
||||
/** The y coordinate of this object. */
|
||||
public float y;
|
||||
|
||||
/** The width of this object. */
|
||||
public float width;
|
||||
|
||||
/** The height of this object. */
|
||||
public float height;
|
||||
|
||||
/** Construct a new instance, with all parameters set to 0. */
|
||||
public Float ()
|
||||
{
|
||||
this (0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/** Construct a new instance with the given arguments.
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param w The width
|
||||
* @param h The height
|
||||
* @param arcWidth The arc width
|
||||
* @param arcHeight The arc height
|
||||
*/
|
||||
public Float (float x, float y, float w, float h,
|
||||
float arcWidth, float arcHeight)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.arcwidth = arcWidth;
|
||||
this.archeight = arcHeight;
|
||||
}
|
||||
|
||||
public double getArcHeight ()
|
||||
{
|
||||
return archeight;
|
||||
}
|
||||
|
||||
public double getArcWidth ()
|
||||
{
|
||||
return arcwidth;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D ()
|
||||
{
|
||||
return new Rectangle2D.Float (x, y, width, height);
|
||||
}
|
||||
|
||||
public double getX ()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY ()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getWidth ()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public double getHeight ()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public boolean isEmpty ()
|
||||
{
|
||||
return width <= 0 || height <= 0;
|
||||
}
|
||||
|
||||
public void setRoundRect (float x, float y, float w, float h,
|
||||
float arcWidth, float arcHeight)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
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;
|
||||
}
|
||||
setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(),
|
||||
rr.getArcWidth(), rr.getArcHeight());
|
||||
}
|
||||
|
||||
/** A subclass of RoundRectangle which keeps its parameters as
|
||||
|
@ -295,9 +186,8 @@ public abstract class RoundRectangle2D extends RectangularShape
|
|||
public double height;
|
||||
|
||||
/** Construct a new instance, with all parameters set to 0. */
|
||||
public Double ()
|
||||
public Double()
|
||||
{
|
||||
this (0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/** Construct a new instance with the given arguments.
|
||||
|
@ -308,8 +198,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 Double(double x, double y, double w, double h,
|
||||
double arcWidth, double arcHeight)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
@ -319,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.Double (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 (double x, double y, double w, double h,
|
||||
double arcWidth, double arcHeight)
|
||||
public void setRoundRect(double x, double y, double w, double h,
|
||||
double arcWidth, double arcHeight)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
@ -369,5 +259,114 @@ public abstract class RoundRectangle2D extends RectangularShape
|
|||
this.arcwidth = arcWidth;
|
||||
this.archeight = arcHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // class Double
|
||||
|
||||
/** A subclass of RoundRectangle which keeps its parameters as
|
||||
* floats. */
|
||||
public static class Float extends RoundRectangle2D
|
||||
{
|
||||
/** The height of the corner arc. */
|
||||
public float archeight;
|
||||
|
||||
/** The width of the corner arc. */
|
||||
public float arcwidth;
|
||||
|
||||
/** The x coordinate of this object. */
|
||||
public float x;
|
||||
|
||||
/** The y coordinate of this object. */
|
||||
public float y;
|
||||
|
||||
/** The width of this object. */
|
||||
public float width;
|
||||
|
||||
/** The height of this object. */
|
||||
public float height;
|
||||
|
||||
/** Construct a new instance, with all parameters set to 0. */
|
||||
public Float()
|
||||
{
|
||||
}
|
||||
|
||||
/** Construct a new instance with the given arguments.
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param w The width
|
||||
* @param h The height
|
||||
* @param arcWidth The arc width
|
||||
* @param arcHeight The arc height
|
||||
*/
|
||||
public Float(float x, float y, float w, float h,
|
||||
float arcWidth, float arcHeight)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.arcwidth = arcWidth;
|
||||
this.archeight = arcHeight;
|
||||
}
|
||||
|
||||
public double getArcHeight()
|
||||
{
|
||||
return archeight;
|
||||
}
|
||||
|
||||
public double getArcWidth()
|
||||
{
|
||||
return arcwidth;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D()
|
||||
{
|
||||
return new Rectangle2D.Float(x, y, width, height);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public double getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return width <= 0 || height <= 0;
|
||||
}
|
||||
|
||||
public void setRoundRect(float x, float y, float w, float h,
|
||||
float arcWidth, float arcHeight)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue