|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectacm.graphics.GObject
acm.graphics.GLine
public class GLine
The GLine class is a graphical object whose appearance consists
of a line segment.
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
GLine(double x0,
double y0,
double x1,
double y1)
Constructs a line segment from its endpoints. |
|
| Method Summary | |
|---|---|
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(Graphics g)
Implements the paint operation for this graphical object. |
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. |
| Methods inherited from class acm.graphics.GObject |
|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final double LINE_TOLERANCE
| Constructor Detail |
|---|
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 line| Method Detail |
|---|
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.
contains in class GObjectx - The x-coordinate of the point being testedy - The y-coordinate of the point being tested
true if the point (x, y) is insidepublic GRectangle getBounds()
getBounds in class GObjectpublic GPoint getEndPoint()
GPoint object.
public GPoint getStartPoint()
getLocation and exists only to
provide symmetry with setStartPoint.
public void paint(Graphics g)
paint operation for this graphical object. This method
is not called directly by clients.
paint in class GObjectg - The graphics context into which the painting is donepublic String paramString()
paramString in class GObjectpublic final void scale(double sf)
sf, which applies
in both dimensions.
scale in interface GScalablesf - The factor used to scale all coordinates in both dimensions
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.
scale in interface GScalablesx - The factor used to scale all coordinates in the x directionsy - The factor used to scale all coordinates in the y direction
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 point
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 origin
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||