All Packages Class Hierarchy This Package Previous Next Index
Class sg.Line
java.lang.Object
|
+----sg.Line
- public class Line
- extends Object
- implements Polygon
The class Line
defines a geometric object line.
-
Line()
- Default zero-parameter constructor that sets the line
to the default line consisting of a single pixel at (0,0).
-
Line(Pixel, Pixel)
- Two-parameter constructor
-
isParallel(Line)
- Returns
true
if the slope of the object line is the same as
the slope of the line L.
-
paint(Graphics)
- Draws the line on the graphic device g.
-
slope()
- Computes the slope of the line.
Line
public Line()
- Default zero-parameter constructor that sets the line
to the default line consisting of a single pixel at (0,0).
Line
public Line(Pixel start,
Pixel end)
- Two-parameter constructor
- Parameters:
- start - starting pixel of the line
- end - ending pixel of the line
slope
public double slope()
- Computes the slope of the line.
- Returns:
- double the slope. If the line is vertical, return
Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY as
appropriate.
isParallel
public boolean isParallel(Line L)
- Returns
true
if the slope of the object line is the same as
the slope of the line L.
- Parameters:
- L - the line whose slope is to be compared to the slope
of the object line.
- Returns:
-
true
if the slope of the object is the same as
the slope of the argument; false
otherwise.
paint
public void paint(Graphics g)
- Draws the line on the graphic device g.
- Parameters:
- g - the simple graphics device on which to draw.
All Packages Class Hierarchy This Package Previous Next Index