java.lang.ObjectDrawableShape
Triangle
public class Triangle
An equilateral triangle that can be manipulated and drawn.
Constructor Summary | |
---|---|
Triangle()
Creates a new Triangle object with default location, radius, and color. |
Method Summary | |
---|---|
void |
draw(java.awt.Graphics2D g2d)
|
java.lang.String |
getColor()
Get the triangle's current color |
double |
getRotation()
Get the triangle's current rotation (in radians) |
int |
getSideLength()
Get the triangle's current side length |
int |
getXPosition()
Get the triangle's current x position |
int |
getYPosition()
Get the triangle's current y position |
boolean |
isFilled()
Get whether the triangle is filled |
void |
moveDown()
Move the triangle a few pixels down. |
void |
moveHorizontal(int distance)
Move the triangle horizontally by distance pixels. |
void |
moveLeft()
Move the triangle a few pixels to the left. |
void |
moveRight()
Move the triangle a few pixels to the right. |
void |
moveUp()
Move the triangle a few pixels up. |
void |
moveVertical(int distance)
Move the triangle vertically by distance pixels. |
void |
setColor(java.lang.String color)
Set the triangle's new color |
void |
setFilled(boolean filled)
Set whether the triangle is filled; can either be true or false |
void |
setRotation(double rotation)
Set the triangle's current rotation (in radians). |
void |
setSideLength(int sideLength)
Set the triangle's new side length |
void |
setXPosition(int x)
Set the triangle's new x position |
void |
setYPosition(int y)
Set the triangle's new x position |
Methods inherited from class DrawableShape |
---|
getColorFromString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Triangle()
Method Detail |
---|
public void draw(java.awt.Graphics2D g2d)
draw
in class DrawableShape
public java.lang.String getColor()
public double getRotation()
public int getSideLength()
public int getXPosition()
public int getYPosition()
public boolean isFilled()
public void moveDown()
public void moveHorizontal(int distance)
distance
- The distance the triangle should move horizontallypublic void moveLeft()
public void moveRight()
public void moveUp()
public void moveVertical(int distance)
distance
- The distance the triangle should move verticallypublic void setColor(java.lang.String color)
color
- The Triangle's new color. Can either be:
"red", "green", "blue", "cyan", "magenta", "yellow", "pink", "gray", "black", "white"public void setFilled(boolean filled)
filled
- Whether the triangle should be filled; can either be true or falsepublic void setRotation(double rotation)
radius
- Triangle's new rotation (in radians). Note that this number should have a decimal value.public void setSideLength(int sideLength)
radius
- Triangle's new side lengthpublic void setXPosition(int x)
x
- Triangle's new x positionpublic void setYPosition(int y)
y
- Triangle's new y position