Packagecom.yworks.canvas.drawing
Classpublic class AdvancedStroke
InheritanceAdvancedStroke Inheritance mx.graphics.Stroke
Implements IAdvancedStroke
Subclasses LineType

A advanced stroke implementation that allows drawing dotted/dashed strokes.



Public Properties
 PropertyDefined By
  pattern : Array
Get or set the pattern used for drawing dashed/dotted strokes.
AdvancedStroke
Public Methods
 MethodDefined By
  
AdvancedStroke(color:uint = 0, weight:Number = 0, alpha:Number = 1.0, dashPattern:Array = null, pixelHinting:Boolean = false, scaleMode:String, caps:String = null, joints:String = null, miterLimit:Number = 0)
Create a new stroke instance with the given stroke properties.
AdvancedStroke
  
drawCurve(currentX:Number, currentY:Number, toX:Number, toY:Number, cx:Number, cy:Number, graphics:YGraphics, targetGraphics:Graphics):void
Draw a quadratic bezier curve from (x0,y0) to (x1,y1) using the control point at (cx,cy).
AdvancedStroke
  
drawLine(currentX:Number, currentY:Number, x1:Number, y1:Number, graphics:YGraphics, targetGraphics:Graphics):void
Draw a straight line from the current graphics location to (toX,toY)
AdvancedStroke
  
drawPath(path:GeneralPath, graphics:YGraphics, targetGraphics:Graphics):void
Draw a path.
AdvancedStroke
  
reset(graphics:YGraphics, targetGraphics:Graphics):void
Reset the stroke state.
AdvancedStroke
Property Detail
patternproperty
pattern:Array

Get or set the pattern used for drawing dashed/dotted strokes.

Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes (e.g. [2,1] defines a dashed line where a segment of length 2 is opaque, the next segment has the length 1 and is transparent, and so on...).

The length of the pattern array should contain an even number of elements.


Implementation
    public function get pattern():Array
    public function set pattern(value:Array):void
Constructor Detail
AdvancedStroke()Constructor
public function AdvancedStroke(color:uint = 0, weight:Number = 0, alpha:Number = 1.0, dashPattern:Array = null, pixelHinting:Boolean = false, scaleMode:String, caps:String = null, joints:String = null, miterLimit:Number = 0)

Create a new stroke instance with the given stroke properties.

Parameters
color:uint (default = 0) — The line color.
 
weight:Number (default = 0) — The line weight, in pixels.
 
alpha:Number (default = 1.0) — The alpha value in the range 0.0 to 1.0.
 
dashPattern:Array (default = null) — The dash pattern to use for dashed lines.

Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes (e.g. [2,1] defines a dashed line where a segment of length 2 is opaque, the next segment has the length 1 and is transparent, and so on...).

The length of the given pattern array should contain an even number of elements.

 
pixelHinting:Boolean (default = false) — Specifies whether to hint strokes to full pixels. This value affects both the position of anchors of a curve and the line stroke size itself.
 
scaleMode:String (default = NaN) — Specifies how to scale a stroke. Valid values are "normal", "none", "vertical", and "noScale".
 
caps:String (default = null) — Specifies the type of caps at the end of lines. Valid values are "round", "square", and "none".
 
joints:String (default = null) — Specifies the type of joint appearance used at angles. Valid values are "round", "miter", and "bevel".

Note: setting joints to "miter" can seriously slow down rendering!

 
miterLimit:Number (default = 0) — Indicates the limit at which a miter is cut off. Valid values range from 0 to 255.
Method Detail
drawCurve()method
public function drawCurve(currentX:Number, currentY:Number, toX:Number, toY:Number, cx:Number, cy:Number, graphics:YGraphics, targetGraphics:Graphics):void

Draw a quadratic bezier curve from (x0,y0) to (x1,y1) using the control point at (cx,cy).

Note that no moveTo operation should be called on the targetGraphics that moves to (currentX,currentY). The targetGraphics current location will already be set to (x0,y0).

Parameters

currentX:Number — The x-coordinate of the current graphics location (the first anchor point of the curve)
 
currentY:Number — The y-coordinate of the current graphics location (the first anchor point of the curve)
 
toX:Number — The x-coordinate of the curve's second anchor point
 
toY:Number — The y-coordinate of the curve's second anchor point
 
cx:Number — The x-coordinate of the curve's the control point
 
cy:Number — The y-coordinate of the curve's control point
 
graphics:YGraphics — The YGraphics instance that wants to draw the curve
 
targetGraphics:Graphics — The graphics instance that should be used for actual drawing. The current location of the graphics instance is already set to currentX,currentY

drawLine()method 
public function drawLine(currentX:Number, currentY:Number, x1:Number, y1:Number, graphics:YGraphics, targetGraphics:Graphics):void

Draw a straight line from the current graphics location to (toX,toY)

Parameters

currentX:Number — The x-coordinate of the current graphics location
 
currentY:Number — The y-coordinate of the current graphics location
 
x1:Number — The x-coordinate of the line's end point
 
y1:Number — The y-coordinate of the line's end point
 
graphics:YGraphics — The YGraphics instance that wants to draw the line
 
targetGraphics:Graphics — The graphics instance that should be used for actual drawing. The current location of the graphics instance is already set to currentX,currentY

drawPath()method 
public function drawPath(path:GeneralPath, graphics:YGraphics, targetGraphics:Graphics):void

Draw a path.

Parameters

path:GeneralPath — The path to be drawn
 
graphics:YGraphics — The YGraphics instance that wants to draw the path
 
targetGraphics:Graphics — The graphics instance that should be used for actual drawing

reset()method 
public function reset(graphics:YGraphics, targetGraphics:Graphics):void

Reset the stroke state.

This is called by YGraphics when a moveTo or endFill is requested.

Parameters

graphics:YGraphics — The YGraphics instance that wants to reset the stroke state.
 
targetGraphics:Graphics — The graphics instance that should be used for actual drawing