Package paintingcanvas.drawable
Interface Drawable<T extends Drawable<T>>
-
- All Superinterfaces:
Animatable
- All Known Subinterfaces:
Anchorable<T>
,Colorable<T>
,Outlineable<T>
,Positionable<T>
- All Known Implementing Classes:
Circle
,DrawableBase
,DrawableBase.InteractableShape
,DrawableBase.OutlineableDrawableBase
,DrawableBase.Shape
,Ellipse
,Image
,Line
,Path
,Polygon
,Rectangle
,Square
,Text
,Triangle
public interface Drawable<T extends Drawable<T>> extends Animatable
An interface to connect to any objects that can be considered "painter.drawable.Drawable". Provides various common methods to draw objects to a screen
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default AnimationBuilder
animate()
Start animating this object.default T
bringToFront()
Brings the object in front of all other objects.java.awt.Point
center(java.awt.Graphics2D g)
Get the object's centerpointdefault Drawable<?>
drawable()
Get theDrawable
element from thisAnimatable
.default void
erase()
Erase this object from the canvas.int
getLayer()
Gets the current layer of the object.T
getThis()
T
hide()
Hide the Object.void
internalSetLayer(int layer)
void
render(java.awt.Graphics2D g)
Actually render the object itselfdefault T
sendToBack()
Puts the object behind all other objects.default T
setLayer(int layer)
Puts the object on a specific layer.T
show()
Show the Object-
Methods inherited from interface paintingcanvas.animation.Animatable
Modifier and Type Method Description default AnimationBuilder
colorTo(int hex, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(int r, int g, int b, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(int r, int g, int b, int a, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(java.awt.Color color, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(java.lang.String name, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.default AnimationBuilder
colorTo(Hue hue, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.Drawable<?>
drawable()
Get theDrawable
element from thisAnimatable
.default AnimationBuilder
fadeIn(double duration)
Fadethis
in overduration
seconds.default AnimationBuilder
fadeOut(double duration)
Fadethis
out overduration
seconds.default AnimationBuilder
moveBy(int x, int y, double duration)
Movethis
by the specifiedx
andy
overduration
seconds.default AnimationBuilder
moveHorizontalBy(int x, double duration)
Movethis
by the specifiedx
horizontally overduration
seconds.default AnimationBuilder
moveTo(int x, int y, double duration)
Movethis
to the specifiedx
andy
overduration
secondsdefault AnimationBuilder
moveVerticalBy(int y, double duration)
Movethis
by the specifiedy
vertically overduration
seconds.default AnimationBuilder
rotateBy(int angle, double duration)
Rotatethis
byangle
degrees overduration
seconds.default AnimationBuilder
rotateTo(int angle, double duration)
Rotatethis
to the specifiedangle
degrees overduration
seconds.
-
-
-
-
Method Detail
-
internalSetLayer
void internalSetLayer(int layer)
-
center
java.awt.Point center(java.awt.Graphics2D g)
Get 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
-
render
void render(java.awt.Graphics2D g)
Actually render the object itselfThis calls the draw methods, but does some extra steps beforehand to lay it out correctly
- Parameters:
g
- the graphics context to draw the object with
-
getThis
T getThis()
-
hide
T hide()
Hide the Object.Circle o = new Circle(100, 100, 20); o.hide();
- Returns:
- the original object to allow method chaining
- See Also:
show()
-
show
T show()
Show the ObjectCircle o = new Circle(100, 100, 20); o.show();
- Returns:
- the original object to allow method chaining
- See Also:
hide()
-
getLayer
int getLayer()
Gets the current layer of the object. By default, all objects are on layer 0.- Returns:
- the original object to allow method chaining
- See Also:
setLayer(int)
,bringToFront()
,sendToBack()
-
setLayer
default T setLayer(int layer)
Puts the object on a specific layer.- Parameters:
layer
- the layer to set the object to- Returns:
- the original object to allow method chaining
- See Also:
getLayer()
,bringToFront()
,sendToBack()
-
bringToFront
default T bringToFront()
Brings the object in front of all other objects.- Returns:
- the original object to allow method chaining
- See Also:
getLayer()
,setLayer(int)
,sendToBack()
-
sendToBack
default T sendToBack()
Puts the object behind all other objects.- Returns:
- the original object to allow method chaining
- See Also:
getLayer()
,setLayer(int)
,bringToFront()
-
erase
default void erase()
Erase this object from the canvas. This object will be gone and cannot* be added back!* It can be added back just don't tell anyone shhhh
-
animate
default AnimationBuilder animate()
Start animating this object.- Returns:
- An
AnimationBuilder
to start animating this object.
-
drawable
default Drawable<?> drawable()
Description copied from interface:Animatable
Get theDrawable
element from thisAnimatable
.- Specified by:
drawable
in interfaceAnimatable
- Returns:
- the
Drawable
-
-