Package paintingcanvas.drawable
Interface Positionable<T extends Drawable<T>>
-
- Type Parameters:
T- the type of the object
- All Superinterfaces:
Animatable,Drawable<T>
- All Known Subinterfaces:
Anchorable<T>
- All Known Implementing Classes:
Circle,DrawableBase,DrawableBase.InteractableShape,DrawableBase.OutlineableDrawableBase,DrawableBase.Shape,Ellipse,Image,Line,Path,Polygon,Rectangle,Square,Text,Triangle
public interface Positionable<T extends Drawable<T>> extends Drawable<T>
Elements that can be translated and rotated
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods 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-
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.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
-
-
-
-
Method Detail
-
internalSetPos
void internalSetPos(int x, int y)
-
internalGetRotation
double internalGetRotation()
-
internalSetRotation
void internalSetRotation(double rotation)
-
getPos
java.awt.Point getPos()
Get the position of the element- Returns:
- the position of the element as a
Point - See Also:
setPos(int, int)
-
getRotation
double getRotation()
Get an elements rotationCircle o = new Circle(100, 100, 20); o.setRotation(90); // Sets the elements rotation to 90° let i = o.getRotation(); // Gets the rotation assert i == 90;- Returns:
- the rotation of the object
- See Also:
rotate(double)
-
getX
default int getX()
Get the X-position of the element
-
setX
default T setX(int x)
Set the X-position of the object
-
getY
default int getY()
Get the Y-position of the element.
-
setY
default T setY(int y)
Set the Y-position of the element
-
setPos
default T setPos(int x, int y)
Set the position of the element.
-
move
default T move(int x, int y)
Moves this drawable by the specified x and y.Circle c = new Circle(100, 100, 20); // moves this circle 10 pixels to the right and 10 pixels down c.move(10, 10); // moves this circle 10 pixels to the left and 10 pixels up c.move(-10, -10);- Parameters:
x- the x to move byy- the y to move by- Returns:
- the original object to allow method chaining
- See Also:
setPos(int, int),moveHorizontal(int),moveVertical(int)
-
moveHorizontal
default T moveHorizontal(int x)
Moves this drawable by the specified x and y.Circle c = new Circle(100, 100, 20); // moves this circle 10 pixels to the right c.moveHorizontal(10);- Parameters:
x- the x to move by- Returns:
- the original object to allow method chaining
- See Also:
setPos(int, int),moveVertical(int)
-
moveVertical
default T moveVertical(int y)
Moves this drawable by the specified x and y.Circle c = new Circle(100, 100, 20); // moves this circle 10 pixels down c.moveVertical(10);- Parameters:
y- the y to move by- Returns:
- the original object to allow method chaining
- See Also:
setPos(int, int),moveHorizontal(int)
-
rotate
default T rotate(double rotation)
Rotate this element byrotationdegrees.Circle o = new Circle(100, 100, 20); // Calling rotate(90) twice makes the object rotate 180° o.rotate(90); o.rotate(90);- Parameters:
rotation- Change in rotation. (Degrees)- Returns:
- the original object to allow method chaining
- See Also:
setRotation(double)
-
setRotation
default T setRotation(double rotation)
Set an elements rotation torotationdegrees.Circle o = new Circle(100, 100, 20); o.setRotation(90); // Sets the elements rotation to 90°- Parameters:
rotation- Absolute rotation. (Degrees)- Returns:
- the original object to allow method chaining
- See Also:
rotate(double)
-
-