Package breadboards
Class GLine
- java.lang.Object
-
- breadboards.GObject
-
- breadboards.GLine
-
-
Field Summary
Fields Modifier and Type Field Description double
LINE_TOLERANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(double px, double py)
returns true if (x,y) is sufficiently close (i.e., within LINE_TOLERANCE) to the segmentvoid
draw(java.awt.Graphics g)
draws the GLine (generally not called directly)GRectangle
getBounds()
returns the bounding rectangle of the GLinejava.awt.Color
getColor()
returns color of GLineGPoint
getEndPoint()
returns end point of the GLineGPoint
getStartPoint()
returns start point of the GLinevoid
scale(double sf)
keeping the same starting point, this scales the length of the GLine by sfvoid
scale(double sx, double sy)
keeping the same starting point, this scales the horizontal component of the GLine's length by sx, and the vertical component by syvoid
setColor(java.awt.Color color)
sets the color for the GLine to the specified colorvoid
setEndPoint(double endX, double endY)
sets the end point for the GLinevoid
setStartPoint(double startX, double startY)
sets the start point for the GLine-
Methods inherited from class breadboards.GObject
addMouseListener, addMouseMotionListener, getBreadboard, getLocation, getMouseListeners, getMouseMotionListeners, getParent, getX, getY, isVisible, move, movePolar, removeMouseListener, removeMouseMotionListener, sendBackward, sendForward, sendToBack, sendToFront, setLocation, setParent, setVisible, setX, setY, updateBreadboard
-
-
-
-
Field Detail
-
LINE_TOLERANCE
public final double LINE_TOLERANCE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GLine
public GLine()
constructs a zero-length segment from (0,0) to itself
-
GLine
public GLine(double x0, double y0, double x1, double y1)
constructs a segment from (x0,y0) to (x1,y1)- Parameters:
x0
- x-coordinate of starting pointy0
- y-coordinate of starting pointx1
- x-coordinate of end pointy1
- y-coordinate of end point
-
-
Method Detail
-
getBounds
public GRectangle getBounds()
returns the bounding rectangle of the GLine
-
getEndPoint
public GPoint getEndPoint()
returns end point of the GLine- Returns:
- end point of the GLine
-
getStartPoint
public GPoint getStartPoint()
returns start point of the GLine- Returns:
- start point of the GLine
-
getColor
public java.awt.Color getColor()
returns color of GLine- Returns:
- color of GLine
-
setStartPoint
public void setStartPoint(double startX, double startY)
sets the start point for the GLine- Parameters:
startX
- x-coordinate for starting pointstartY
- y-coordinate for starting point
-
setEndPoint
public void setEndPoint(double endX, double endY)
sets the end point for the GLine- Parameters:
endX
- x-coordinate for end pointendY
- y-coordinate for end point
-
setColor
public void setColor(java.awt.Color color)
sets the color for the GLine to the specified color- Parameters:
color
- the specified color for the GLine
-
scale
public void scale(double sx, double sy)
keeping the same starting point, this scales the horizontal component of the GLine's length by sx, and the vertical component by sy- Parameters:
sx
- the horizontal scaling factorsy
- the vertical scaling factor
-
scale
public void scale(double sf)
keeping the same starting point, this scales the length of the GLine by sf- Parameters:
sf
- the scaling factor
-
contains
public boolean contains(double px, double py)
returns true if (x,y) is sufficiently close (i.e., within LINE_TOLERANCE) to the segment
-
draw
public void draw(java.awt.Graphics g)
draws the GLine (generally not called directly)
-
-