java.lang.Objectobjectdraw.ObjectDrawObject
objectdraw.ObjectDrawShape
objectdraw.ObjectDrawRectangularShape
objectdraw.FilledOval
public class FilledOval
A FilledOval
is an oval filled in with some color. Like other
shapes that implement the Drawable2DInterface
, its shape is bounded by a top
left corner, plus a width and height.
Constructor Summary | |
---|---|
FilledOval(double x,
double y,
double width,
double height,
Color color,
DrawingCanvas canvas)
Construct an oval in a bounding rect starting at ( x , y ) at its
top left corner, and extending the given width and height from
there, filled in with the given color . |
|
FilledOval(double x,
double y,
double width,
double height,
DrawingCanvas canvas)
Construct an oval in a bounding rect starting at ( x , y ) at its
top left corner, and extending the given width and height from
there, filled in with black. |
|
FilledOval(Location point,
double width,
double height,
Color color,
DrawingCanvas canvas)
Construct an oval in a bounding rect with its top left corner at point
and extending the given width and height from there,
filled in with the given color . |
|
FilledOval(Location point,
double width,
double height,
DrawingCanvas canvas)
Construct an oval in a bounding rect with its top left corner at point
and extending the given width and height from there, filled
in with black. |
|
FilledOval(Location corner1,
Location corner2,
Color color,
DrawingCanvas canvas)
Construct an oval whose bounding rectangle stretches between corner1
and corner2 , filled in with the given color . |
|
FilledOval(Location corner1,
Location corner2,
DrawingCanvas canvas)
Construct an oval whose bounding rectangle stretches between corner1
and corner2 , filled in with black. |
Method Summary | |
---|---|
void |
addToCanvas(DrawingCanvas c)
Place this object on the specified canvas. |
boolean |
contains(Location point)
Return true if the given location is inside this object, false
otherwise. |
DrawingCanvas |
getCanvas()
Return the canvas that this object is on. |
Color |
getColor()
Return the color of this object |
double |
getDoubleHeight()
Return the height of the rectangle bounding this object, in double precision. |
double |
getDoubleWidth()
Return the height of the rectangle bounding this object, in double precision. |
double |
getDoubleX()
Get this object's x coordinate, in double precision. |
double |
getDoubleY()
Get this object's y coordinate, in double precision. |
int |
getHeight()
Return the width of the rectangle bounding this object. |
Location |
getLocation()
Get this object's location. |
int |
getWidth()
Return the height of the rectangle bounding this object. |
int |
getX()
Get this object's x coordinate. |
int |
getY()
Get this object's y coordinate. |
void |
hide()
Make this object invisible. |
boolean |
isHidden()
Return true if this object has been rendered invisible with a call to its
hide() method, false if it is still being drawn. |
void |
move(double dx,
double dy)
Shift (translate) this object left or right by an amount dx , and up or
down by an amount dy . |
void |
moveTo(double x,
double y)
Move the reference point of this object to the given location. |
void |
moveTo(Location point)
Move the reference point of this object to the given location. |
boolean |
overlaps(Drawable2DInterface other)
Return true if the rectangle bounding this object overlaps with the
rectangle bounding another object; false otherwise. |
void |
removeFromCanvas()
Remove this object from its canvas. |
void |
sendBackward()
Move this object one step backward in the draw order, causing it to be drawn underneath the objects that are in front of it. |
void |
sendForward()
Move this object one step forward in the draw order, causing it to be drawn on top of the objects that are behind it. |
void |
sendToBack()
Move this object to the very back of the draw order, causing it to be drawn underneath all the other objects. |
void |
sendToFront()
Move this object to the very front of the draw order, causing it to be drawn on top of all the other objects. |
void |
setColor(Color c)
Change the color of this object. |
void |
setHeight(double h)
Set the height of this object, leaving its top edge in place and stretching the bottom. |
void |
setSize(double width,
double height)
Set the width and height of this object. |
void |
setWidth(double w)
Set the width of this object, leaving its left edge in place and stretching the right. |
void |
show()
Make an object visible again after it had been hidden. |
String |
toString()
Return a string describing how this object might be constructed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FilledOval(double x, double y, double width, double height, Color color, DrawingCanvas canvas)
x
, y
) at its
top left corner, and extending the given width
and height
from
there, filled in with the given color
.
x
- x coordinate of the top left cornery
- y coordinate of the top left cornerwidth
- width of the ovalheight
- height of the ovalcolor
- Color
to draw the oval incanvas
- DrawingCanvas
on which to place the ovalpublic FilledOval(double x, double y, double width, double height, DrawingCanvas canvas)
x
, y
) at its
top left corner, and extending the given width
and height
from
there, filled in with black.
x
- x coordinate of the top left cornery
- y coordinate of the top left cornerwidth
- width of the ovalheight
- height of the ovalcanvas
- DrawingCanvas
on which to place the ovalpublic FilledOval(Location point, double width, double height, Color color, DrawingCanvas canvas)
point
and extending the given width
and height
from there,
filled in with the given color
.
point
- Location
of the top left cornerwidth
- width of the ovalheight
- height of the ovalcolor
- Color
to draw the oval incanvas
- DrawingCanvas
on which to place the ovalpublic FilledOval(Location point, double width, double height, DrawingCanvas canvas)
point
and extending the given width
and height
from there, filled
in with black.
point
- Location
of the top left cornerwidth
- width of the ovalheight
- height of the ovalcanvas
- DrawingCanvas
on which to place the ovalpublic FilledOval(Location corner1, Location corner2, Color color, DrawingCanvas canvas)
corner1
and corner2
, filled in with the given color
.
corner1
- Location
of one corner of the bounding rectanglecorner2
- Location
of the opposite corner of the bounding rectanglecolor
- Color
of the arccanvas
- DrawingCanvas
on which to place the arcpublic FilledOval(Location corner1, Location corner2, DrawingCanvas canvas)
corner1
and corner2
, filled in with black.
corner1
- Location
of one corner of the bounding rectanglecorner2
- Location
of the opposite corner of the bounding rectanglecanvas
- DrawingCanvas
on which to place the arcMethod Detail |
---|
public void addToCanvas(DrawingCanvas c)
null
the object is simply removed from its current canvas.
addToCanvas
in interface DrawableInterface
addToCanvas
in class objectdraw.ObjectDrawShape
c
- DrawingCanvas
to place this object onpublic boolean contains(Location point)
true
if the given location is inside this object, false
otherwise. Because Line
s and FramedArc
s have no "inside", a
point is considered to be contained in one of them as long as it is within a few pixels
of the line.
contains
in interface DrawableInterface
contains
in class objectdraw.ObjectDrawRectangularShape
point
- Location
to test
public DrawingCanvas getCanvas()
null
.
getCanvas
in interface DrawableInterface
getCanvas
in class objectdraw.ObjectDrawShape
DrawingCanvas
that this object is on.public Color getColor()
getColor
in interface DrawableInterface
getColor
in class objectdraw.ObjectDrawShape
Color
of this objectpublic double getDoubleHeight()
getDoubleHeight
in interface Drawable2DInterface
getDoubleHeight
in class objectdraw.ObjectDrawRectangularShape
public double getDoubleWidth()
getDoubleWidth
in interface Drawable2DInterface
getDoubleWidth
in class objectdraw.ObjectDrawRectangularShape
public double getDoubleX()
getDoubleX
in interface LocatableInterface
getDoubleX
in class objectdraw.ObjectDrawRectangularShape
public double getDoubleY()
getDoubleY
in interface LocatableInterface
getDoubleY
in class objectdraw.ObjectDrawRectangularShape
public int getHeight()
getHeight
in interface Drawable2DInterface
getHeight
in class objectdraw.ObjectDrawRectangularShape
public Location getLocation()
Location
object
will have the same effect as moving the object. So, the following two lines
of code are equivalent:
object.move(10, 20);
object.getLocation().translate(10, 20);
Location
offset by some
amount from the Location
of this object, without actually
moving this object, use the offset()
method in Location
,
which creates a new Location
.
getLocation
in interface LocatableInterface
getLocation
in class objectdraw.ObjectDrawRectangularShape
Location
of this object.public int getWidth()
getWidth
in interface Drawable2DInterface
getWidth
in class objectdraw.ObjectDrawRectangularShape
public int getX()
getX
in interface LocatableInterface
getX
in class objectdraw.ObjectDrawRectangularShape
public int getY()
getY
in interface LocatableInterface
getY
in class objectdraw.ObjectDrawRectangularShape
public void hide()
hide
in interface DrawableInterface
hide
in class objectdraw.ObjectDrawShape
public boolean isHidden()
true
if this object has been rendered invisible with a call to its
hide()
method, false
if it is still being drawn.
isHidden
in interface DrawableInterface
isHidden
in class objectdraw.ObjectDrawShape
public void move(double dx, double dy)
dx
, and up or
down by an amount dy
. A negative dx
indicates a shift to the
left; a negative dy
indicates a shift up
move
in interface DrawableInterface
move
in class objectdraw.ObjectDrawShape
dx
- amount of x translationdy
- amount of y translationpublic void moveTo(double x, double y)
moveTo
in interface DrawableInterface
moveTo
in class objectdraw.ObjectDrawShape
x
- x coordinate to move toy
- y coordinate to move topublic void moveTo(Location point)
moveTo
in interface DrawableInterface
moveTo
in class objectdraw.ObjectDrawShape
point
- Location
to move topublic boolean overlaps(Drawable2DInterface other)
true
if the rectangle bounding this object overlaps with the
rectangle bounding another object; false
otherwise.
overlaps
in interface Drawable2DInterface
overlaps
in class objectdraw.ObjectDrawRectangularShape
other
- another two dimensional object to check for overlapping with
public void removeFromCanvas()
removeFromCanvas
in interface DrawableInterface
removeFromCanvas
in class objectdraw.ObjectDrawShape
public void sendBackward()
sendBackward
in interface DrawableInterface
sendBackward
in class objectdraw.ObjectDrawShape
public void sendForward()
sendForward
in interface DrawableInterface
sendForward
in class objectdraw.ObjectDrawShape
public void sendToBack()
sendToBack
in interface DrawableInterface
sendToBack
in class objectdraw.ObjectDrawShape
public void sendToFront()
sendToFront
in interface DrawableInterface
sendToFront
in class objectdraw.ObjectDrawShape
public void setColor(Color c)
setColor
in interface DrawableInterface
setColor
in class objectdraw.ObjectDrawShape
c
- new Color
for this objectpublic void setHeight(double h)
setHeight
in interface Resizable2DInterface
setHeight
in class objectdraw.ObjectDrawRectangularShape
h
- new heightpublic void setSize(double width, double height)
setSize
in interface Resizable2DInterface
setSize
in class objectdraw.ObjectDrawRectangularShape
width
- new widthheight
- new heightpublic void setWidth(double w)
setWidth
in interface Resizable2DInterface
setWidth
in class objectdraw.ObjectDrawRectangularShape
w
- new widthpublic void show()
show
in interface DrawableInterface
show
in class objectdraw.ObjectDrawShape
public String toString()
toString
in class objectdraw.ObjectDrawObject