gishur.gui2
Class EllipseShape

java.lang.Object
  |
  +--gishur.gui2.EllipseShape
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, Shape, java.awt.Shape

public class EllipseShape
extends java.lang.Object
implements Shape

An ellipse which implements the Shape interface.

Version:
1.0
Author:
Thomas Wolf

Field Summary
 int height
          The height of the oval's bounding box.
 int width
          The width of the oval's bounding box.
 int x
          The x coordinate of the oval's bounding box.
 int y
          The y coordinate of the oval's bounding box.
 
Constructor Summary
EllipseShape()
          Constructs a new EllipseShape, initialized to location (0,0) and size (0,0).
EllipseShape(int x, int y, int w, int h)
          Constructs and initializes an EllipseShape from the specified coordinates.
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class as this object.
 boolean contains(int x, int y)
          Tests if a specified point is inside the boundary of this EllipseShape.
 boolean contains(int x, int y, int w, int h)
          Tests if the interior of this EllipseShape entirely contains the specified rectangular area.
 boolean contains(java.awt.Point p)
          Tests if a specified Point is inside the boundary of the EllipseShape.
 void draw(java.awt.Graphics g)
          Strokes the outline of a Shape using the settings of the Graphics context (if visible).
 void fill(java.awt.Graphics g)
          Fills the interior of a Shape using the settings of the Graphics context (if visible).
 java.awt.Rectangle getBounds()
          Returns the bounding box of this EllipseShape.
 RectangleShape getBoundShape()
          Return the bounding box of the EllipseShape.
 java.awt.Point getCenter()
          Returns the center point of the framing rectangle of the EllipseShape.
 int getCenterX()
          Returns the X coordinate of the center of the framing rectangle of the EllipseShape.
 int getCenterY()
          Returns the Y coordinate of the center of the framing rectangle of the Shape.
 int getHeight()
          Returns the overall height of this EllipseShape.
 int getWidth()
          Returns the overall width of this EllipseShape.
 int getX()
          Returns the X coordinate of the upper left corner of this EllipseShape.
 int getY()
          Returns the Y coordinate of the upper left corner of this EllipseShape.
 boolean intersects(int x, int y, int w, int h)
          Tests if the interior of this EllipseShape intersects the interior of a specified rectangular area.
 boolean isEmpty()
          Determines whether or not the bounding box of this EllipseShape is empty.
 void set(int x, int y, int width, int height)
          Sets the EllipseShape to the specified values.
 void setFrame(int x, int y, int w, int h)
          Sets the location and size of this EllipseShape to the specified values.
 void setLocation(int x, int y)
          Moves the this Shape to the specified location.
 java.lang.String toString()
          Returns a string representation of the object.
 void translate(int dx, int dy)
          Translates this EllipseShape by the vector (x,y).
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getBounds2D, getPathIterator, getPathIterator, intersects, intersects
 

Field Detail

x

public int x
The x coordinate of the oval's bounding box.

y

public int y
The y coordinate of the oval's bounding box.

width

public int width
The width of the oval's bounding box.

height

public int height
The height of the oval's bounding box.
Constructor Detail

EllipseShape

public EllipseShape()
Constructs a new EllipseShape, initialized to location (0,0) and size (0,0).

EllipseShape

public EllipseShape(int x,
                    int y,
                    int w,
                    int h)
Constructs and initializes an EllipseShape from the specified coordinates.
Parameters:
x,y - the coordinates of the bounding rectangle
w - the width of the bounding rectangle
h - the height of the bounding rectangle
Method Detail

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

clone

public java.lang.Object clone()
Creates a new object of the same class as this object.
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

getX

public int getX()
Returns the X coordinate of the upper left corner of this EllipseShape.
Returns:
the X coordinate of the upper left corner of the bounding rectangle of this EllipseShape.

getY

public int getY()
Returns the Y coordinate of the upper left corner of this EllipseShape.
Returns:
the Y coordinate of the upper left corner of the bounding rectangle of this EllipseShape.

getWidth

public int getWidth()
Returns the overall width of this EllipseShape.
Returns:
the width of this EllipseShape.

getHeight

public int getHeight()
Returns the overall height of this EllipseShape.
Returns:
the height of this EllipseShape.

setFrame

public void setFrame(int x,
                     int y,
                     int w,
                     int h)
Sets the location and size of this EllipseShape to the specified values.
Parameters:
x, y - the specified coordinates to which to set the location of the bounding box
w - the specified width to which to set the width of this EllipseShape
h - the specified height to which to set the height of the EllipseShape

isEmpty

public boolean isEmpty()
Determines whether or not the bounding box of this EllipseShape is empty.
Returns:
true if the bounding rectangle of this EllipseShape is empty; false otherwise.

contains

public boolean contains(int x,
                        int y)
Tests if a specified point is inside the boundary of this EllipseShape.
Specified by:
contains in interface Shape
Parameters:
x, y - the coordinates to test
Returns:
true if the specified point is contained in this ellipse; false otherwise.

contains

public boolean contains(java.awt.Point p)
Tests if a specified Point is inside the boundary of the EllipseShape.
Specified by:
contains in interface Shape
Parameters:
p - a specified point
Returns:
true if the specified point is inside the boundary of the Shape; false otherwise.

intersects

public boolean intersects(int x,
                          int y,
                          int w,
                          int h)
Tests if the interior of this EllipseShape intersects the interior of a specified rectangular area.
Specified by:
intersects in interface Shape
Parameters:
x, y - the coordinates of the upper left corner of the specified rectangular area
w - the width of the specified rectangular area
h - the height of the specified rectangluar area
Returns:
true if this EllipseShape contains the specified rectangular area; false otherwise.

contains

public boolean contains(int x,
                        int y,
                        int w,
                        int h)
Tests if the interior of this EllipseShape entirely contains the specified rectangular area.
Specified by:
contains in interface Shape
Parameters:
x, y - the coordinates of the upper left corner of the specified rectangular area
w - the width of the specified rectangular area
h - the height of the specified rectangular area
Returns:
true if this EllipseShape contains the specified rectangular area; false otherwise.

getBounds

public java.awt.Rectangle getBounds()
Returns the bounding box of this EllipseShape.
Specified by:
getBounds in interface java.awt.Shape
Returns:
a Rectangle that is the bounding box of this EllipseShape.

getBoundShape

public RectangleShape getBoundShape()
Return the bounding box of the EllipseShape.
Specified by:
getBoundShape in interface Shape
Returns:
bounding box.

getCenterX

public int getCenterX()
Returns the X coordinate of the center of the framing rectangle of the EllipseShape.
Specified by:
getCenterX in interface Shape
Returns:
X coordinate of the shape

getCenterY

public int getCenterY()
Returns the Y coordinate of the center of the framing rectangle of the Shape.
Specified by:
getCenterY in interface Shape
Returns:
Y coordinate of the shape

getCenter

public java.awt.Point getCenter()
Returns the center point of the framing rectangle of the EllipseShape.
Specified by:
getCenter in interface Shape
Returns:
center point of the shape

translate

public void translate(int dx,
                      int dy)
Translates this EllipseShape by the vector (x,y).
Specified by:
translate in interface Shape
Parameters:
dx - x coordinate of the translation vector
dy - y coordinate of the translation vector

setLocation

public void setLocation(int x,
                        int y)
Moves the this Shape to the specified location.
Specified by:
setLocation in interface Shape
Parameters:
dx - x coordinate of point to move to
dy - y coordinate of point to move to

set

public void set(int x,
                int y,
                int width,
                int height)
Sets the EllipseShape to the specified values.
Parameters:
x,y - new position of the upper left corner of the bounding rectangle
width - new width of the bounding rectangle
height - new height of the bounding rectangle

draw

public void draw(java.awt.Graphics g)
Strokes the outline of a Shape using the settings of the Graphics context (if visible).
Specified by:
draw in interface Shape
Parameters:
g - Graphics context

fill

public void fill(java.awt.Graphics g)
Fills the interior of a Shape using the settings of the Graphics context (if visible).
Specified by:
fill in interface Shape
Parameters:
g - Graphics context