Package paintingcanvas.drawable
Class Ellipse
- java.lang.Object
-
- paintingcanvas.drawable.Drawable<Ellipse>
-
- paintingcanvas.drawable.Ellipse
-
- All Implemented Interfaces:
Animatable
public class Ellipse extends Drawable<Ellipse>
An ellipse element.// Create a new ellipse at (100, 100) with width 20 and height 30 Ellipse ellipse = new Ellipse(100, 100, 20, 30);
-
-
Constructor Summary
Constructors Constructor Description Ellipse(int centerX, int centerY, int width, int height)
Create a new Ellipse element.Ellipse(int centerX, int centerY, int width, int height, java.awt.Color color)
Create a new Ellipse element.Ellipse(int centerX, int centerY, int width, int height, java.lang.String color)
Create a new Ellipse element with a certain color by name (seeHue
for list of all valid names)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
drawFilled(java.awt.Graphics2D gc)
the color is set to `color`protected void
drawOutline(java.awt.Graphics2D gc)
the color is set to `outlineColor`, the stroke is set to `outlineStroke`int
getHeight()
Gets the height of the ellipse.protected Ellipse
getThis()
int
getWidth()
Gets the width of the ellipse.Ellipse
setHeight(int h)
Sets the height of the ellipse.Ellipse
setWidth(int w)
Sets the width of the ellipse.-
Methods inherited from class paintingcanvas.drawable.Drawable
Modifier and Type Method Description AnimationBuilder
animate()
Start animating this object.java.awt.Point
center(java.awt.Graphics g)
Get the object's centerpointDrawable<?>
drawable()
Get theDrawable
element from thisAnimatable
.protected abstract void
drawFilled(java.awt.Graphics2D gc)
the color is set to `color`protected abstract void
drawOutline(java.awt.Graphics2D gc)
the color is set to `outlineColor`, the stroke is set to `outlineStroke`void
erase()
Erase this object from the canvas.java.awt.Color
getColor()
Get the current color of an element as aColor
java.awt.Color
getOutlineColor()
Gets the outline colorjava.awt.Stroke
getOutlineStroke()
Gets the outline strokejava.awt.Point
getPos()
Get the position of the elementdouble
getRotation()
Get an elements rotationprotected abstract T
getThis()
int
getX()
Get the X-position of the elementint
getY()
Get the Y-position of the element.T
hide()
Hide the Object.T
move(int x, int y)
Moves this drawable by the specified x and y.T
moveHorizontal(int x)
Moves this drawable by the specified x and y.T
moveVertical(int y)
Moves this drawable by the specified x and y.T
removeOutline()
Removes the outline from the shapevoid
render(java.awt.Graphics g)
Actually render the object itselfT
rotate(double rotation)
Rotate this element byrotation°
.T
setColor(int hex)
Set the color of the object with a 8-bit RGB hex literal.T
setColor(int r, int g, int b)
Set the color of the element with RGB.T
setColor(java.awt.Color color)
Set the color of the object with aColor
object.T
setColor(java.lang.String color)
Set the color of the object with a certain color by name (seeHue
for list of all valid names)T
setFilled(boolean filled)
Set whether this object is filled or notT
setOutline(int thickness)
Sets the parameters for the outline of the shape, with the color defaulting to blackT
setOutline(int thickness, java.awt.Color color)
Sets the parameters for the outline of the shapeT
setOutline(java.awt.Color color)
Sets the outline color of the shapeT
setPos(int x, int y)
Set the position of the element.T
setRotation(double rotation)
Set an elements rotation torotation°
.T
setX(int x)
Set the X-position of the objectT
setY(int y)
Set the Y-position of the elementT
show()
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 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(java.awt.Color color, double duration)
Change the color ofthis
to the specifiedcolor
overduration
seconds.Drawable<?>
drawable()
Get theDrawable
element from thisAnimatable
.default AnimationBuilder
fadeIn(double duration)
Fadesthis
in over @{code duration} seconds.default AnimationBuilder
fadeOut(double duration)
Fadesthis
out over @{code duration} seconds.default AnimationBuilder
moveBy(int x, int y, double duration)
This method movesthis
by the specifiedx
andy
default AnimationBuilder
moveHorizontalBy(int x, double duration)
This method movesthis
by the specifiedx
horizontally.default AnimationBuilder
moveTo(int x, int y, double duration)
Movethis
to the specifiedx
andy
overduration
secondsdefault AnimationBuilder
moveVerticalBy(int y, double duration)
This method movesthis
by the specifiedx
horizontally.default AnimationBuilder
rotateBy(int angle, double duration)
Rotatesthis
byangle°
.default AnimationBuilder
rotateTo(int angle, double duration)
Rotatesthis
to the specifiedangle°
.
-
-
-
-
Constructor Detail
-
Ellipse
public Ellipse(int centerX, int centerY, int width, int height)
Create a new Ellipse element.// Create a new ellipse centered at (100, 100) with width 20 and height 30 Ellipse ellipse = new Ellipse(100, 100, 20, 30);
- Parameters:
centerX
- The X-position of the ellipsecenterY
- The Y-position of the ellipsewidth
- The width of the ellipseheight
- The height of the ellipse
-
Ellipse
public Ellipse(int centerX, int centerY, int width, int height, java.awt.Color color)
Create a new Ellipse element.// Create a new red ellipse centered at (100, 100) with width 20 and height 30 Ellipse ellipse = new Ellipse(100, 100, 20, 30, new Color(255, 0, 0));
- Parameters:
centerX
- The X-position of the ellipsecenterY
- The Y-position of the ellipsewidth
- The width of the ellipseheight
- The height of the ellipsecolor
- The color of the ellipse
-
Ellipse
public Ellipse(int centerX, int centerY, int width, int height, java.lang.String color)
Create a new Ellipse element with a certain color by name (seeHue
for list of all valid names)// Create a new red ellipse centered at (100, 100) with width 20 and height 30 Ellipse ellipse = new Ellipse(100, 100, 20, 30, "red");
- Parameters:
centerX
- The X-position of the ellipsecenterY
- The Y-position of the ellipsewidth
- The width of the ellipseheight
- The height of the ellipsecolor
- The name of the color (case-insensitive)
-
-
Method Detail
-
drawOutline
protected void drawOutline(java.awt.Graphics2D gc)
Description copied from class:Drawable
the color is set to `outlineColor`, the stroke is set to `outlineStroke`- Specified by:
drawOutline
in classDrawable<Ellipse>
- Parameters:
gc
- The graphics context to draw the object with
-
drawFilled
protected void drawFilled(java.awt.Graphics2D gc)
Description copied from class:Drawable
the color is set to `color`- Specified by:
drawFilled
in classDrawable<Ellipse>
- Parameters:
gc
- The graphics context to draw the object with
-
getWidth
public int getWidth()
Gets the width of the ellipse.- Returns:
- The width of the ellipse in pixels
- See Also:
getHeight()
,setWidth(int)
-
setWidth
public Ellipse setWidth(int w)
Sets the width of the ellipse.- Parameters:
w
- The new width of the ellipse in pixels- Returns:
- The original object to allow method chaining
- See Also:
setHeight(int)
,getWidth()
-
getHeight
public int getHeight()
Gets the height of the ellipse.- Returns:
- The height of the ellipse in pixels
- See Also:
getWidth()
,setHeight(int)
-
setHeight
public Ellipse setHeight(int h)
Sets the height of the ellipse.- Parameters:
h
- The new height of the ellipse in pixels- Returns:
- The original object to allow method chaining
- See Also:
setWidth(int)
,getHeight()
-
-