Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.nwoods.jgo
Class JGoStroke

    java.lang.Object
      com.nwoods.jgo.JGoObject
          com.nwoods.jgo.JGoDrawable
              com.nwoods.jgo.JGoStroke

All Implemented Interfaces:
  JGoXMLSaveRestore, java.io.Serializable

Direct Known Subclasses:
  JGoLink, JGoPolygon

public class JGoStroke
extends JGoDrawable

JGoStroke is a JGoObject that represents a poly line. In other words, it is an object made up of an arbirary number of line segments, where each segment shares two endpoints with other segments, except the first and last segments.

The appearance (color, thickness, style) of the stroke is determined by the pen; change it by calling setPen().

Manipulate stroke points by using the addPoint(), setPoint(), insertPoint(), removePoint(), removeAllPoints() and getNumPoints() methods. Stroke points are indexed by integers starting with 0.

By default there is an implied directionality of the stroke. It defines the "from" end as the first point of the stroke and the "to" end as the last point of the stroke.

The stroke can be shown with a highlight. Specify the highlight pen; by default there is no highlight. The highlight is achieved by drawing the stroke twice: first the highlight and then the regular stroke. Usually the highlight pen should be significantly wider than the stroke's regular pen. Note that this highlight is not a selection indication. If you do want to change the stroke (and thus the document) when a view on the document selects this stroke to use this highlight to indicate selection, you should override gainedSelection and lostSelection to set the highlight pen.

Each stroke supports optional arrow heads at either end of the stroke. Arrow heads are drawn as four-sided polygons with a solid pen of width 1; the stroke's brush is used to fill the arrow head.

- the first point is on the "shaft", the line between the end point and the next-to-end point, at a distance of getArrowShaftLength() from the end point
- the third point is at the stroke's end point and forms the arrow head's "point"; the value of getArrowWidth() determines how sharp or blunt the arrow head appears
- the second and fourth points are at a distance of getArrowLength() from the end point along the shaft, but are off of the shaft on opposite sides to form the angle at the third point (the end point)

You can get a triangular arrow head by setting the ArrowShaftLength to be equal to the ArrowLength. You can get a diamond arrow head by setting the ArrowShaftLength to be twice the ArrowLength. You can get a simple line drawn arrow head by setting the ArrowShaftLength to zero.

Both arrow heads will always point "out". In other words, calling setArrowHeads(true, true) will produce a stroke pointing "both ways". If you want the decoration at the "from" end to be something different than an arrow head, you will have to override drawArrowhead() and do your own drawing.

The ArrowLength, ArrowShaftLength, and ArrowWidth properties are double-float values.

See Also:
  Serialized Form

Field Summary
`static int` | `ChangedAddPoint` a CHANGED event hint: a stroke point has been added
`static int` | `ChangedAllPoints` a CHANGED event hint: all stroke points have been changed.
`static int` | `ChangedArrowAngle` Deprecated. functionality changed; use ChangedArrowWidth instead
`static int` | `ChangedArrowHeads` a CHANGED event hint: changed the presence of arrow heads at the either end of the stroke
`static int` | `ChangedArrowLength` a CHANGED event hint: changed the length of the arrow heads
`static int` | `ChangedArrowShaftLength` a CHANGED event hint: changed the length of the arrow heads on the stroke
`static int` | `ChangedArrowWidth` a CHANGED event hint: changed the length of the arrow heads
`static int` | `ChangedCubic` a CHANGED event hint: the highlighting of the stroke has changed
`static int` | `ChangedHighlight` a CHANGED event hint: the highlighting of the stroke has changed
`static int` | `ChangedModifiedPoint` a CHANGED event hint: a stroke point has changed position
`static int` | `ChangedRemovePoint` a CHANGED event hint: one or more stroke points have been removed
`protected java.util.ArrayList` | `myPoints` the list of points in this stroke.

Fields inherited from class com.nwoods.jgo.JGoObject
`Bottom, BottomCenter, BottomLeft, BottomMiddle, BottomRight, Center, CenterLeft, CenterRight, Changed4ResizeHandles, ChangedAutoRescale, ChangedBrush, ChangedDraggable, ChangedDragsNode, ChangedGeometry, ChangedGrabChildSelection, ChangedInitializing, ChangedPen, ChangedResizable, ChangedSelectable, ChangedUpdatePartner, ChangedVisible, ChangedZOrder, LastChangedHint, Left, LeftCenter, NoHandle, NoSpot, NumReservedHandles, RepaintAll, Right, RightCenter, SideLeft, SideRight, Top, TopCenter, TopLeft, TopMiddle, TopRight`

Constructor Summary
`JGoStroke()` Create a new stroke with no points in it.

Method Summary
`int` | `addPoint(int x, int y)` Add a point to the stroke.
`int` | `addPoint(java.awt.Point point)` Add a point to the stroke.
`protected void` | `calculateFilledArrowhead(int x0, int y0, int x1, int y1, int atend, int[] headx, int[] heady)` Used to calculate a polygon for an arrowhead at the end of the line (x0,y0) --> (x1,y1).
`void` | `changeValue(JGoDocumentChangedEdit e, boolean undo)` This method is called by the JGoDocumentChangedEdit.undo and redo methods to actually perform the property value change for a JGoObject.
`protected java.awt.Rectangle` | `computeBoundingRect()` Compute the bounds of this stroke by determining the bounding rectangle for all of the points.
`void` | `copyNewValueForRedo(JGoDocumentChangedEdit e)` This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed.
`JGoObject` | `copyObject(JGoCopyEnvironment env)` Create a copy of the JGoStroke, including the points that define it.
`void` | `copyOldValueForUndo(JGoDocumentChangedEdit e)` This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed.
`java.util.Vector` | `copyPoints()` Return a copy of the Vector of Points representing the points of this stroke.
`java.util.ArrayList` | `copyPointsArray()` Return a copy of the ArrayList of Points representing the points of this stroke.
`protected void` | `drawArrowhead(java.awt.Graphics2D g, boolean atend, int[] headx, int[] heady)` Draw the arrow head, given the X and Y arrays for the four points used in the polygon for the arrow head.
`protected void` | `drawArrowHeads(java.awt.Graphics2D g)` Draw the arrowheads on the screen.
`void` | `expandRectByPenWidth(java.awt.Rectangle rect)` Modify the given rectangle representing an object's bounding rectangle to account for any additional drawing region caused by the thickness of the pen.
`protected void` | `gainedSelection(JGoSelection selection)` Called whenever this stroke is added to a selection in some view.
`protected void` | `geometryChange(java.awt.Rectangle prevRect)` Called if we're moved or scaled.
`double` | `getArrowAngle()` Deprecated. use getArrowWidth instead
`java.awt.Point` | `getArrowFromAnchorPoint()` Return the anchor point of the "From" arrow, in document coordinates
`java.awt.Point` | `getArrowFromEndPoint()` Return the end point of the "From" arrow, in document coordinates
`double` | `getArrowLength()` Return the overall length of the arrowhead.
`double` | `getArrowShaftLength()` Return the length of the arrowhead along the stroke.
`java.awt.Point` | `getArrowToAnchorPoint()` Return the anchor point of the "To" arrow, in document coordinates
`java.awt.Point` | `getArrowToEndPoint()` Return the end point of the "To" arrow, in document coordinates
`double` | `getArrowWidth()` Return the width of the arrowhead, perpendicular to the shaft.
`java.awt.Point` | `getEndPoint()` Return the ending point for this line.
`int` | `getFirstPickPoint()` Return the first point which can be selected and moved.
`JGoPen` | `getHighlight()` Returns the current highlighting pen for this stroke.
`int` | `getLastPickPoint()` Return the last point that can be selected and moved.
`static boolean` | `getNearestIntersectionOnLine(int Ax, int Ay, int Bx, int By, int Px, int Py, int Qx, int Qy, java.awt.Point R)` Find the intersection point of the finite line segment A-B and the infinite line P-Q that is closest to point P.
`boolean` | `getNearestIntersectionPoint(int px, int py, int cx, int cy, java.awt.Point result)` Consider each segment, whether straight or cubic/Bezier, when finding nearest the intersection with a line.
`static boolean` | `getNearestPointOnLine(int Ax, int Ay, int Bx, int By, int Px, int Py, java.awt.Point R)` Return a point on a straight line segment that is closest to a given point.
`static boolean` | `getNearestPointOnLine(java.awt.Point A, java.awt.Point B, java.awt.Point P, java.awt.Point R)` Return a point on a straight line segment that is closest to a given point.
`int` | `getNumPoints()` Get the number of points in this stroke.
`java.awt.Point` | `getPoint(int i)` Return a point given its index.
`int` | `getPointX(int i)` Return the X coordinate for the point at the given index.
`int` | `getPointY(int i)` Return the Y coordinate for the point at the given index.
`int` | `getSegmentNearPoint(java.awt.Point pnt)` Return the segment which is close to the given point, if any.
`java.awt.Point` | `getStartPoint()` Return the starting point for this line.
`java.awt.Rectangle` | `handleResize(java.awt.Graphics2D g, JGoView view, java.awt.Rectangle prevRect, java.awt.Point newPoint, int whichHandle, int event, int minWidth, int minHeight)` Called as we are moving a point in the stroke.
`boolean` | `hasArrowAtEnd()` Return whether or not this line has an arrowhead at its end.
`boolean` | `hasArrowAtStart()` Return whether or not this line has an arrowhead at its start.
`int` | `insertPoint(int i, int x, int y)` Add a point to the stroke at a particular position in the stroke's list of points.
`int` | `insertPoint(int i, java.awt.Point point)` Add a point to the stroke at a particular position in the stroke's list of points.
`boolean` | `isCubic()` Return whether the style of this stroke is Cubic (Bezier).
`boolean` | `isPointInObj(java.awt.Point pnt)` Checks whether or not the given point is on or near the stroke.
`void` | `paint(java.awt.Graphics2D g, JGoView view)` Draw the stroke on the graphics context.
`void` | `removeAllPoints()` Delete all the points from the stroke.
`void` | `removePoint(int i)` Remove the point from the stroke given its index.
`void` | `setArrowAngle(double angle)` Deprecated. use setArrowWidth instead
`void` | `setArrowHeads(boolean from, boolean to)` Sets whether or not there are arrow heads at either end of this line.
`void` | `setArrowLength(double len)` Set the overall length of the arrowhead.
`void` | `setArrowShaftLength(double len)` Set the length of the arrowhead on the stroke, to determine the fullness of the arrowhead.
`void` | `setArrowWidth(double width)` Set the width of the arrowhead, measured as the widest distance perpendicular to the arrow's shaft.
`void` | `setCubic(boolean c)` Set whether the points in this stroke are to be interpreted as the start, two control, and end points of a Cubic (Bezier) curve.
`void` | `setHighlight(JGoPen pen)` Sets the current "pen stroke" to use when drawing the highlight for this stroke.
`void` | `setPoint(int i, int x, int y)` Change the location of the given point.
`void` | `setPoint(int i, java.awt.Point point)` Change the location of the given point.
`void` | `setPoints(java.util.ArrayList points)` Reset all of the points of this stroke to instead be the points in the given ArrayList of points.
`void` | `setPoints(java.util.Vector points)` Reset all of the points of this stroke to instead be the points in the given Vector of points.
`DomNode` | `SVGReadObject(DomDoc svgDoc, JGoDocument jGoDoc, DomElement svgElement, DomElement jGoChildElement)` Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document.
`void` | `SVGUpdateReference(java.lang.String attr, java.lang.Object referencedObject)` This method will be called to fill in object references.
`void` | `SVGWriteObject(DomDoc svgDoc, DomElement jGoElementGroup)` Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

Methods inherited from class com.nwoods.jgo.JGoDrawable
`draw3DRect, draw3DRect, drawEllipse, drawEllipse, drawEllipse, drawLine, drawLine, drawPath, drawPolygon, drawPolygon, drawRect, drawRect, drawRect, drawRoundRect, drawRoundRect, getBrush, getPen, setBrush, setPen, SVGAddPathArgs, SVGReadAttributes, SVGWriteAttributes`

Methods inherited from class com.nwoods.jgo.JGoObject
`canView, computeMove, computeResize, copy, copyObjectDelayed, copyRect, doMouseClick, doMouseDblClick, doUncapturedMouseMove, findCommonParent, foredate, geometryChangeChild, getBoundingRect, getDocument, getDraggingObject, getFlags, getHeight, getLayer, getLeft, getLocation, getLocation, getParent, getParentJGoNode, getParentNode, getPartner, getRectangleSpotLocation, getSize, getSize, getSpotLocation, getSpotLocation, getToolTipText, getTop, getTopLeft, getTopLeft, getTopLevelObject, getView, getWidth, growRect, handleMove, hideSelectionHandles, is4ResizeHandles, isAutoRescale, isBoundingRectInvalid, isChildOf, isDraggable, isDragsNode, isInitializing, isResizable, isSelectable, isSkipsUndoManager, isSuspendChildUpdates, isSuspendUpdates, isTopLevel, isUpdatePartner, isVisible, lostSelection, ownerChange, partnerUpdate, pick, redirectSelection, remove, set4ResizeHandles, setAutoRescale, setBoundingRect, setBoundingRect, setBoundingRect, setBoundingRectForce, setBoundingRectForce, setBoundingRectInvalid, setBoundsRect, setDraggable, setDragsNode, setFlags, setHeight, setInitializing, setLeft, setLocation, setLocation, setLocationOffset, setLocationOffset, setParent, setPartner, setRectangleSpotLocation, setResizable, setSelectable, setSize, setSize, setSizeKeepingLocation, setSkipsUndoManager, setSpotLocation, setSpotLocation, setSpotLocation, setSpotLocationOffset, setSuspendChildUpdates, setSuspendUpdates, setTop, setTopLeft, setTopLeft, setUpdatePartner, setVisible, setWidth, showSelectionHandles, spotOpposite, update, update`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ChangedAddPoint

    public static final int ChangedAddPoint

  a CHANGED event hint: a stroke point has been added

  See Also:
    Constant Field Values

### ChangedRemovePoint

    public static final int ChangedRemovePoint

  a CHANGED event hint: one or more stroke points have been removed

  See Also:
    Constant Field Values

### ChangedModifiedPoint

    public static final int ChangedModifiedPoint

  a CHANGED event hint: a stroke point has changed position

  See Also:
    Constant Field Values

### ChangedArrowHeads

    public static final int ChangedArrowHeads

  a CHANGED event hint: changed the presence of arrow heads at the either end of the stroke

  See Also:
    Constant Field Values

### ChangedArrowLength

    public static final int ChangedArrowLength

  a CHANGED event hint: changed the length of the arrow heads

  See Also:
    Constant Field Values

### ChangedArrowShaftLength

    public static final int ChangedArrowShaftLength

  a CHANGED event hint: changed the length of the arrow heads on the stroke

  See Also:
    Constant Field Values

### ChangedArrowAngle

    public static final int ChangedArrowAngle

  Deprecated. functionality changed; use ChangedArrowWidth instead

  See Also:
    Constant Field Values

### ChangedHighlight

    public static final int ChangedHighlight

  a CHANGED event hint: the highlighting of the stroke has changed

  See Also:
    Constant Field Values

### ChangedCubic

    public static final int ChangedCubic

  a CHANGED event hint: the highlighting of the stroke has changed

  See Also:
    Constant Field Values

### ChangedAllPoints

    public static final int ChangedAllPoints

  a CHANGED event hint: all stroke points have been changed. These event come in pairs: one before any points are changed, caused by a call to JGoObject.foredate, and one after the change, caused by a call to JGoObject.update.

  See Also:
    Constant Field Values

### ChangedArrowWidth

    public static final int ChangedArrowWidth

  a CHANGED event hint: changed the length of the arrow heads

  See Also:
    Constant Field Values

### myPoints

    protected java.util.ArrayList myPoints

  the list of points in this stroke.

Constructor Detail

### JGoStroke

    public JGoStroke()

  Create a new stroke with no points in it.

  By default it draws a thin black line (JGoPen.black) and fills any arrowheads with black (JGoBrush.black).

Method Detail

### copyObject

    public JGoObject copyObject(JGoCopyEnvironment env)

  Create a copy of the JGoStroke, including the points that define it.

  Overrides:
    `copyObject` in class `JGoDrawable`
  Parameters:
    `env` - the environment for the copy operation - keeps track of copied objects.

### SVGWriteObject

    public void SVGWriteObject(DomDoc svgDoc,
                               DomElement jGoElementGroup)

  Description copied from interface: `JGoXMLSaveRestore`
  Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

  This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGWriteDoc() for every JGoObject contained within a JGoDocument. The following example uses a JGoRectangle to illustrate the format of a generated SVG JGoObject:

  <g>
  <JGoClass class="com.nwoods.jgo.JGoRectangle"\>
  <rect height="75" style="stroke:black;stroke-width:1;fill:rgb(255,0,0);" width="75" x="65" y="71"/>
  <JGoClass class="com.nwoods.jgo.JGoDrawable" drawablebrush="jgoid1" drawablepen="jgoid2" embeddedpenbrush="false"/>
  <JGoClass class="com.nwoods.jgo.JGoObject" obj_flags="1054"/>
  </g>

  Note that the entire JGoObject is enclosed in a group (<g>). Each subclass of the JGoObject is described by a <JGoClass> element, starting with the most specific class and moving to the more general. Each <JGoClass> element has a "class" attribute which defines the class name. Each <JGoClass> element may also have several other attributes which uniquely describe that state of that class. Following the <JGoClass> element, each class may also genereate any other elements that are required, including representations of contained objects and standard SVG elements such as the <rect> element shown in the above example. The generation of SVG elements in the output makes it possible for the output to be read by SVG viewers and other SVG aware applications. The information contained in the <JGoClass> elements allows us to accurately save and restore all the information in a particular JGoObject subclass.

  If this class contains a reference to another object, call DomDoc.registerReferencingNode() to register that reference. This will cause the element representing the referenced object to be identified with a unique id attribute, and cause the element representing the referring object to have a user defined attribute containing a reference to that id. See DomDoc.registerReferencingNode() for more information.

  Typically, an implementation of this method will generate a <JGoClass> element using the DomDoc.createJGoClassElement() method, adding whatever attributes are necessary to describe the class. It will then call its superclass so that the superclass can add its own <JGoClass> element and other information to jGoElementGroup within the DomDoc.

  Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGWriteObject() and com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for examples using this method.

  Refer to the file com.nwoods.jgo.svg\xsvg.dtd for a formal description of JGo extensions to the SVG document type.

  Specified by:
    `SVGWriteObject` in interface `JGoXMLSaveRestore`
  Overrides:
    `SVGWriteObject` in class `JGoDrawable`

### SVGReadObject

    public DomNode SVGReadObject(DomDoc svgDoc,
                                 JGoDocument jGoDoc,
                                 DomElement svgElement,
                                 DomElement jGoChildElement)

  Description copied from interface: `JGoXMLSaveRestore`
  Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

  This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() for every <JGoClass> element encountered in a DomDoc. First, an object of the type specified by the class attribute will be created and then the SVGReadObject() method will be called on that newly created object. Refer to SVGWriteObject() for a description of the expected format of the SVG document.

  This method may also be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() when reading any SVG document, including those not generated by JGo and therefore not containing any <JGoClass> elements. In such cases, the DefaultDocument.SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard JGoObjects such as JGoRectangles, JGoStrokes, etc will be created to represent these objects.

  If this class contains a reference to another object, call DomDoc.registerReferencingObject() to register that reference. This will cause the JGoObject.SVGUpdateReference() to be called on the referencing object after all the objects have been created, passing in the object befing referenced. See DomDoc.registerReferencingObject() for more information.

  Typically, an implementation of this method starts by verifying that the element being read is a <JGoClass> element (which will be true if jGoChildElement is not null). This will always be true unless you have subclassed the DefaultDocument.SVGReadElement() method as described above. It will then read the expected attributes of the <JGoClass> element (as written by SVGReadObject()), call SVGReadObject() on its superclass, and finally return the next element by calling svgElement.getNextSibling().

  Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGReadObject() and com.nwoods.jgo.examples.SimpleNode.SVGReadObject() for examples using this method.

  Specified by:
    `SVGReadObject` in interface `JGoXMLSaveRestore`
  Overrides:
    `SVGReadObject` in class `JGoDrawable`

### SVGUpdateReference

    public void SVGUpdateReference(java.lang.String attr,
                                   java.lang.Object referencedObject)

  Description copied from class: `JGoObject`
  This method will be called to fill in object references.

  This is called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() after all the objects have been created and if DomDoc.registerReferencingObject() has been previously called by SVGReadObject().

  Typically, an implementation of this method will first call the superclass and then fill in the appropriate object reference based on the attr argument.

  Refer to com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for an example using this method.

  Overrides:
    `SVGUpdateReference` in class `JGoDrawable`

### paint

    public void paint(java.awt.Graphics2D g,
                      JGoView view)

  Draw the stroke on the graphics context.

  Overrides:
    `paint` in class `JGoObject`
  Parameters:
    `g` - the graphics context on which to draw.
    `view` - the view we're drawing in

### isCubic

    public boolean isCubic()

  Return whether the style of this stroke is Cubic (Bezier). By default this is false.

### setCubic

    public void setCubic(boolean c)

  Set whether the points in this stroke are to be interpreted as the start, two control, and end points of a Cubic (Bezier) curve.

  When there are more than four points, the end point of the first Bezier segment is used as the start point for the next Bezier segment. If the number of points is not exactly one more than a multiple of three, the last segment uses the last two points as the second control point and the end point and it ignores the one or two points just before the last two. If there are fewer than four points, this stroke cannot be drawn as a Bezier curve, but will be drawn as straight line segments when there are two or three points.

### addPoint

    public final int addPoint(java.awt.Point point)

  Add a point to the stroke. A line will be drawn from the previous point to this point.

  Parameters:
    `point` - the point to add.
  Returns:
    the index of the new point.

### addPoint

    public int addPoint(int x,
                        int y)

  Add a point to the stroke. A line will be drawn from the previous point to this point.

  Parameters:
    `x` - the x coordinate of the new point to add.
    `y` - the y coordinate of the new point to add.
  Returns:
    the index of the new point.

### insertPoint

    public final int insertPoint(int i,
                                 java.awt.Point point)

  Add a point to the stroke at a particular position in the stroke's list of points.

  Parameters:
    `i` - the index of the new point
    `point` - the point to add.
  Returns:
    the index of the new point

### insertPoint

    public int insertPoint(int i,
                           int x,
                           int y)

  Add a point to the stroke at a particular position in the stroke's list of points. Any points at that index and above get shifted up to make room for the new point.

  Parameters:
    `i` - the index of the new point
    `x` - the x coordinate of the new point to add
    `y` - the y coordinate of the new point to add
  Returns:
    the index of the new point

### removePoint

    public void removePoint(int i)

  Remove the point from the stroke given its index.

  Parameters:
    `i` - the index of the point to remove.

### getPoint

    public java.awt.Point getPoint(int i)

  Return a point given its index.

  The returned point must not be modified; to change the position of a point one must call setPoint().

  Parameters:
    `i` - the index of the point to return.
  Returns:
    the point at the given index.

### getPointX

    public int getPointX(int i)

  Return the X coordinate for the point at the given index. If the index does not specify a valid point, the return value is meaningless.

  Parameters:
    `i` - the index of the point whose X coordinate we return,

### getPointY

    public int getPointY(int i)

  Return the Y coordinate for the point at the given index. If the index does not specify a valid point, the return value is meaningless.

  Parameters:
    `i` - the index of the point whose Y coordinate we return,

### setPoint

    public final void setPoint(int i,
                               java.awt.Point point)

  Change the location of the given point.

  Parameters:
    `i` - the index of the point to change.
    `point` - the new location for the point.

### setPoint

    public void setPoint(int i,
                         int x,
                         int y)

  Change the location of the given point. If an out-of-bounds index is given, this is a no-op.

  Parameters:
    `i` - the index of the point to change.
    `x` - the new x coordinate location for the point.
    `y` - the new y coordinate location for the point.

### removeAllPoints

    public void removeAllPoints()

  Delete all the points from the stroke.

### setPoints

    public void setPoints(java.util.Vector points)

  Reset all of the points of this stroke to instead be the points in the given Vector of points. The Point coordinates are copied by this stroke.

  Parameters:
    `points` - a Vector of Point references

### setPoints

    public void setPoints(java.util.ArrayList points)

  Reset all of the points of this stroke to instead be the points in the given ArrayList of points. The Point coordinates are copied by this stroke.

  Parameters:
    `points` - a ArrayList of Point references

### copyPoints

    public java.util.Vector copyPoints()

  Return a copy of the Vector of Points representing the points of this stroke. The Point coordinates are copied for the newly allocated Vector that is returned.

### copyPointsArray

    public java.util.ArrayList copyPointsArray()

  Return a copy of the ArrayList of Points representing the points of this stroke. The Point coordinates are copied for the newly allocated ArrayList that is returned.

### getNumPoints

    public int getNumPoints()

  Get the number of points in this stroke.

  Returns:
    the number of points in this stroke.

### getStartPoint

    public java.awt.Point getStartPoint()

  Return the starting point for this line.

  Returns:
    getPoint(0)

### getEndPoint

    public java.awt.Point getEndPoint()

  Return the ending point for this line.

  Returns:
    getPoint(getNumPoints()-1)

### getFirstPickPoint

    public int getFirstPickPoint()

  Return the first point which can be selected and moved. The default is the first point in the stroke.

  Subclasses should override this function if they want something other than the default behavior.

  Returns:
    the first point which can be selected

### getLastPickPoint

    public int getLastPickPoint()

  Return the last point that can be selected and moved. The default is the last point in the stroke.

  Subclasses should override this function if they want something other than the default behavior.

  Returns:
    the last point which can be selected

### handleResize

    public java.awt.Rectangle handleResize(java.awt.Graphics2D g,
                                           JGoView view,
                                           java.awt.Rectangle prevRect,
                                           java.awt.Point newPoint,
                                           int whichHandle,
                                           int event,
                                           int minWidth,
                                           int minHeight)

  Called as we are moving a point in the stroke. We take care of updating the stroke.

  Overrides:
    `handleResize` in class `JGoObject`
  Parameters:
    `g` - the graphics context to draw on
    `view` - the view we're being resizing in
    `prevRect` - the previous bounding rectangle (unused)
    `newPoint` - the location of the new point
    `whichHandle` - the handle number of the point being moved
    `event` - the event
    `minWidth` - the minimum width of the object (unused)
    `minHeight` - the minimim height of the object (unused)

### geometryChange

    protected void geometryChange(java.awt.Rectangle prevRect)

  Called if we're moved or scaled. We must update all of our points.

  Overrides:
    `geometryChange` in class `JGoObject`
  Parameters:
    `prevRect` - this stroke's previous rectangle.

### gainedSelection

    protected void gainedSelection(JGoSelection selection)

  Called whenever this stroke is added to a selection in some view.

  The default behavior creates resize handles at each of the stroke's points.

  Overrides:
    `gainedSelection` in class `JGoObject`
  Parameters:
    `selection` - the selection to which this object was added

### computeBoundingRect

    protected java.awt.Rectangle computeBoundingRect()

  Compute the bounds of this stroke by determining the bounding rectangle for all of the points.

  Overrides:
    `computeBoundingRect` in class `JGoObject`

### expandRectByPenWidth

    public void expandRectByPenWidth(java.awt.Rectangle rect)

  Modify the given rectangle representing an object's bounding rectangle to account for any additional drawing region caused by the thickness of the pen.

  Overrides:
    `expandRectByPenWidth` in class `JGoDrawable`
  Parameters:
    `rect` - the rectangle to be enlarged

### isPointInObj

    public boolean isPointInObj(java.awt.Point pnt)

  Checks whether or not the given point is on or near the stroke.

  Overrides:
    `isPointInObj` in class `JGoObject`
  Parameters:
    `pnt` - the point to check
  Returns:
    true if pnt is in this object

### getSegmentNearPoint

    public int getSegmentNearPoint(java.awt.Point pnt)

  Return the segment which is close to the given point, if any. The segment is identified by the index of its first stroke point.

  This returns -1 if the given point is not at all near the stroke, or if it is in the bounding rectangle but not near any segment. For Bezier style strokes, the index of the first of each set of points is returned, e.g. 0, 3, 7, ....

  Parameters:
    `pnt` - the point to check

### getNearestPointOnLine

    public static boolean getNearestPointOnLine(java.awt.Point A,
                                                java.awt.Point B,
                                                java.awt.Point P,
                                                java.awt.Point R)

  Return a point on a straight line segment that is closest to a given point.

  Parameters:
    `A` - one end of the line segment
    `B` - the other end of the line segment
    `P` - the point to be closest to
    `R` - a Point that is modified to hold a point that is on the finite length straight line segment from A to B
  Returns:
    the result of the overloaded method that takes the individual coordinates rather than Points.

### getNearestPointOnLine

    public static boolean getNearestPointOnLine(int Ax,
                                                int Ay,
                                                int Bx,
                                                int By,
                                                int Px,
                                                int Py,
                                                java.awt.Point R)

  Return a point on a straight line segment that is closest to a given point.

  All coordinates are in document coordinates.

  Parameters:
    `Ax` - the X coordinate of one end of the line segment
    `Ay` - the Y coordinate of one end of the line segment
    `Bx` - the X coordinate of the other end of the line segment
    `By` - the Y coordinate of the other end of the line segment
    `Px` - the X coordinate of the point to be closest to
    `Py` - the Y coordinate of the point to be closest to
    `R` - a Point that is modified to hold a point that is on the finite length straight line segment from A to B
  Returns:
    true if the point is on a perpendicular line to the line segment; false if the point is beyond either end of the line segment

### getNearestIntersectionOnLine

    public static boolean getNearestIntersectionOnLine(int Ax,
                                                       int Ay,
                                                       int Bx,
                                                       int By,
                                                       int Px,
                                                       int Py,
                                                       int Qx,
                                                       int Qy,
                                                       java.awt.Point R)

  Find the intersection point of the finite line segment A-B and the infinite line P-Q that is closest to point P.

  Parameters:
    `Ax` - the X coordinate of one end of the line segment
    `Ay` - the Y coordinate of one end of the line segment
    `Bx` - the X coordinate of the other end of the line segment
    `By` - the Y coordinate of the other end of the line segment
    `Px` - the X coordinate of the point to be closest to
    `Py` - the Y coordinate of the point to be closest to
    `Qx` - the X coordinate of a point describing the infinite line from P
    `Qy` - the Y coordinate of a point describing the infinite line from P
    `R` - a Point that is modified to hold the intersection point that is on the finite length straight line segment from A to B
  Returns:
    true if the parameter R now holds the intersection point on segment A-B; false if the there is no intersection point--either the lines are parallel or the intersection is beyond the ends of the segment A-B

### getNearestIntersectionPoint

    public boolean getNearestIntersectionPoint(int px,
                                               int py,
                                               int cx,
                                               int cy,
                                               java.awt.Point result)

  Consider each segment, whether straight or cubic/Bezier, when finding nearest the intersection with a line.

  Overrides:
    `getNearestIntersectionPoint` in class `JGoDrawable`

### setArrowHeads

    public void setArrowHeads(boolean from,
                              boolean to)

  Sets whether or not there are arrow heads at either end of this line.

  Parameters:
    `from` - if true, draw an arrow head at the end of the line.
    `to` - if true, draw an arrow head at the start of the line.

### hasArrowAtEnd

    public boolean hasArrowAtEnd()

  Return whether or not this line has an arrowhead at its end.

  Returns:
    true if the stroke has an arrow at the end

### hasArrowAtStart

    public boolean hasArrowAtStart()

  Return whether or not this line has an arrowhead at its start.

  Returns:
    true if the stroke has an arrow at the start

### getArrowToEndPoint

    public java.awt.Point getArrowToEndPoint()

  Return the end point of the "To" arrow, in document coordinates

### getArrowToAnchorPoint

    public java.awt.Point getArrowToAnchorPoint()

  Return the anchor point of the "To" arrow, in document coordinates

### getArrowFromEndPoint

    public java.awt.Point getArrowFromEndPoint()

  Return the end point of the "From" arrow, in document coordinates

### getArrowFromAnchorPoint

    public java.awt.Point getArrowFromAnchorPoint()

  Return the anchor point of the "From" arrow, in document coordinates

### setArrowLength

    public void setArrowLength(double len)

  Set the overall length of the arrowhead.

  Parameters:
    `len` - the length of the arrowhead

### getArrowLength

    public double getArrowLength()

  Return the overall length of the arrowhead.

  This defaults to 10.

### setArrowShaftLength

    public void setArrowShaftLength(double len)

  Set the length of the arrowhead on the stroke, to determine the fullness of the arrowhead.

  Parameters:
    `len` - the length of the arrowhead

### getArrowShaftLength

    public double getArrowShaftLength()

  Return the length of the arrowhead along the stroke.

  This defaults to 8.

### setArrowAngle

    public void setArrowAngle(double angle)

  Deprecated. use setArrowWidth instead

### getArrowAngle

    public double getArrowAngle()

  Deprecated. use getArrowWidth instead

### setArrowWidth

    public void setArrowWidth(double width)

  Set the width of the arrowhead, measured as the widest distance perpendicular to the arrow's shaft. The value must be non-negative.

### getArrowWidth

    public double getArrowWidth()

  Return the width of the arrowhead, perpendicular to the shaft.

### drawArrowHeads

    protected void drawArrowHeads(java.awt.Graphics2D g)

  Draw the arrowheads on the screen. This calls calculateFilledArrowhead and drawArrowhead for each end of the stroke that has an arrowhead, as determined by hasArrowAtEnd and hasArrowAtStart.

  Parameters:
    `g` - the graphics context on which to draw

### calculateFilledArrowhead

    protected void calculateFilledArrowhead(int x0,
                                            int y0,
                                            int x1,
                                            int y1,
                                            int atend,
                                            int[] headx,
                                            int[] heady)

  Used to calculate a polygon for an arrowhead at the end of the line (x0,y0) --> (x1,y1). The polygon points are returned in headx[] and heady[], which are int arrays of size 4.

### drawArrowhead

    protected void drawArrowhead(java.awt.Graphics2D g,
                                 boolean atend,
                                 int[] headx,
                                 int[] heady)

  Draw the arrow head, given the X and Y arrays for the four points used in the polygon for the arrow head.

  By default this draws a filled polygon with a solid pen of width 1 with the same color as the rest of the stroke.

### setHighlight

    public void setHighlight(JGoPen pen)

  Sets the current "pen stroke" to use when drawing the highlight for this stroke. Specifying a value of null will turn off any highlighting.

  Parameters:
    `pen` - the pen to use when drawing the highlight

### getHighlight

    public JGoPen getHighlight()

  Returns the current highlighting pen for this stroke. By default this is null; the stroke does not have any highlighting.

  Returns:
    the highlight pen

### copyOldValueForUndo

    public void copyOldValueForUndo(JGoDocumentChangedEdit e)

  Description copied from class: `JGoObject`
  This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. The previous value Object provided by the JGoObject.update method might be altered by future changes. But losing that state would make it hard for the JGoDocumentChangedEdit to perform an undo correctly. In these cases it is important for the JGoDocumentChangedEdit to make a copy of the Object value, by calling setOldValue with a copy of the getOldValue Object.

  The exact nature of the Object depends on the particular event hint or sub-hint, of course, but is typically a Rectangle or Point or some similar structure that is actually owned by the object. The responsibility for copying rests with the document event listener rather than the code calling JGoObject.update for efficiency when there is no undo/redo manager.

  Overrides:
    `copyOldValueForUndo` in class `JGoObject`
  Parameters:
    `e` - the UndoableEdit that also remembers the kind of change and any appropriate previous state that should be copied in-place

### copyNewValueForRedo

    public void copyNewValueForRedo(JGoDocumentChangedEdit e)

  Description copied from class: `JGoObject`
  This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. In order for the JGoDocumentChangedEdit to be able to perform a redo, it needs to remember the new property value or state. However, the JGoObject.update method does not provide such a new value. The value must be taken from this object and copied into the JGoDocumentChangedEdit by calling setNewValue and/or setNewValueInt.

  Just as the previous/old value/state information is stored as one or both of an integer and an Object, the new value/state information may be stored as either or both of an integer or an Object.

  The responsibility for copying rests with the document event listener rather than the code calling JGoObject.update for efficiency when there is no undo/redo manager.

  Overrides:
    `copyNewValueForRedo` in class `JGoDrawable`

### changeValue

    public void changeValue(JGoDocumentChangedEdit e,
                            boolean undo)

  Description copied from class: `JGoObject`
  This method is called by the JGoDocumentChangedEdit.undo and redo methods to actually perform the property value change for a JGoObject.

  You will want to override this method to handle changing the additional state of your object subclasses.

  Overrides:
    `changeValue` in class `JGoDrawable`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD