element
Class Arc

java.lang.Object
  |
  +--element.Rect
        |
        +--element.Oval
              |
              +--element.Arc

public class Arc
extends Oval

An object that describes a portion of an oval.


Field Summary
protected  int angle
          The span of the arc, increasing counter-clockwize from the start angle.
protected  int start
          The start angle of the arc.
 
Fields inherited from class element.Rect
height, left, top, width
 
Constructor Summary
Arc()
          Construct a trivial arc located at the origin.
Arc(Arc r)
          Constructs a copy of an arc from another.
Arc(int x, int y, int w, int h)
          Construct an oval bounded by the rectangle specified by (x,y,w,h).
Arc(int x, int y, int w, int h, int strt, int angl)
          Construct an arc bounded by the rectangle specified by (x,y,w,h), starting at strt, and sweeping for angl degrees.
Arc(Pt p, Pt q)
          Construct an oval determined by two points: p and q.
Arc(Rect r, int strt, int angl)
          Construct an arc bounded by rectangle r with specified start and sweep.
 
Method Summary
 int angle()
          Return the span of the arc.
 void angle(int angl)
          Set the span or sweep of the arc.
protected static int canonical(int angle)
          turn an angle into one that is between 0 and 359.
 void clearOn(DrawingWindow d)
          Erase arc from the drawing window d.
 java.lang.Object clone()
          return a distinct copy of this arc
 boolean contains(Pt p)
          Determine if a point p is within an arc.
 void drawOn(DrawingWindow d)
          Draw (in the current mode) the arc on the drawing window.
 boolean equals(java.lang.Object other)
          Return true iff this arc equals the other
 void fillOn(DrawingWindow d)
          Draw this arc on the specified drawing window.
 int hashCode()
          Return an integer for use as a hash code.
 int start()
          Return the starting angle of the arc.
 void start(int strt)
          Set the starting angle of the arc.
 java.lang.String toString()
          Construct a string representation of this arc
 
Methods inherited from class element.Rect
bottom, bottom, center, center, extend, height, height, left, left, move, moveTo, moveTo, Rectangle, right, right, top, top, width, width
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

start

protected int start
The start angle of the arc. Measured in degrees, with zero degrees due right, and increasing counter-clockwize.

angle

protected int angle
The span of the arc, increasing counter-clockwize from the start angle.
Constructor Detail

Arc

public Arc()
Construct a trivial arc located at the origin.

Arc

public Arc(Pt p,
           Pt q)
Construct an oval determined by two points: p and q.
Parameters:
p - one of the two points determining the bounding rectangle
q - the other point determining the bounding rectangle

Arc

public Arc(Rect r,
           int strt,
           int angl)
Construct an arc bounded by rectangle r with specified start and sweep.
Parameters:
r - the bounding rectangle
strt - the starting angle of the arc
angl - the counter-clockwize sweep of the arc.

Arc

public Arc(int x,
           int y,
           int w,
           int h,
           int strt,
           int angl)
Construct an arc bounded by the rectangle specified by (x,y,w,h), starting at strt, and sweeping for angl degrees.
Parameters:
x - the left side of the bounding rectangle.
y - the top side of the bounding rectangle
w - the width of the bounding rectangle
h - the height of the bounding rectangle
strt - the starting angle of the arc, with zero pointing due right
angl - the size of counter-clockwize sweep of arc.

Arc

public Arc(int x,
           int y,
           int w,
           int h)
Construct an oval bounded by the rectangle specified by (x,y,w,h).
Parameters:
x - the left side of the bounding rectangle.
y - the top side of the bounding rectangle
w - the width of the bounding rectangle
h - the height of the bounding rectangle

Arc

public Arc(Arc r)
Constructs a copy of an arc from another.
Parameters:
r - the source arc.
Method Detail

canonical

protected static int canonical(int angle)
turn an angle into one that is between 0 and 359.
Parameters:
angle - the initial angle.
Returns:
the canonical form of the angle.

contains

public boolean contains(Pt p)
Determine if a point p is within an arc.
Overrides:
contains in class Oval
Parameters:
p - the point to be checked
Returns:
true if the point is within the arc, false otherwise.

start

public int start()
Return the starting angle of the arc.
Returns:
the starting angle of the arc.

angle

public int angle()
Return the span of the arc.
Returns:
the span of the arc, in degrees.

start

public void start(int strt)
Set the starting angle of the arc.
Parameters:
strt - the new starting angle of the arc, in degrees.

angle

public void angle(int angl)
Set the span or sweep of the arc.
Parameters:
angl - the sweep of the arc, in degrees, counter-clockwize from start.

fillOn

public void fillOn(DrawingWindow d)
Draw this arc on the specified drawing window.
Overrides:
fillOn in class Oval
Parameters:
d - the target drawing window.
See Also:
DrawingWindow.fill(element.Drawable), DrawingWindow.paintMode(), DrawingWindow.invertMode()

clearOn

public void clearOn(DrawingWindow d)
Erase arc from the drawing window d.
Overrides:
clearOn in class Oval
Parameters:
d - the target drawing window
See Also:
DrawingWindow.clear(element.Drawable)

drawOn

public void drawOn(DrawingWindow d)
Draw (in the current mode) the arc on the drawing window.
Overrides:
drawOn in class Oval
Parameters:
d - the target drawing window
See Also:
DrawingWindow.paintMode(), DrawingWindow.invertMode(), DrawingWindow.draw(element.Drawable)

hashCode

public int hashCode()
Return an integer for use as a hash code.
Overrides:
hashCode in class Oval
Returns:
a hash code

equals

public boolean equals(java.lang.Object other)
Return true iff this arc equals the other
Overrides:
equals in class Oval
Parameters:
other - another valid arc
Returns:
true if the two are equal valued, false otherwise

clone

public java.lang.Object clone()
return a distinct copy of this arc
Overrides:
clone in class Oval
Returns:
a distinct copy of this arc

toString

public java.lang.String toString()
Construct a string representation of this arc
Overrides:
toString in class Oval
Returns:
a string representation of this arc