uwcse.graphics
Class Line
java.lang.Object
|
+--uwcse.graphics.ShapeImpl
|
+--uwcse.graphics.PolyShape
|
+--uwcse.graphics.Line
- All Implemented Interfaces:
- Shape
- public class Line
- extends PolyShape
- implements Shape
A line shape. (Really, just a polygon with two vertices.) The
main operations are to read the x and y coordinates of the
upper-left corner of the bounding rectangle around the line (getX()
and getY()), to change the position of the upper-left corner
(moveBy(...) and moveTo(...)), to rotate the line around some
point (rotateAround(...)), to read and change the color of the
shape (getColor() and setColor(...)), and add to and remove from a
GWindow (addTo(...) and removeFromWindow()). Other operations are
mainly for internal use, and should not be called by regular client
programs.
Constructor Summary |
Line()
Make a new orange line with a default size and position. |
Line(int x1,
int y1,
int x2,
int y2)
Create a new black line between the two given points |
Line(int x1,
int y1,
int x2,
int y2,
java.awt.Color c)
Create a new line of the given color between the two given
points (lines are never filled, so no filled argument is needed) |
Method Summary |
java.lang.String |
toString()
Answer the printed representation of this shape. |
Methods inherited from class uwcse.graphics.ShapeImpl |
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, recordWindow, removeFromWindow, setColor |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface uwcse.graphics.Shape |
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, paint, recordWindow, removeFromWindow, rotateAround, setColor |
Line
public Line()
- Make a new orange line with a default size and position.
Line
public Line(int x1,
int y1,
int x2,
int y2)
- Create a new black line between the two given points
- Parameters:
x1
- the X coordinate of the first pointy1
- the Y coordinate of the first pointx2
- the X coordinate of the second pointy2
- the Y coordinate of the second point
Line
public Line(int x1,
int y1,
int x2,
int y2,
java.awt.Color c)
- Create a new line of the given color between the two given
points (lines are never filled, so no filled argument is needed)
- Parameters:
x1
- the X coordinate of the first pointy1
- the Y coordinate of the first pointx2
- the X coordinate of the second pointy2
- the Y coordinate of the second point
toString
public java.lang.String toString()
- Description copied from class:
ShapeImpl
- Answer the printed representation of this shape.
- Overrides:
toString
in class PolyShape