jdraw.graphics
Class LineObject

java.lang.Object
  |
  +--jdraw.graphics.GraphicObject
        |
        +--jdraw.graphics.LineObject
All Implemented Interfaces:
java.io.Serializable

public class LineObject
extends GraphicObject

Class LineObject is the GraphicObject extension which holds a single line shape.

See Also:
Serialized Form

Field Summary
protected  java.awt.Point firstPoint
          Need to save a reference to initial point.
 
Fields inherited from class jdraw.graphics.GraphicObject
arrowsOn, backgroundColor, color, controlPoints, graphicType, paint, shape, stroke
 
Constructor Summary
LineObject(java.awt.Color c, java.awt.Color bgc, java.util.Vector p, java.util.Vector cPoints, java.awt.BasicStroke bs, int arrows)
          Construct this with the given Shape, Color, FillStyle, and ControlPoints objects.
LineObject(java.awt.Point pt1, java.awt.Point pt2, java.awt.Color c, java.awt.Color bgc, java.util.Vector p, java.awt.BasicStroke bs, int arrows)
          Construct this with the given Points, Colors, FillStyle, BasicStroke objects.
 
Method Summary
 java.lang.Object clone()
          Returns a derived copy of this.
 java.awt.geom.GeneralPath deriveImage(float zoom)
          Method deriveImage creates the GeneralPath object which will represent this shape on screen, given the passed in zoom factor.
 void draw(java.awt.Graphics2D g2D, float zoom)
          Draws this.shape on the given Graphics2D object.
 java.util.Vector getSaveBundle()
          Returns a saveBundle (Vector) derived from the information contained in this.
 boolean isPointOnShape(java.awt.Point clickedPoint)
          Returns a boolean value representing whether the given Point resides on this.shape.
 void setArrows(int arrows)
          Empty method which is overwritten in Line, Polyline, and Curve.
 void setControlPoints()
          Sets this.controlPoints based on the current PathIterator of this.shape.
 void setSecondPoint(java.awt.Point pt2)
          Sets the opposite corner of the Shape from firstPoint.
 void setShape()
          Sets this.shape based on the points currently in this.controlPoints.
 void translate(float deltaX, float deltaY)
          Translates the position of this.shape by the given deltaX and deltaY values.
 
Methods inherited from class jdraw.graphics.GraphicObject
addPoint, containedIn, flipHorizontally, flipVertically, getBackgroundColor, getColor, getControlPoints, getGraphicType, getMaxX, getMaxY, getMinX, getMinY, getShape, getStroke, getTouchedControlPoint, rotate, setBackgroundColor, setColor, setHorizontalCenter, setLastPoint, setMaxX, setMaxY, setMinX, setMinY, setPaint, setStroke, setVerticalCenter, translateControlPoint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstPoint

protected java.awt.Point firstPoint
Need to save a reference to initial point.
Constructor Detail

LineObject

public LineObject(java.awt.Color c,
                  java.awt.Color bgc,
                  java.util.Vector p,
                  java.util.Vector cPoints,
                  java.awt.BasicStroke bs,
                  int arrows)
Construct this with the given Shape, Color, FillStyle, and ControlPoints objects.
Parameters:
c - - The Color object to store in this.color.
bgc - - The Color object to store in this.backgroundColor.
p - - The Vector to store in this.paint.
cPoints - - Vector object to store in this.controlPoints.
bs - - The BasicStroke object to store in this.stroke.
arrows - - The int value indicating which (if any) arrow heads to draw.

LineObject

public LineObject(java.awt.Point pt1,
                  java.awt.Point pt2,
                  java.awt.Color c,
                  java.awt.Color bgc,
                  java.util.Vector p,
                  java.awt.BasicStroke bs,
                  int arrows)
Construct this with the given Points, Colors, FillStyle, BasicStroke objects.
Parameters:
pt1 - - The Point object at which to start the GeneralPath.
pt2 - - The Point object at the opposite corner of the shape from pt1
c - - The Color object to store in this.color.
bgc - - The Color object to store in this.backgroundColor.
p - - The Vector to store in this.paint.
bs - - The BasicStroke object to store in this.stroke.
arrows - - The int value indicating which (if any) arrow heads to draw.
Method Detail

clone

public java.lang.Object clone()
Returns a derived copy of this. returns - A copy of this.
Overrides:
clone in class GraphicObject

setSecondPoint

public void setSecondPoint(java.awt.Point pt2)
Sets the opposite corner of the Shape from firstPoint.
Overrides:
setSecondPoint in class GraphicObject
Parameters:
pt2 - - The Point object used with firstPoint to build this.shape.

isPointOnShape

public boolean isPointOnShape(java.awt.Point clickedPoint)
Returns a boolean value representing whether the given Point resides on this.shape.
Overrides:
isPointOnShape in class GraphicObject
Parameters:
clickedPoint - - The Point object represent the position of a mouse click.
Returns:
- The boolean value described above.

draw

public void draw(java.awt.Graphics2D g2D,
                 float zoom)
Draws this.shape on the given Graphics2D object.
Overrides:
draw in class GraphicObject
Parameters:
g2D - - The Graphics2D object on which to draw this.shape.

setShape

public void setShape()
Sets this.shape based on the points currently in this.controlPoints.
Overrides:
setShape in class GraphicObject

deriveImage

public java.awt.geom.GeneralPath deriveImage(float zoom)
Method deriveImage creates the GeneralPath object which will represent this shape on screen, given the passed in zoom factor.
Overrides:
deriveImage in class GraphicObject
Parameters:
zoom - - The float value indicating the current zoom factor.

getSaveBundle

public java.util.Vector getSaveBundle()
Returns a saveBundle (Vector) derived from the information contained in this.
Overrides:
getSaveBundle in class GraphicObject

setControlPoints

public void setControlPoints()
Sets this.controlPoints based on the current PathIterator of this.shape.
Overrides:
setControlPoints in class GraphicObject

translate

public void translate(float deltaX,
                      float deltaY)
Translates the position of this.shape by the given deltaX and deltaY values.
Overrides:
translate in class GraphicObject
Parameters:
deltaX - - The int value by which to alter the X position of this.shape.
deltaY - - The int value by which to alter the Y position of this.shape.

setArrows

public void setArrows(int arrows)
Description copied from class: GraphicObject
Empty method which is overwritten in Line, Polyline, and Curve.
Overrides:
setArrows in class GraphicObject
Parameters:
arrows - - The int value to be copied to this.arrowsOn.