sm
Class SMPolyLine

java.lang.Object
  extended bysm.SMShape
      extended bysm.SMPolyLine
All Implemented Interfaces:
java.lang.Cloneable, InteractiveObject

public class SMPolyLine
extends SMShape

An arbitrary shape for use with an SMCanvas. If filled, the fill paint is used to paint the interior. If outlined, the outline paint and stroke are used to draw the boundary. The shape is build using path operators such as lineTo.

Author:
Caroline Appert

Field Summary
 
Fields inherited from class sm.SMShape
cptId
 
Constructor Summary
SMPolyLine(double x, double y)
          Builds a SMPolyLine with an initial point (x, y).
SMPolyLine(double x, double y, java.awt.Paint p)
          Builds a SMPolyLine with an initial point (x, y).
SMPolyLine(double x, double y, java.awt.Paint p, java.awt.Paint o)
          Builds a SMPolyLine with an initial point (x, y).
SMPolyLine(double x, double y, java.awt.Paint p, java.awt.Paint o, java.awt.Stroke str)
          Builds a SMPolyLine with an initial point (x, y).
SMPolyLine(double x, double y, java.awt.Paint p, java.awt.Stroke str)
          Builds a SMPolyLine with an initial point (x, y).
SMPolyLine(double x, double y, java.awt.Stroke str)
          Builds a SMPolyLine with an initial point (x, y).
SMPolyLine(java.awt.geom.Point2D pt)
          Builds a SMPolyLine with an initial point pt.
SMPolyLine(java.awt.geom.Point2D pt, java.awt.Paint p)
          Builds a SMPolyLine with an initial point pt.
SMPolyLine(java.awt.geom.Point2D pt, java.awt.Paint p, java.awt.Paint o)
          Builds a SMPolyLine with an initial point pt.
SMPolyLine(java.awt.geom.Point2D pt, java.awt.Paint p, java.awt.Paint o, java.awt.Stroke str)
          Builds a SMPolyLine with an initial point pt.
SMPolyLine(java.awt.geom.Point2D pt, java.awt.Paint p, java.awt.Stroke str)
          Builds a SMPolyLine with an initial point pt.
SMPolyLine(java.awt.geom.Point2D pt, java.awt.Stroke str)
          Builds a SMPolyLine with an initial point pt.
 
Method Summary
 SMPolyLine arcTo(double start, double extent, double rx, double ry)
          Adds an arc segment to this polyline.
 SMPolyLine close()
          Closes this polyLine by drawing a straight line from the current point to the starting point.
 SMShape copyTo(SMShape sms)
          Copies this shape into a destination shape.
 SMPolyLine curveTo(double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double xEnd, double yEnd)
          Adds a cubic curve segment to this polyline.
 SMPolyLine curveTo(java.awt.geom.Point2D ptCtrl1, java.awt.geom.Point2D ptCtrl2, java.awt.geom.Point2D ptEnd)
          Adds a cubic curve segment to this polyline.
 SMShape duplicate()
          Creates a new copy of this shape and returns it.
 java.awt.geom.Point2D getCurrentPoint()
           
 SMPolyLine lineTo(double x, double y)
          Adds a line segment to this polyline from the current point to point (x, y).
 SMPolyLine lineTo(java.awt.geom.Point2D pt)
          Adds a line segment to this polyline from the current point to point pt.
 SMPolyLine moveTo(double x, double y)
          Sets the current point of this polyLine to point (x, y).
 SMPolyLine moveTo(java.awt.geom.Point2D pt)
          Sets the current point of this polyLine to point pt.
 SMPolyLine quadTo(double ctrlx1, double ctrly1, double xEnd, double yEnd)
          Adds a quadric curve segment to this polyline.
 SMPolyLine quadTo(java.awt.geom.Point2D ptCtrl, java.awt.geom.Point2D ptEnd)
          Adds a quadric curve segment to this polyline.
 SMPolyLine removeLastSegment()
          Removes the last segment of this polyline, if any.
 SMPolyLine reset(double x, double y)
          Resets this polyline to the unique point (x, y).
 SMPolyLine reset(java.awt.geom.Point2D pt)
          Resets this polyline to the unique point pt.
 
Methods inherited from class sm.SMShape
above, aboveAll, addChild, addGhost, addTag, addTag, addTag, addTo, asEllipse, asImage, asPolyLine, asRectangle, asRectangularShape, asText, attachSM, below, belowAll, canvasToShape, clone, contains, contains, contains, contains, containsPoint, containsPoint, detachSM, equals, getAbsShape, getAbsTransform, getBoundingBox, getCanvas, getCenterX, getCenterY, getChildren, getClip, getFillPaint, getHeight, getHierarchy, getID, getMaxX, getMaxY, getMinX, getMinY, getOutlinePaint, getParent, getReferenceX, getReferenceY, getRotation, getScaleX, getScaleY, getShape, getStroke, getTransform, getTranslateX, getTranslateY, getTransparency, getWidth, hasTag, hasTag, intersects, intersects, isAbove, isAntialiased, isBelow, isDrawable, isEmpty, isFilled, isOnOutline, isOutlined, isPickable, paint, remove, removeChild, removeGhost, removeTag, removeTag, rotateBy, rotateTo, scaleBy, scaleBy, scaleTo, scaleTo, setAntialiased, setClip, setDrawable, setFilled, setFillPaint, setOutlined, setOutlinePaint, setParent, setPickable, setReferencePoint, setShape, setStroke, setTransparency, shapeToCanvas, translateBy, translateTo
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMPolyLine

public SMPolyLine(double x,
                  double y,
                  java.awt.Paint p,
                  java.awt.Paint o,
                  java.awt.Stroke str)
Builds a SMPolyLine with an initial point (x, y).

Parameters:
x - The x coordinate of the initial point
y - The y coordinate of the initial point
p - The fill paint style of this SMPolyLine
o - The outline paint style of this SMPolyLine
str - The outline style of this SMPolyLine

SMPolyLine

public SMPolyLine(java.awt.geom.Point2D pt,
                  java.awt.Paint p,
                  java.awt.Paint o,
                  java.awt.Stroke str)
Builds a SMPolyLine with an initial point pt.

Parameters:
pt - The initial point
p - The fill paint style of this SMPolyLine
o - The outline paint style of this SMPolyLine
str - The outline style of this SMPolyLine

SMPolyLine

public SMPolyLine(double x,
                  double y,
                  java.awt.Paint p,
                  java.awt.Paint o)
Builds a SMPolyLine with an initial point (x, y).

Parameters:
x - The x coordinate of the initial point
y - The y coordinate of the initial point
p - The fill paint style of this SMPolyLine
o - The outline paint style of this SMPolyLine

SMPolyLine

public SMPolyLine(java.awt.geom.Point2D pt,
                  java.awt.Paint p,
                  java.awt.Paint o)
Builds a SMPolyLine with an initial point pt.

Parameters:
pt - The initial point
p - The fill paint style of this SMPolyLine
o - The outline paint style of this SMPolyLine

SMPolyLine

public SMPolyLine(double x,
                  double y,
                  java.awt.Paint p,
                  java.awt.Stroke str)
Builds a SMPolyLine with an initial point (x, y).

Parameters:
x - The x coordinate of the initial point
y - The y coordinate of the initial point
p - The fill paint style of this SMPolyLine
str - The outline style of this SMPolyLine

SMPolyLine

public SMPolyLine(java.awt.geom.Point2D pt,
                  java.awt.Paint p,
                  java.awt.Stroke str)
Builds a SMPolyLine with an initial point pt.

Parameters:
pt - The initial point
p - The fill paint style of this SMPolyLine
str - The outline style of this SMPolyLine

SMPolyLine

public SMPolyLine(double x,
                  double y,
                  java.awt.Paint p)
Builds a SMPolyLine with an initial point (x, y).

Parameters:
x - The x coordinate of the initial point
y - The y coordinate of the initial point
p - The fill paint style of this SMPolyLine

SMPolyLine

public SMPolyLine(java.awt.geom.Point2D pt,
                  java.awt.Paint p)
Builds a SMPolyLine with an initial point pt.

Parameters:
pt - The initial point
p - The fill paint style of this SMPolyLine

SMPolyLine

public SMPolyLine(double x,
                  double y,
                  java.awt.Stroke str)
Builds a SMPolyLine with an initial point (x, y).

Parameters:
x - The x coordinate of the initial point
y - The y coordinate of the initial point
str - The outline style of this SMPolyLine

SMPolyLine

public SMPolyLine(java.awt.geom.Point2D pt,
                  java.awt.Stroke str)
Builds a SMPolyLine with an initial point pt.

Parameters:
pt - The initial point
str - The outline style of this SMPolyLine

SMPolyLine

public SMPolyLine(double x,
                  double y)
Builds a SMPolyLine with an initial point (x, y).

Parameters:
x - The x coordinate of the initial point
y - The y coordinate of the initial point

SMPolyLine

public SMPolyLine(java.awt.geom.Point2D pt)
Builds a SMPolyLine with an initial point pt.

Parameters:
pt - The initial point
Method Detail

reset

public SMPolyLine reset(double x,
                        double y)
Resets this polyline to the unique point (x, y).

Parameters:
x - The x coordinate of the initial point
y - The y coordinate of the initial point
Returns:
Returns this polyLine

reset

public SMPolyLine reset(java.awt.geom.Point2D pt)
Resets this polyline to the unique point pt.

Parameters:
pt - The point
Returns:
Returns this polyLine

lineTo

public SMPolyLine lineTo(double x,
                         double y)
Adds a line segment to this polyline from the current point to point (x, y).

Parameters:
x - The x coordinate of the last point
y - the y coordinate of the last point
Returns:
Returns this polyLine

lineTo

public SMPolyLine lineTo(java.awt.geom.Point2D pt)
Adds a line segment to this polyline from the current point to point pt.

Parameters:
pt - The point
Returns:
Returns this polyLine

moveTo

public SMPolyLine moveTo(double x,
                         double y)
Sets the current point of this polyLine to point (x, y).

Parameters:
x - The x coordinate of the current point to set
y - the y coordinate of the current point to set
Returns:
Returns this polyLine

moveTo

public SMPolyLine moveTo(java.awt.geom.Point2D pt)
Sets the current point of this polyLine to point pt.

Parameters:
pt - The point
Returns:
Returns this polyLine

arcTo

public SMPolyLine arcTo(double start,
                        double extent,
                        double rx,
                        double ry)
Adds an arc segment to this polyline. The arc is part of an ellipse of x radius rx and y radius ry centered at the current point and going from angle start to angle start+extent. See further explanations here.

Parameters:
start - The starting angle of the ellipse
extent - The extent angle of the arc
rx - The x radius of the ellipse
ry - The y radius of the ellipse
Returns:
Returns this polyLine

getCurrentPoint

public java.awt.geom.Point2D getCurrentPoint()
Returns:
Returns the coordinates most recently added to the end of the path as a Point2D object.

quadTo

public SMPolyLine quadTo(double ctrlx1,
                         double ctrly1,
                         double xEnd,
                         double yEnd)
Adds a quadric curve segment to this polyline. The curved segment starts at the current point and ends (xEnd, yEnd), and uses point (ctrlx1, ctrly1) as Bezier control point.

Parameters:
ctrlx1 - The x coordinate of the first Bezier control point
ctrly1 - The y coordinate of the first Bezier control point
xEnd - The x coordinate of the end point
yEnd - The y coordinate of the end point
Returns:
Returns this polyLine

quadTo

public SMPolyLine quadTo(java.awt.geom.Point2D ptCtrl,
                         java.awt.geom.Point2D ptEnd)
Adds a quadric curve segment to this polyline. The curved segment starts at the current point and ends at ptEnd, and uses point ptCtrl as Bezier control point.

Parameters:
ptCtrl - The first Bezier control point
ptEnd - The end point
Returns:
Returns this polyLine

curveTo

public SMPolyLine curveTo(double ctrlx1,
                          double ctrly1,
                          double ctrlx2,
                          double ctrly2,
                          double xEnd,
                          double yEnd)
Adds a cubic curve segment to this polyline. The curved segment starts at the current point and ends (xEnd, yEnd), and uses points (ctrlx1, ctrly1) and (ctrlx2, ctrly2) as Bezier control points.

Parameters:
ctrlx1 - The x coordinate of the first Bezier control point
ctrly1 - The y coordinate of the first Bezier control point
ctrlx2 - The x coordinate of the second Bezier control point
ctrly2 - The y coordinate of the second Bezier control point
xEnd - The x coordinate of the ending point
yEnd - The y coordinate of the ending point
Returns:
Returns this polyLine

curveTo

public SMPolyLine curveTo(java.awt.geom.Point2D ptCtrl1,
                          java.awt.geom.Point2D ptCtrl2,
                          java.awt.geom.Point2D ptEnd)
Adds a cubic curve segment to this polyline. The curved segment starts at the current point and ends at ptEnd, and uses points ptCtrl1 and ptCtrl2 as Bezier control points.

Parameters:
ptCtrl1 - The first Bezier control point
ptCtrl2 - The second Bezier control point
ptEnd - The ending point
Returns:
Returns this polyLine

close

public SMPolyLine close()
Closes this polyLine by drawing a straight line from the current point to the starting point.

Returns:
Returns this polyLine

removeLastSegment

public SMPolyLine removeLastSegment()
Removes the last segment of this polyline, if any.

Returns:
Returns this polyline

copyTo

public SMShape copyTo(SMShape sms)
Description copied from class: SMShape
Copies this shape into a destination shape. The copy differs from the original as follows: If this shape is in a canvas, the copy is added to that canvas, on top all other objects; The copy has no children, i.e. it is not the parent of any shape, even if the original has.

Overrides:
copyTo in class SMShape
Parameters:
sms - The destination shape
Returns:
Returns this shape

duplicate

public SMShape duplicate()
Creates a new copy of this shape and returns it.

Overrides:
duplicate in class SMShape
Returns:
Returns the copy.