|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectLine
public class Line
Constructor Summary | |
---|---|
Line(double x1,
double y1,
double x2,
double y2)
Constructs a line with a given starting and ending location. |
Method Summary | |
---|---|
void |
draw()
Shows this line on the canvas. |
int |
getHeight()
Gets the height of the bounding box. |
int |
getWidth()
Gets the width of the bounding box. |
int |
getX()
Gets the leftmost x-position of the line. |
int |
getY()
Gets the topmost y-position of the line. |
void |
grow(double dw,
double dh)
Resizes this line both horizontally and vertically. |
void |
paintShape(Graphics2D g2)
Paints the shape |
void |
setColor(Color newColor)
Sets the color for drawing this line. |
String |
toString()
|
void |
translate(double dx,
double dy)
Moves this line by a given amount. |
Methods inherited from class |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Line(double x1, double y1, double x2, double y2)
x1
- the x-coordinate of the starting pointy1
- the y-coordinate of the starting pointx2
- the x-coordinate of the ending pointy2
- the y-coordinate of the ending pointMethod Detail |
---|
public void draw()
public int getHeight()
getHeight
in interface Shape
public int getWidth()
getWidth
in interface Shape
public int getX()
getX
in interface Shape
public int getY()
getY
in interface Shape
public void grow(double dw, double dh)
dw
- the amount by which to resize the width on each sidedw
- the amount by which to resize the height on each sidepublic void paintShape(Graphics2D g2)
Shape
paintShape
in interface Shape
g2
- the graphics objectpublic void setColor(Color newColor)
newColor
- the new colorpublic String toString()
toString
in class Object
public void translate(double dx, double dy)
dx
- the amount by which to move in x-directiondy
- the amount by which to move in y-direction
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |