java.lang.Objectobjectdraw.ObjectDrawObject
objectdraw.ObjectDrawShape
objectdraw.ObjectDrawRectangularShape
objectdraw.FramedArc
public class FramedArc
A FramedArc
is a curved line that forms some portion of an oval. Like other
shapes that implement the Drawable2DInterface
, its shape is bounded by a top
left corner, plus a width and height; these specify the size of the oval it is cut out of,
not the space taken up by the arc itself. In addition, it has an angle in degrees specifying
at what angle the arc starts, and another saying how many degrees from there the arc extends.
Field Summary |
---|
Fields inherited from interface objectdraw.DrawableStrokeInterface |
---|
CLICK_SIZE, DEFAULT_STROKE |
Constructor Summary | |
---|---|
FramedArc(double x,
double y,
double width,
double height,
double startAngle,
double arcAngle,
Color color,
DrawingCanvas canvas)
Construct a FramedArc whose bounding rectangle has its top left corner at
(x , y ) and extends the given width and
height from there. |
|
FramedArc(double x,
double y,
double width,
double height,
double startAngle,
double arcAngle,
DrawingCanvas canvas)
Construct a FramedArc whose bounding rectangle has its top left corner at
(x , y ) and extends the given width and
height from there. |
|
FramedArc(Location point,
double width,
double height,
double startAngle,
double arcAngle,
Color color,
DrawingCanvas canvas)
Construct a FramedArc whose bounding rectangle has its top left corner at
point and extends the given width and
height from there. |
|
FramedArc(Location point,
double width,
double height,
double startAngle,
double arcAngle,
DrawingCanvas canvas)
Construct a FramedArc whose bounding rectangle has its top left corner at
point and extends the given width and
height from there. |
|
FramedArc(Location corner1,
Location corner2,
double startAngle,
double arcAngle,
Color color,
DrawingCanvas canvas)
Construct a FramedArc whose bounding rectangle stretches between corner1
and corner2 . |
|
FramedArc(Location corner1,
Location corner2,
double startAngle,
double arcAngle,
DrawingCanvas canvas)
Construct a FramedArc whose bounding rectangle stretches between corner1
and corner2 . |
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. |
double |
getArcAngle()
Return the angular extent of the arc, in degrees. |
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. |
double |
getLineWidth()
Return the width of this object's lines. |
Location |
getLocation()
Get this object's location. |
double |
getStartAngle()
Get the angle at which the arc starts, in degrees. |
BasicStroke |
getStroke()
Return the stroke used for this object's lines. |
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 |
setArcAngle(double a)
Set the angular length of the arc, in degrees. |
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 |
setLineWidth(double width)
Set the width of this object's lines |
void |
setSize(double width,
double height)
Set the width and height of this object. |
void |
setStartAngle(double a)
Set the start angle of the arc, in degrees. |
void |
setStroke(BasicStroke stroke)
Set the stroke used for this object's lines |
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 FramedArc(double x, double y, double width, double height, double startAngle, double arcAngle, Color color, DrawingCanvas canvas)
FramedArc
whose bounding rectangle has its top left corner at
(x
, y
) and extends the given width
and
height
from there. The arc will start at startAngle
, given in
degrees in the usual angle system, so that 0 is east, Math.PI / 2
is north,
and so on; it will extend arcAngle
degrees from there. The sign of
arcAngle
determines which way the arc goes from startAngle
;
a negative sign means that the arc extends clockwise, whereas a positive sign means
that it extends counterclockwise.
x
- x coordinate of top left corner of bounding rectangley
- y coordinate of top left corner of bounding rectanglewidth
- width of bounding rectangleheight
- height of bounding rectanglestartAngle
- start angle, in degreesarcAngle
- arc angle, in degreescolor
- Color
of the arccanvas
- DrawingCanvas
on which to place the arcpublic FramedArc(double x, double y, double width, double height, double startAngle, double arcAngle, DrawingCanvas canvas)
FramedArc
whose bounding rectangle has its top left corner at
(x
, y
) and extends the given width
and
height
from there. The arc will start at startAngle
, given in
degrees in the usual angle system, so that 0 is east, Math.PI / 2
is north,
and so on; it will extend arcAngle
degrees from there. The sign of
arcAngle
determines which way the arc goes from startAngle
;
a negative sign means that the arc extends clockwise, whereas a positive sign means
that it extends counterclockwise.
x
- x coordinate of top left corner of bounding rectangley
- y coordinate of top left corner of bounding rectanglewidth
- width of bounding rectangleheight
- height of bounding rectanglestartAngle
- start angle, in degreesarcAngle
- arc angle, in degreescanvas
- DrawingCanvas
on which to place the arcpublic FramedArc(Location point, double width, double height, double startAngle, double arcAngle, Color color, DrawingCanvas canvas)
FramedArc
whose bounding rectangle has its top left corner at
point
and extends the given width
and
height
from there. The arc will start at startAngle
, given in
degrees in the usual angle system, so that 0 is east, Math.PI / 2
is north,
and so on; it will extend arcAngle
degrees from there. The sign of
arcAngle
determines which way the arc goes from startAngle
;
a negative sign means that the arc extends clockwise, whereas a positive sign means
that it extends counterclockwise.
point
- Location
of the top left corner of the bounding rectanglewidth
- width of bounding rectangleheight
- height of bounding rectanglestartAngle
- start angle, in degreesarcAngle
- arc angle, in degreescolor
- Color
of the arccanvas
- DrawingCanvas
on which to place the arcpublic FramedArc(Location point, double width, double height, double startAngle, double arcAngle, DrawingCanvas canvas)
FramedArc
whose bounding rectangle has its top left corner at
point
and extends the given width
and
height
from there. The arc will start at startAngle
, given in
degrees in the usual angle system, so that 0 is east, Math.PI / 2
is north,
and so on; it will extend arcAngle
degrees from there. The sign of
arcAngle
determines which way the arc goes from startAngle
;
a negative sign means that the arc extends clockwise, whereas a positive sign means
that it extends counterclockwise.
point
- Location
of the top left corner of the bounding rectanglewidth
- width of bounding rectangleheight
- height of bounding rectanglestartAngle
- start angle, in degreesarcAngle
- arc angle, in degreescanvas
- DrawingCanvas
on which to place the arcpublic FramedArc(Location corner1, Location corner2, double startAngle, double arcAngle, Color color, DrawingCanvas canvas)
FramedArc
whose bounding rectangle stretches between corner1
and corner2
. The arc will start at startAngle
, given in
degrees in the usual angle system, so that 0 is east, Math.PI / 2
is north,
and so on; it will extend arcAngle
degrees from there. The sign of
arcAngle
determines which way the arc goes from startAngle
;
a negative sign means that the arc extends clockwise, whereas a positive sign means
that it extends counterclockwise.
corner1
- Location
of one corner of the bounding rectanglecorner2
- Location
of the opposite corner of the bounding rectanglestartAngle
- start angle, in degreesarcAngle
- arc angle, in degreescolor
- Color
of the arccanvas
- DrawingCanvas
on which to place the arcpublic FramedArc(Location corner1, Location corner2, double startAngle, double arcAngle, DrawingCanvas canvas)
FramedArc
whose bounding rectangle stretches between corner1
and corner2
. The arc will start at startAngle
, given in
degrees in the usual angle system, so that 0 is east, Math.PI / 2
is north,
and so on; it will extend arcAngle
degrees from there. The sign of
arcAngle
determines which way the arc goes from startAngle
;
a negative sign means that the arc extends clockwise, whereas a positive sign means
that it extends counterclockwise.
corner1
- Location
of one corner of the bounding rectanglecorner2
- Location
of the opposite corner of the bounding rectanglestartAngle
- start angle, in degreesarcAngle
- arc angle, in degreescanvas
- 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 double getArcAngle()
(startAngle + arcAngle)
.
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 double getLineWidth()
getLineWidth
in interface DrawableStrokeInterface
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 double getStartAngle()
public BasicStroke getStroke()
getStroke
in interface DrawableStrokeInterface
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 setArcAngle(double a)
a
- new arc anglepublic 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 setLineWidth(double width)
setLineWidth
in interface DrawableStrokeInterface
width
- the new width of this object's linespublic void setSize(double width, double height)
setSize
in interface Resizable2DInterface
setSize
in class objectdraw.ObjectDrawRectangularShape
width
- new widthheight
- new heightpublic void setStartAngle(double a)
a
- new start anglepublic void setStroke(BasicStroke stroke)
setStroke
in interface DrawableStrokeInterface
stroke
- the new stroke for this object's linespublic 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