Package doodlepad
Class Arc
java.lang.Object
doodlepad.Shape
doodlepad.Arc
A class that implements a graphical arc shape.
An Arc is a partial section of an ellipse that is bounded by the rectangle
defined by the parameters passed to the Arc constructor. The start angle and
angle extent define the section of the ellipse that makes up the Arc.
-
Nested Class Summary
Nested classes/interfaces inherited from class doodlepad.Shape
Shape.ShapeMouseEventHandler, Shape.ShapeSelectionEventHandler
-
Field Summary
Fields inherited from class doodlepad.Shape
draggable, eventsEnabled, fillColor, filled, font, fontFamily, fontSize, fontStyle, height, layer, selectable, selected, shapeListener, strokeColor, stroked, strokeWidth, text, textFillColor, transform, visible, width, x, y
-
Constructor Summary
ConstructorDescriptionArc()
Default constructor for the Arc object.Arc
(double x, double y, double width, double height, double startAngle, double arcAngle) Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height).Arc
(double x, double y, double width, double height, double startAngle, double arcAngle, Layer layer) Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height) and the layer on which the arc will be drawn.Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height). -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(Graphics2D g) Draw the shapedouble
Returns the arc angle for the Arc Shape.getArea()
Return the area of an arc.double
Returns the start angle for the Arc Shape.void
setArcAngle
(double angle) Sets the arc angle extent for the Arc Shape.void
setStartAngle
(double angle) Sets the start angle for the Arc Shape.void
A no-op to prevent setting text for this Shape.toString()
Builds and returns a string representation of the arc shape that includes position, size and layer.Methods inherited from class doodlepad.Shape
contains, contains, drawText, getCenter, getDraggable, getEventsEnabled, getFillAlpha, getFillBlue, getFillColor, getFilled, getFillGreen, getFillRed, getFontFamily, getFontSize, getFontStyle, getHeight, getLayer, getLocation, getPad, getPadLocation, getSelectable, getSelected, getSize, getStrokeAlpha, getStrokeBlue, getStrokeColor, getStroked, getStrokeGreen, getStrokeRed, getStrokeWidth, getText, getTransform, getVisible, getWidth, getWindowLocation, getX, getY, intersects, move, onMouseClicked, onMouseDoubleClicked, onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onSelectionChanged, repaint, reset, rotate, rotate, scale, scale, scale, scale, setCenter, setCenter, setDraggable, setEventsEnabled, setFillColor, setFillColor, setFillColor, setFillColor, setFilled, setFontFamily, setFontSize, setFontStyle, setHeight, setLocation, setLocation, setMouseClickedHandler, setMouseDoubleClickedHandler, setMouseDraggedHandler, setMouseEnteredHandler, setMouseExitedHandler, setMouseMovedHandler, setMousePressedHandler, setMouseReleasedHandler, setPadLocation, setSelectable, setSelected, setSelectionChangedHandler, setSize, setSize, setStrokeColor, setStrokeColor, setStrokeColor, setStrokeColor, setStroked, setStrokeWidth, setTextColor, setTextColor, setTextColor, setTextColor, setTransform, setVisible, setWidth, setWindowLocation, setX, setY, toBack, toFront, toWindowCoords, toWindowCoords, translate
-
Constructor Details
-
Arc
public Arc(double x, double y, double width, double height, double startAngle, double arcAngle) Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height). The section starts at angle startAngle (degrees) and extends by arcAngle (degrees).// Creates an arc with an upper left corner at (10, 20) and a size of (100, 50) // from an angle of 0° and continuing by an extent of 45°. Arc arc = new Arc(10, 20, 100, 50, 0, 45);
- Parameters:
x
- The upper x-coordinate of the Arc`s related ellipse bounding box (pixels).y
- The upper y-coordinate of the Arc`s related ellipse bounding box (pixels).width
- The width of the Arc`s related ellipse (pixels).height
- The height of the Arc`s related ellipse bounding box (pixels).startAngle
- The starting angle at which to begin drawing the Arc (degrees).arcAngle
- The angular extent of the Arc, which defines its length (degrees).
-
Arc
public Arc(double x, double y, double width, double height, double startAngle, double arcAngle, Pad pad) Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height). The section starts at angle startAngle (degrees) and extends by arcAngle (degrees).- Parameters:
x
- The upper x-coordinate of the Arc`s related ellipse bounding box (pixels).y
- The upper y-coordinate of the Arc`s related ellipse bounding box (pixels).width
- The width of the Arc`s related ellipse (pixels).height
- The height of the Arc`s related ellipse bounding box (pixels).startAngle
- The starting angle at which to begin drawing the Arc (degrees).arcAngle
- The angular extent of the Arc, which defines its length (degrees).pad
- The Pad object on which to create the Arc.
-
Arc
public Arc(double x, double y, double width, double height, double startAngle, double arcAngle, Layer layer) Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height) and the layer on which the arc will be drawn. The section starts at angle startAngle (degrees) and extends by arcAngle (degrees).- Parameters:
x
- The upper x-coordinate of the Arc`s related ellipse bounding box (pixels).y
- The upper y-coordinate of the Arc`s related ellipse bounding box (pixels).width
- The width of the Arc`s related ellipse (pixels).height
- The height of the Arc`s related ellipse bounding box (pixels).startAngle
- The starting angle at which to begin drawing the Arc (degrees).arcAngle
- The angular extent of the Arc, which defines its length (degrees).layer
- Layer object to add Arc to, or null if not to add Arc to a Layer.
-
Arc
public Arc()Default constructor for the Arc object. Creates an arc shape with the default parameters width=100, height=100, startAngle=0, arcAngle=270. that is draggable shape and positioned randomly.
-
-
Method Details
-
getStartAngle
public double getStartAngle()Returns the start angle for the Arc Shape.- Returns:
- start angle (degrees)
-
getArcAngle
public double getArcAngle()Returns the arc angle for the Arc Shape.- Returns:
- arc angle extent (degrees)
-
setStartAngle
public void setStartAngle(double angle) Sets the start angle for the Arc Shape.- Parameters:
angle
- start angle (degrees)
-
setArcAngle
public void setArcAngle(double angle) Sets the arc angle extent for the Arc Shape.- Parameters:
angle
- arc angle extent (degrees)
-
setText
A no-op to prevent setting text for this Shape. -
toString
Builds and returns a string representation of the arc shape that includes position, size and layer. -
draw
Draw the shape -
getArea
Return the area of an arc. The area will be of the pie section if filled, and an open section if not filled.
-