com.sencha.gxt.chart.client.draw.path
Class PathSprite

java.lang.Object
  extended by com.sencha.gxt.chart.client.draw.sprite.Sprite
      extended by com.sencha.gxt.chart.client.draw.path.PathSprite

public class PathSprite
extends Sprite

A Sprite that represents a path. Also contains utility functions for path manipulation.


Constructor Summary
PathSprite()
          Creates a path with no values.
PathSprite(CircleSprite sprite)
          Creates a path sprite by converting the given CircleSprite.
PathSprite(EllipseSprite sprite)
          Creates a path sprite by converting the given EllipseSprite.
PathSprite(PathSprite path)
          Creates a copy of the given path.
PathSprite(RectangleSprite sprite)
          Creates a path sprite by converting the given RectangleSprite.
PathSprite(TextSprite sprite)
          Creates a path sprite by converting the given TextSprite.
 
Method Summary
 void addCommand(int index, PathCommand command)
          Adds a PathCommand to the path at the given index.
 void addCommand(PathCommand command)
          Adds a PathCommand to the path.
 void clearCommands()
          Clears all PathCommand in the path.
 void clearDirtyFlags()
          Clears all of the dirty flags on the sprite.
 PathSprite copy()
          Returns a copy of the sprite.
static List<PathCommand> copyCommands(List<PathCommand> commands)
          Returns a new list of PathCommands by making copies of the given commands.
 PreciseRectangle dimensions()
          Returns the calculated dimensions of the path.
static List<PathSprite> findDelta(PathSprite origin, List<PathCommand> commands)
          Ensures PathCommand parity between this path and the given path.
 PathCommand getCommand(int index)
          Returns the PathCommand at the given index.
 List<PathCommand> getCommands()
          Returns a List of all the PathCommands in the sprite.
 double getMiterLimit()
          Returns the miter limit of the path.
 PathSprite getPathSprite()
          Returns the Sprite as a path.
 Context2d.LineCap getStrokeLineCap()
          Returns the shape to be used at the end of open subpaths when they are stroked.
 Context2d.LineJoin getStrokeLineJoin()
          Returns the Context2d.LineJoin of the path.
 boolean isAbsolute()
          Returns true if all path commands are absolute.
 boolean isCurved()
          Returns true if all path commands are MoveTo or CurveTo commands.
 boolean isDirty()
          Returns true if the sprite changed since the last render.
 boolean isMiterLimitDirty()
          Returns true if the miter limit changed since the last render.
 boolean isPathDirty()
          Returns true if the path changed since the last render.
 boolean isStrokeLineCapDirty()
          Returns true if the line cap changed since the last render.
 boolean isStrokeLineJoinDirty()
          Returns true if the line join changed since the last render.
 PathSprite map(Matrix matrix)
          Transforms the PathSprite by the passed Matrix.
 void removeCommand(int index)
          Removes the PathCommand at the given index.
 void setCommand(int index, PathCommand command)
          Sets the PathCommand of the path at given index.
 void setCommands(List<PathCommand> commands)
          Replace the path's PathCommands with the given List of commands.
 void setMiterLimit(double miterLimit)
          Sets miter limit of the path.
 void setStrokeLineCap(Context2d.LineCap strokeLineCap)
          Sets the Context2d.LineCap of the path.
 void setStrokeLineJoin(Context2d.LineJoin strokeLineJoin)
          Sets the Context2d.LineJoin of the path.
 int size()
          Returns the number of PathCommands added to the sprite.
 PathSprite toAbsolute()
          Returns the path converted to only absolute PathCommands.
 PathSprite toCurve()
          Returns the path converted to only MoveTo and CurveTo commands.
 PathSprite toSmooth(int subsections)
          Returns the path smoothed by increasing the number of subsections.
 String toString()
           
 
Methods inherited from class com.sencha.gxt.chart.client.draw.sprite.Sprite
getBBox, getClipRectangle, getComponent, getFill, getFillOpacity, getOpacity, getRotation, getScaling, getStroke, getStrokeOpacity, getStrokeWidth, getSurface, getTranslation, getzIndex, isClipRectangleDirty, isFillDirty, isFillOpacityDirty, isHidden, isHiddenDirty, isOpacityDirty, isStrokeDirty, isStrokeOpacityDirty, isStrokeWidthDirty, isTransformDirty, isZIndexDirty, redraw, remove, setClipRectangle, setComponent, setCursor, setFill, setFillOpacity, setHidden, setOpacity, setRotation, setRotation, setRotation, setScaling, setScaling, setScaling, setStroke, setStrokeOpacity, setStrokeWidth, setSurface, setTranslation, setTranslation, setZIndex, transformMatrix, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathSprite

public PathSprite()
Creates a path with no values.


PathSprite

public PathSprite(CircleSprite sprite)
Creates a path sprite by converting the given CircleSprite.

Parameters:
sprite - the circle sprite to be converted to a path

PathSprite

public PathSprite(EllipseSprite sprite)
Creates a path sprite by converting the given EllipseSprite.

Parameters:
sprite - the ellipse sprite to be converted to a path

PathSprite

public PathSprite(PathSprite path)
Creates a copy of the given path.

Parameters:
path - the sprite to be copied

PathSprite

public PathSprite(RectangleSprite sprite)
Creates a path sprite by converting the given RectangleSprite.

Parameters:
sprite - the rectangle sprite to be converted to a path

PathSprite

public PathSprite(TextSprite sprite)
Creates a path sprite by converting the given TextSprite.

Parameters:
sprite - the text sprite to be converted to a path
Method Detail

copyCommands

public static List<PathCommand> copyCommands(List<PathCommand> commands)
Returns a new list of PathCommands by making copies of the given commands.

Parameters:
commands - the commands to be copied
Returns:
the new list

findDelta

public static List<PathSprite> findDelta(PathSprite origin,
                                         List<PathCommand> commands)
Ensures PathCommand parity between this path and the given path.

Parameters:
origin - the path to be compared
commands - the path commands to compare against
Returns:
list of the converted path and the delta between the target commands

addCommand

public void addCommand(int index,
                       PathCommand command)
Adds a PathCommand to the path at the given index.

Parameters:
index - the index to add the command
command - the path command to add

addCommand

public void addCommand(PathCommand command)
Adds a PathCommand to the path.

Parameters:
command - the path command to add

clearCommands

public void clearCommands()
Clears all PathCommand in the path.


clearDirtyFlags

public void clearDirtyFlags()
Description copied from class: Sprite
Clears all of the dirty flags on the sprite.

Overrides:
clearDirtyFlags in class Sprite

copy

public PathSprite copy()
Description copied from class: Sprite
Returns a copy of the sprite.

Specified by:
copy in class Sprite
Returns:
copy of the sprite

dimensions

public PreciseRectangle dimensions()
Returns the calculated dimensions of the path.

Returns:
the calculated dimensions of the path

getCommand

public PathCommand getCommand(int index)
Returns the PathCommand at the given index.

Parameters:
index - the index of the command to return
Returns:
the requested command

getCommands

public List<PathCommand> getCommands()
Returns a List of all the PathCommands in the sprite.

Returns:
a list of all the commands in the sprite

getMiterLimit

public double getMiterLimit()
Returns the miter limit of the path.

Returns:
the miter limit of the path

getPathSprite

public PathSprite getPathSprite()
Description copied from class: Sprite
Returns the Sprite as a path.

Specified by:
getPathSprite in class Sprite
Returns:
the sprite as a path

getStrokeLineCap

public Context2d.LineCap getStrokeLineCap()
Returns the shape to be used at the end of open subpaths when they are stroked.

Returns:
the shape to be used at the end of open subpaths when they are stroked

getStrokeLineJoin

public Context2d.LineJoin getStrokeLineJoin()
Returns the Context2d.LineJoin of the path.

Returns:
the line join of the path

isAbsolute

public boolean isAbsolute()
Returns true if all path commands are absolute.

Returns:
true if all path commands are absolute

isCurved

public boolean isCurved()
Returns true if all path commands are MoveTo or CurveTo commands.

Returns:
true if all path commands are moveto or curveto commands

isDirty

public boolean isDirty()
Description copied from class: Sprite
Returns true if the sprite changed since the last render.

Overrides:
isDirty in class Sprite
Returns:
true if the sprite changed since the last render

isMiterLimitDirty

public boolean isMiterLimitDirty()
Returns true if the miter limit changed since the last render.

Returns:
true if the miter limit changed since the last render

isPathDirty

public boolean isPathDirty()
Returns true if the path changed since the last render.

Returns:
true if the path changed since the last render

isStrokeLineCapDirty

public boolean isStrokeLineCapDirty()
Returns true if the line cap changed since the last render.

Returns:
true if the line cap changed since the last render

isStrokeLineJoinDirty

public boolean isStrokeLineJoinDirty()
Returns true if the line join changed since the last render.

Returns:
true if the line join changed since the last render

map

public PathSprite map(Matrix matrix)
Transforms the PathSprite by the passed Matrix.

Parameters:
matrix - the transformation Matrix
Returns:
the transformed PathSprite

removeCommand

public void removeCommand(int index)
Removes the PathCommand at the given index.

Parameters:
index - the index of the command

setCommand

public void setCommand(int index,
                       PathCommand command)
Sets the PathCommand of the path at given index.

Parameters:
index - the index of the command to be set
command - the command to be set

setCommands

public void setCommands(List<PathCommand> commands)
Replace the path's PathCommands with the given List of commands.

Parameters:
commands - the new list of commands

setMiterLimit

public void setMiterLimit(double miterLimit)
Sets miter limit of the path. Determines the limit on the ratio of the miter length to the stroke width.

Parameters:
miterLimit - the new miter limit of the path

setStrokeLineCap

public void setStrokeLineCap(Context2d.LineCap strokeLineCap)
Sets the Context2d.LineCap of the path. Determines the shape to be used at the end of open subpaths.

Parameters:
strokeLineCap - the line cap of the path

setStrokeLineJoin

public void setStrokeLineJoin(Context2d.LineJoin strokeLineJoin)
Sets the Context2d.LineJoin of the path. Determines the shape to be used at the corners of paths.

Parameters:
strokeLineJoin - the line join of the path

size

public int size()
Returns the number of PathCommands added to the sprite.

Returns:
the number of commands added to the sprite

toAbsolute

public PathSprite toAbsolute()
Returns the path converted to only absolute PathCommands.

Returns:
the path converted to only absolute commands

toCurve

public PathSprite toCurve()
Returns the path converted to only MoveTo and CurveTo commands.

Returns:
the path converted to only move and curve commands

toSmooth

public PathSprite toSmooth(int subsections)
Returns the path smoothed by increasing the number of subsections. The subdivisions is determined by the given subsections. The resultant path will be made of CurveTo commands.

Parameters:
subsections - the number of subdivisions used in the smoothing function; must be no less than 4
Returns:
the smoothed path

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.