Modifier and Type | Field and Description |
---|---|
static double |
LINE_TOLERANCE
This constant defines how close (measured in pixel units) a point has to be
to a line before that point is considered to be "contained" within the line.
|
Constructor and Description |
---|
GLine(double x0,
double y0,
double x1,
double y1)
Constructs a line segment from its endpoints.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(double x,
double y)
Checks to see whether a point is inside the object.
|
GRectangle |
getBounds()
Returns the bounding box for this object.
|
GPoint |
getEndPoint()
Returns the end point of the line as a
GPoint object. |
GPoint |
getStartPoint()
Returns the coordinates of the initial point in the line.
|
void |
paint(java.awt.Graphics g)
Implements the
paint operation for this graphical object. |
java.lang.String |
paramString()
Returns a string indicating the parameters of this object.
|
void |
scale(double sf)
Scales the object on the screen by the scale factor
sf , which
applies in both dimensions. |
void |
scale(double sx,
double sy)
Scales the line on the screen by the scale factors
sx and
sy . |
void |
setEndPoint(double x,
double y)
Sets the end point of the line to the point
(
x , y ). |
void |
setStartPoint(double x,
double y)
Sets the initial point in the line to (
x , y ),
leaving the end point unchanged. |
addActionListener, addMouseListener, addMouseMotionListener, areMouseListenersEnabled, colorName, contains, fireActionEvent, fireActionEvent, fireMouseListeners, getColor, getComponent, getHeight, getLocation, getObjectColor, getParent, getSize, getWidth, getX, getY, isVisible, move, movePolar, paintObject, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, repaint, sendBackward, sendForward, sendToBack, sendToFront, setColor, setLocation, setLocation, setParent, setVisible, start, start, toString, updateEnabledList
public static final double LINE_TOLERANCE
public GLine(double x0, double y0, double x1, double y1)
x0
, y0
) defines the start of the line and the
point (x1
, y1
) defines the end.x0
- The x-coordinate of the start of the liney0
- The y-coordinate of the start of the linex1
- The x-coordinate of the end of the liney1
- The y-coordinate of the end of the linepublic void paint(java.awt.Graphics g)
paint
operation for this graphical object. This
method is not called directly by clients.public GRectangle getBounds()
public void setStartPoint(double x, double y)
x
, y
),
leaving the end point unchanged. This method is therefore different from
setLocation
, which
moves both components of the line segment.x
- The new x-coordinate of the originy
- The new y-coordinate of the originpublic GPoint getStartPoint()
getLocation
and exists
only to provide symmetry with
setStartPoint
.public void setEndPoint(double x, double y)
x
, y
). The origin of the line remains
unchanged.x
- The new x-coordinate of the end pointy
- The new y-coordinate of the end pointpublic GPoint getEndPoint()
GPoint
object.public void scale(double sx, double sy)
sx
and
sy
. This method changes only the end point of the line, leaving
the start of the line fixed.public final void scale(double sf)
sf
, which
applies in both dimensions.public boolean contains(double x, double y)
GLine
class, containment is defined to mean that the point is
within LINE_TOLERANCE
pixels of
the line.public java.lang.String paramString()
paramString
in class GObject