Package doodlepad
Class Polygon
java.lang.Object
doodlepad.Shape
doodlepad.Polygon
A class that implements a general graphical polygon object made up of straight lines
-
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
ConstructorDescriptionPolygon
(double[] xPoints, double[] yPoints) Constructor for objects of class Polygon - double arraysConstructor for objects of class Polygon - double arrays and LayerConstructor for objects of class Polygon - double arrays and PadPolygon
(int[] xPoints, int[] yPoints) Constructor for objects of class Polygon - int arraysConstructor for objects of class PolygonConstructor for objects of class PolygonConstructor for objects of class Polygon -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(Graphics2D g) Draw the Polygon objectdouble
getX
(int i) Return the x-coordinate of the ith polygon pointdouble
getY
(int i) Return the y-coordinate of the ith polygon pointvoid
setLocation
(double x, double y) Set the current position of the polygon and redraw it.void
setSize
(double w, double h) Update all polygon points to reflect new sizevoid
setX
(int i, double x) Update the x-coordinate of the ith polygon pointvoid
setY
(int i, double y) Update the y-coordinate of the ith polygon pointtoString()
Generate a representation of the Polygon object.Methods inherited from class doodlepad.Shape
contains, contains, drawText, getArea, 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, setMouseClickedHandler, setMouseDoubleClickedHandler, setMouseDraggedHandler, setMouseEnteredHandler, setMouseExitedHandler, setMouseMovedHandler, setMousePressedHandler, setMouseReleasedHandler, setPadLocation, setSelectable, setSelected, setSelectionChangedHandler, setSize, setStrokeColor, setStrokeColor, setStrokeColor, setStrokeColor, setStroked, setStrokeWidth, setText, setTextColor, setTextColor, setTextColor, setTextColor, setTransform, setVisible, setWidth, setWindowLocation, setX, setY, toBack, toFront, toWindowCoords, toWindowCoords, translate
-
Constructor Details
-
Polygon
public Polygon(int[] xPoints, int[] yPoints) Constructor for objects of class Polygon - int arrays- Parameters:
xPoints
- The array of x-coordinates for all Polygon object points.yPoints
- The array of y-coordinates for all Polygon object points.
-
Polygon
public Polygon(double[] xPoints, double[] yPoints) Constructor for objects of class Polygon - double arrays- Parameters:
xPoints
- The array of x-coordinates for all Polygon object points.yPoints
- The array of y-coordinates for all Polygon object points.
-
Polygon
Constructor for objects of class Polygon - double arrays and Pad- Parameters:
xPoints
- The array of x-coordinates for all Polygon object points.yPoints
- The array of y-coordinates for all Polygon object points.pad
- The Pad to which the Polygon will be added.
-
Polygon
Constructor for objects of class Polygon - double arrays and Layer- Parameters:
xPoints
- The array of x-coordinates for all Polygon object points.yPoints
- The array of y-coordinates for all Polygon object points.layer
- The Layer object to which the Polygon will be added, or null if not to add to a Pad.
-
Polygon
Constructor for objects of class Polygon- Parameters:
points
- List of Point objects that define coordinate points of Polygon
-
Polygon
Constructor for objects of class Polygon- Parameters:
points
- List of Point objects that define coordinate points of Polygonpad
- The Pad to which the Polygon will be added.
-
Polygon
Constructor for objects of class Polygon- Parameters:
points
- List of Point objects that define coordinate points of Polygonlayer
- The Layer object to which the Polygon will be added, or null if not to add to a Pad.
-
-
Method Details
-
toString
Generate a representation of the Polygon object. -
setLocation
public void setLocation(double x, double y) Set the current position of the polygon and redraw it.- Overrides:
setLocation
in classShape
- Parameters:
x
- the x-value of the positiony
- the y-value of the position
-
setSize
public void setSize(double w, double h) Update all polygon points to reflect new size -
getX
public double getX(int i) Return the x-coordinate of the ith polygon point- Parameters:
i
- Point number- Returns:
- x-coordinate of ith point
-
setX
public void setX(int i, double x) Update the x-coordinate of the ith polygon point- Parameters:
i
- Point numberx
- New x-coordinate value for ith point
-
getY
public double getY(int i) Return the y-coordinate of the ith polygon point- Parameters:
i
- point number- Returns:
- y-coordinate of ith point
-
setY
public void setY(int i, double y) Update the y-coordinate of the ith polygon point- Parameters:
i
- Point numbery
- New y-coordinate value for ith point
-
draw
Draw the Polygon object
-