Class Line
- public class Line
- implements Shape
A line class.
- Version:
- $Id: Line.java,v 1.2 2001/04/04 03:25:11 administrator Exp $
- Author:
- Ben Dugan
Line
public Line()
- Make a new line of the default size and position.
By default, the line is orange.
Line
public Line(int x1,
int y1,
int x2,
int y2)
- A line between the points determined by the parameters.
Line
public Line(int x1,
int y1,
int x2,
int y2,
java.awt.Color c)
- Lines are never filled, but we can set the color.
toString
public java.lang.String toString()
- Description copied from class:
ShapeImpl
- Answer the printed representation of this shape.
- Overrides:
toString
in class PolyShape
getBoundingBox
public Rectangle getBoundingBox()
- Answer the Rectangle which specifies the bounding box
- Overrides:
getBoundingBox
in class ShapeImpl
addPoint
public void addPoint(int x,
int y)
- Add a point to the polygon.
paint
public void paint(java.awt.Graphics g)
- Paint the polygon onto the given graphics context.
- Overrides:
paint
in class ShapeImpl
move
public void move(int dx,
int dy)
- Translate all the points of the polygon by the given amount.
- Overrides:
move
in class ShapeImpl
- Following copied from interface:
Shape
- Parameters:
deltaX
- offset in the X direction.deltaY
- offset in the Y direction.
setPosition
public void setPosition(int x,
int y)
rotate
public void rotate(double degrees)
- This method rotates the polygon the given number of degrees about "center" which
is computed as the average of all of its points.
main
public static void main(java.lang.String[] args)
setWindow
public void setWindow(GWindow gw)
- Attach the shape to the given window.
- Specified by:
setWindow
in interface Shape
intersects
public boolean intersects(Shape s)
- Does this shape intersect the other shape?
- Specified by:
intersects
in interface Shape
getColor
public java.awt.Color getColor()
- Answer the color of this shape.
- Specified by:
getColor
in interface Shape
setColor
public void setColor(java.awt.Color c)
- Set the color of this shape.
- Specified by:
setColor
in interface Shape