Added getMin/getMax/getCenter to f/d rectangular shape.

This commit is contained in:
Michael Bayne
2011-07-01 15:16:52 -07:00
parent 043e8fd2e2
commit d82f957f5c
5 changed files with 56 additions and 2 deletions
@@ -23,18 +23,27 @@ public interface IRectangularShape extends IShape
/** Returns the height of the framing rectangle. */ /** Returns the height of the framing rectangle. */
double getHeight (); double getHeight ();
/** Returns the minimum x,y-coordinate of the framing rectangle. */
Point getMin ();
/** Returns the minimum x-coordinate of the framing rectangle. */ /** Returns the minimum x-coordinate of the framing rectangle. */
double getMinX (); double getMinX ();
/** Returns the minimum y-coordinate of the framing rectangle. */ /** Returns the minimum y-coordinate of the framing rectangle. */
double getMinY (); double getMinY ();
/** Returns the maximum x,y-coordinate of the framing rectangle. */
Point getMax ();
/** Returns the maximum x-coordinate of the framing rectangle. */ /** Returns the maximum x-coordinate of the framing rectangle. */
double getMaxX (); double getMaxX ();
/** Returns the maximum y-coordinate of the framing rectangle. */ /** Returns the maximum y-coordinate of the framing rectangle. */
double getMaxY (); double getMaxY ();
/** Returns the center of the framing rectangle. */
Point getCenter ();
/** Returns the x-coordinate of the center of the framing rectangle. */ /** Returns the x-coordinate of the center of the framing rectangle. */
double getCenterX (); double getCenterX ();
@@ -80,6 +80,12 @@ public abstract class RectangularShape implements IRectangularShape
setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY()); setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY());
} }
@Override // from IRectangularShape
public Point getMin ()
{
return new Point(getMinX(), getMinY());
}
@Override // from IRectangularShape @Override // from IRectangularShape
public double getMinX () { public double getMinX () {
return getX(); return getX();
@@ -90,6 +96,12 @@ public abstract class RectangularShape implements IRectangularShape
return getY(); return getY();
} }
@Override // from IRectangularShape
public Point getMax ()
{
return new Point(getMaxX(), getMaxY());
}
@Override // from IRectangularShape @Override // from IRectangularShape
public double getMaxX () { public double getMaxX () {
return getX() + getWidth(); return getX() + getWidth();
@@ -100,6 +112,12 @@ public abstract class RectangularShape implements IRectangularShape
return getY() + getHeight(); return getY() + getHeight();
} }
@Override // from IRectangularShape
public Point getCenter ()
{
return new Point(getCenterX(), getCenterY());
}
@Override // from IRectangularShape @Override // from IRectangularShape
public double getCenterX () { public double getCenterX () {
return getX() + getWidth() / 2; return getX() + getWidth() / 2;
@@ -23,18 +23,27 @@ public interface IRectangularShape extends IShape
/** Returns the height of the framing rectangle. */ /** Returns the height of the framing rectangle. */
float getHeight (); float getHeight ();
/** Returns the minimum x,y-coordinate of the framing rectangle. */
Point getMin ();
/** Returns the minimum x-coordinate of the framing rectangle. */ /** Returns the minimum x-coordinate of the framing rectangle. */
float getMinX (); float getMinX ();
/** Returns the minimum y-coordinate of the framing rectangle. */ /** Returns the minimum y-coordinate of the framing rectangle. */
float getMinY (); float getMinY ();
/** Returns the maximum x,y-coordinate of the framing rectangle. */
Point getMax ();
/** Returns the maximum x-coordinate of the framing rectangle. */ /** Returns the maximum x-coordinate of the framing rectangle. */
float getMaxX (); float getMaxX ();
/** Returns the maximum y-coordinate of the framing rectangle. */ /** Returns the maximum y-coordinate of the framing rectangle. */
float getMaxY (); float getMaxY ();
/** Returns the center of the framing rectangle. */
Point getCenter ();
/** Returns the x-coordinate of the center of the framing rectangle. */ /** Returns the x-coordinate of the center of the framing rectangle. */
float getCenterX (); float getCenterX ();
@@ -80,6 +80,12 @@ public abstract class RectangularShape implements IRectangularShape
setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY()); setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY());
} }
@Override // from IRectangularShape
public Point getMin ()
{
return new Point(getMinX(), getMinY());
}
@Override // from IRectangularShape @Override // from IRectangularShape
public float getMinX () { public float getMinX () {
return getX(); return getX();
@@ -90,6 +96,12 @@ public abstract class RectangularShape implements IRectangularShape
return getY(); return getY();
} }
@Override // from IRectangularShape
public Point getMax ()
{
return new Point(getMaxX(), getMaxY());
}
@Override // from IRectangularShape @Override // from IRectangularShape
public float getMaxX () { public float getMaxX () {
return getX() + getWidth(); return getX() + getWidth();
@@ -100,6 +112,12 @@ public abstract class RectangularShape implements IRectangularShape
return getY() + getHeight(); return getY() + getHeight();
} }
@Override // from IRectangularShape
public Point getCenter ()
{
return new Point(getCenterX(), getCenterY());
}
@Override // from IRectangularShape @Override // from IRectangularShape
public float getCenterX () { public float getCenterX () {
return getX() + getWidth() / 2; return getX() + getWidth() / 2;
+2 -2
View File
@@ -42,12 +42,12 @@ public interface IRectangle extends IShape, Cloneable
int getMinY (); int getMinY ();
/** Returns the maximum x-coordinate of the framing rectangle. <em>Note:</em> this method /** Returns the maximum x-coordinate of the framing rectangle. <em>Note:</em> this method
* differs from its inting-point counterparts in that it considers {@code (x + width - 1)} to * differs from its floating-point counterparts in that it considers {@code (x + width - 1)} to
* be a rectangle's maximum x-coordinate. */ * be a rectangle's maximum x-coordinate. */
int getMaxX (); int getMaxX ();
/** Returns the maximum y-coordinate of the framing rectangle. <em>Note:</em> this method /** Returns the maximum y-coordinate of the framing rectangle. <em>Note:</em> this method
* differs from its inting-point counterparts in that it considers {@code (y + height - 1)} * differs from its floating-point counterparts in that it considers {@code (y + height - 1)}
* to be a rectangle's maximum x-coordinate. */ * to be a rectangle's maximum x-coordinate. */
int getMaxY (); int getMaxY ();