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.


Constructor Index

 o Line()
Default zero-parameter constructor that sets the line to the default line consisting of a single pixel at (0,0).
 o Line(Pixel, Pixel)
Two-parameter constructor

Method Index

 o isParallel(Line)
Returns true if the slope of the object line is the same as the slope of the line L.
 o paint(Graphics)
Draws the line on the graphic device g.
 o slope()
Computes the slope of the line.

Constructors

 o Line
 public Line()
Default zero-parameter constructor that sets the line to the default line consisting of a single pixel at (0,0).

 o Line
 public Line(Pixel start,
             Pixel end)
Two-parameter constructor

Parameters:
start - starting pixel of the line
end - ending pixel of the line

Methods

 o 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.
 o 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.
 o 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