Package paintingcanvas.drawable
Class Polygon
- java.lang.Object
-
- paintingcanvas.drawable.DrawableBase<T>
-
- paintingcanvas.drawable.DrawableBase.OutlineableDrawableBase<Polygon>
-
- paintingcanvas.drawable.Polygon
-
- All Implemented Interfaces:
Animatable,Colorable<Polygon>,Drawable<Polygon>,Outlineable<Polygon>,Positionable<Polygon>
public class Polygon extends DrawableBase.OutlineableDrawableBase<Polygon>
A Polygon Element.Polygon polygon = new Polygon(100, 100, new int[] {0, 25, 50}, new int[] {50, 25, 0}, );
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class paintingcanvas.drawable.DrawableBase
DrawableBase.InteractableShape<T extends Drawable<T>>, DrawableBase.OutlineableDrawableBase<T extends Drawable<T>>, DrawableBase.Shape<T extends Drawable<T>>
-
-
Field Summary
Fields Modifier and Type Field Description java.awt.PolygonpolygonThe internal polygon element
-
Constructor Summary
Constructors Constructor Description Polygon(int[][] points)Create a new Polygon element from a list of pointsPolygon(int[] xPoints, int[] yPoints)Create a new Polygon element from a list of x-positions and y-positionsPolygon(int x, int y)Create a new empty polygon, meant to be used in conjunction withpoint(int, int)Polygon(int x, int y, int[][] points)Create a new Polygon element from a list of pointsPolygon(int x, int y, int[] xPoints, int[] yPoints)Create a new Polygon element from a list of x-positions and y-positionsPolygon(int x, int y, java.awt.Polygon polygon)Create a new Polygon element from aPolygon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Pointcenter(java.awt.Graphics2D g)Get the object's centerpointPolygongetThis()voidpoint(int x, int y)Adds a point to this polygon-
Methods inherited from class paintingcanvas.drawable.DrawableBase.OutlineableDrawableBase
Modifier and Type Method Description java.awt.ColorgetOutlineColor()Gets the outline colorjava.awt.StrokegetOutlineStroke()Gets the outline strokevoidinternalSetFilled(boolean filled)voidinternalSetOutlineColor(java.awt.Color color)voidinternalSetOutlineStroke(java.awt.Stroke stroke)
-
Methods inherited from class paintingcanvas.drawable.DrawableBase
Modifier and Type Method Description java.awt.ColorgetColor()Get the current color of an element as aColorintgetLayer()Gets the current layer of the object.java.awt.PointgetPos()Get the position of the elementdoublegetRotation()Get an elements rotationThide()Hide the Object.doubleinternalGetRotation()voidinternalSetColor(java.awt.Color color)voidinternalSetLayer(int layer)voidinternalSetPos(int x, int y)voidinternalSetRotation(double rotation)voidrender(java.awt.Graphics2D g)Actually render the object itselfTshow()Show the Object
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface paintingcanvas.animation.Animatable
Modifier and Type Method Description default AnimationBuildercolorTo(int hex, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(int r, int g, int b, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(int r, int g, int b, int a, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(java.awt.Color color, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(java.lang.String name, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.default AnimationBuildercolorTo(Hue hue, double duration)Change the color ofthisto the specifiedcoloroverdurationseconds.Drawable<?>drawable()Get theDrawableelement from thisAnimatable.default AnimationBuilderfadeIn(double duration)Fadethisin overdurationseconds.default AnimationBuilderfadeOut(double duration)Fadethisout overdurationseconds.default AnimationBuildermoveBy(int x, int y, double duration)Movethisby the specifiedxandyoverdurationseconds.default AnimationBuildermoveHorizontalBy(int x, double duration)Movethisby the specifiedxhorizontally overdurationseconds.default AnimationBuildermoveTo(int x, int y, double duration)Movethisto the specifiedxandyoverdurationsecondsdefault AnimationBuildermoveVerticalBy(int y, double duration)Movethisby the specifiedyvertically overdurationseconds.default AnimationBuilderrotateBy(int angle, double duration)Rotatethisbyangledegrees overdurationseconds.default AnimationBuilderrotateTo(int angle, double duration)Rotatethisto the specifiedangledegrees overdurationseconds.
-
Methods inherited from interface paintingcanvas.drawable.Colorable
Modifier and Type Method Description java.awt.ColorgetColor()Get the current color of an element as aColorvoidinternalSetColor(java.awt.Color color)default TsetColor(int hex)Set the color ofthisto the specifiedcolor.default TsetColor(int r, int g, int b)Set the color ofthisto the specifiedcolor.default TsetColor(int r, int g, int b, int a)default TsetColor(java.awt.Color color)Set the color of the object with aColorobject.default TsetColor(java.lang.String name)Set the color of the object with a hue name or hex code.default TsetColor(Hue hue)Set the color of the object with aHueobject.
-
Methods inherited from interface paintingcanvas.drawable.Drawable
Modifier and Type Method Description default AnimationBuilderanimate()Start animating this object.default TbringToFront()Brings the object in front of all other objects.java.awt.Pointcenter(java.awt.Graphics2D g)Get the object's centerpointdefault Drawable<?>drawable()Get theDrawableelement from thisAnimatable.default voiderase()Erase this object from the canvas.intgetLayer()Gets the current layer of the object.TgetThis()Thide()Hide the Object.voidinternalSetLayer(int layer)voidrender(java.awt.Graphics2D g)Actually render the object itselfdefault TsendToBack()Puts the object behind all other objects.default TsetLayer(int layer)Puts the object on a specific layer.Tshow()Show the Object
-
Methods inherited from interface paintingcanvas.drawable.Outlineable
Modifier and Type Method Description java.awt.ColorgetOutlineColor()Gets the outline colorjava.awt.StrokegetOutlineStroke()Gets the outline strokevoidinternalSetFilled(boolean filled)voidinternalSetOutlineColor(java.awt.Color color)voidinternalSetOutlineStroke(java.awt.Stroke stroke)default TremoveOutline()Removes the outline from the shapedefault TsetFilled(boolean filled)Set whether this object is filled or notdefault TsetOutline(int thickness)Sets the parameters for the outline of the shape, with the color defaulting to blackdefault TsetOutline(int thickness, java.awt.Color color)Sets the parameters for the outline of the shapedefault TsetOutline(java.awt.Color color)Sets the outline color of the shape
-
Methods inherited from interface paintingcanvas.drawable.Positionable
Modifier and Type Method Description java.awt.PointgetPos()Get the position of the elementdoublegetRotation()Get an elements rotationdefault intgetX()Get the X-position of the elementdefault intgetY()Get the Y-position of the element.doubleinternalGetRotation()voidinternalSetPos(int x, int y)voidinternalSetRotation(double rotation)default Tmove(int x, int y)Moves this drawable by the specified x and y.default TmoveHorizontal(int x)Moves this drawable by the specified x and y.default TmoveVertical(int y)Moves this drawable by the specified x and y.default Trotate(double rotation)Rotate this element byrotationdegrees.default TsetPos(int x, int y)Set the position of the element.default TsetRotation(double rotation)Set an elements rotation torotationdegrees.default TsetX(int x)Set the X-position of the objectdefault TsetY(int y)Set the Y-position of the element
-
-
-
-
Constructor Detail
-
Polygon
public Polygon(int x, int y)Create a new empty polygon, meant to be used in conjunction withpoint(int, int)Polygon p = new Polygon(100, 100) .point(0, 50) .point(25, 25) .point(50, 0)- Parameters:
x- The X-position of the polygony- The Y-position of the polygon- See Also:
point(int, int)
-
Polygon
public Polygon(int x, int y, java.awt.Polygon polygon)Create a new Polygon element from aPolygon.Polygon polygon = new Polygon(100, 100, new java.awt.Polygon( new int[] {0, 25, 50}, new int[] {50, 25, 0}, 3 ));- Parameters:
x- The X-position of the polygony- The Y-position of the polygonpolygon- ThePolygonelement
-
Polygon
public Polygon(int x, int y, int[] xPoints, int[] yPoints)Create a new Polygon element from a list of x-positions and y-positionsPolygon polygon = new Polygon(100, 100, new int[] {0, 25, 50}, new int[] {50, 25, 0}, );- Parameters:
x- The X-position of the polygony- The Y-position of the polygonxPoints- List of X-pointsyPoints- List of Y-points
-
Polygon
public Polygon(int[] xPoints, int[] yPoints)Create a new Polygon element from a list of x-positions and y-positionsPolygon polygon = new Polygon( new int[] {0, 25, 50}, new int[] {50, 25, 0}, );- Parameters:
xPoints- List of X-pointsyPoints- List of Y-points
-
Polygon
public Polygon(int x, int y, int[][] points)Create a new Polygon element from a list of pointsint[][] points = {{0, 50}, {25, 25}, {50, 0}}; Polygon polygon = new Polygon(100, 100, points);- Parameters:
x- The X-position of the polygony- The Y-position of the polygonpoints- A 2D array containing pairs of (x, y) points
-
Polygon
public Polygon(int[][] points)
Create a new Polygon element from a list of pointsint[][] points = {{0, 50}, {25, 25}, {50, 0}}; Polygon polygon = new Polygon(points);- Parameters:
points- A 2D array containing pairs of (x, y) points
-
-
Method Detail
-
point
public void point(int x, int y)Adds a point to this polygon- Parameters:
x- the x-position of said pointy- the y-position of said point
-
center
public java.awt.Point center(java.awt.Graphics2D g)
Description copied from interface:DrawableGet the object's centerpointimport java.awt.Point; Point p = drawable.getStartpoint(); int x = p.x; int y = p.y;- Parameters:
g- Graphics context- Returns:
- the object's center-point
-
getThis
public Polygon getThis()
-
-