Package breadboards
Class GLine
- java.lang.Object
-
- breadboards.GObject
-
- breadboards.GLine
-
-
Field Summary
Fields Modifier and Type Field Description doubleLINE_TOLERANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(double px, double py)returns true if (x,y) is sufficiently close (i.e., within LINE_TOLERANCE) to the segmentvoiddraw(java.awt.Graphics g)draws the GLine (generally not called directly)GRectanglegetBounds()returns the bounding rectangle of the GLinejava.awt.ColorgetColor()returns color of GLineGPointgetEndPoint()returns end point of the GLineGPointgetStartPoint()returns start point of the GLinevoidscale(double sf)keeping the same starting point, this scales the length of the GLine by sfvoidscale(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 syvoidsetColor(java.awt.Color color)sets the color for the GLine to the specified colorvoidsetEndPoint(double endX, double endY)sets the end point for the GLinevoidsetStartPoint(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)
-
-