Packagecom.yworks.canvas.drawing
Classpublic class GridPaintable
InheritanceGridPaintable Inheritance Object
Implements IDisplayObjectCreator

A display object creator which can be added to a background group to paint a grid on its created display object.



Public Properties
 PropertyDefined By
  gridInfo : GridInfo
The grid info that describes the geometry of the grid.
GridPaintable
  gridStyle : Object
The grid style that is used by this implementation.
GridPaintable
  stroke : IStroke
The stroke to use for painting the grid.
GridPaintable
  visibilityThreshold : Number
The visibility threshold indicates the minimum distance in the view coordinate system between two grid points.
GridPaintable
  visible : Boolean
If the grid shall be visible.
GridPaintable
Public Methods
 MethodDefined By
  
GridPaintable(gridInfo:GridInfo = null, stroke:IStroke = null)
Creates a new instance which will render the grid with the given grid size.
GridPaintable
  
GridPaintable
  
Paints the grid by delegating to a paint method matching the gridStyle.
GridPaintable
  
updateDisplayObject(oldDisplayObject:DisplayObject, context:IDisplayObjectContext):DisplayObject
GridPaintable
Protected Methods
 MethodDefined By
  
drawCrossPoint(g:YGraphics, ctx:IPaintContext, x:Number, y:Number, dx:Number, dy:Number):void
Draws a single cross point at the given location.
GridPaintable
  
drawDotPoint(g:YGraphics, ctx:IPaintContext, x:Number, y:Number):void
Draws a small cross as single dot point at the given location.
GridPaintable
  
Paints a cross at each visible grid point by delegating to drawCrossPoint.
GridPaintable
  
Paints a dot at each visible grid point by delegating to drawDotPoint.
GridPaintable
  
Paints horizontal and vertical lines through all visible grid points.
GridPaintable
Public Constants
 ConstantDefined By
  GRID_STYLE_CROSSES : Object = GRID_STYLE_CROSSES
[static] For each grid point there is a small cross rendered.
GridPaintable
  GRID_STYLE_DOTS : Object = GRID_STYLE_DOTS
[static] For each grid point there is a small dot rendered.
GridPaintable
  GRID_STYLE_LINES : Object = GRID_STYLE_LINES
[static] Draws horizontal and vertical lines through the grid points.
GridPaintable
Property Detail
gridInfoproperty
gridInfo:GridInfo

The grid info that describes the geometry of the grid.


Implementation
    public function get gridInfo():GridInfo
    public function set gridInfo(value:GridInfo):void
gridStyleproperty 
gridStyle:Object

The grid style that is used by this implementation.

The default value is GridPaintable#GRID_STYLE_DOTS.


Implementation
    public function get gridStyle():Object
    public function set gridStyle(value:Object):void

See also

strokeproperty 
stroke:IStroke

The stroke to use for painting the grid.


Implementation
    public function get stroke():IStroke
    public function set stroke(value:IStroke):void
visibilityThresholdproperty 
visibilityThreshold:Number

The visibility threshold indicates the minimum distance in the view coordinate system between two grid points. If the distance becomes smaller, the grid will not be rendered.

The default value is 10.


Implementation
    public function get visibilityThreshold():Number
    public function set visibilityThreshold(value:Number):void
visibleproperty 
visible:Boolean

If the grid shall be visible. If false no grid is painted.

The default value is true.


Implementation
    public function get visible():Boolean
    public function set visible(value:Boolean):void
Constructor Detail
GridPaintable()Constructor
public function GridPaintable(gridInfo:GridInfo = null, stroke:IStroke = null)

Creates a new instance which will render the grid with the given grid size.

Parameters
gridInfo:GridInfo (default = null) — The info describing the grid.
 
stroke:IStroke (default = null) — The stroke used to paint the grid.
Method Detail
createDisplayObject()method
public function createDisplayObject(context:IDisplayObjectContext):DisplayObject

Parameters

context:IDisplayObjectContext

Returns
DisplayObject
drawCrossPoint()method 
protected function drawCrossPoint(g:YGraphics, ctx:IPaintContext, x:Number, y:Number, dx:Number, dy:Number):void

Draws a single cross point at the given location.

Parameters

g:YGraphics — The graphics object to draw on.
 
ctx:IPaintContext — The paint context.
 
x:Number — The horizontal location of the center of the cross to draw.
 
y:Number — The vertical location of the center of the cross to draw.
 
dx:Number — The distance the cross shall stretch horizontally from the center.
 
dy:Number — The distance the cross shall stretch vertically from the center.

drawDotPoint()method 
protected function drawDotPoint(g:YGraphics, ctx:IPaintContext, x:Number, y:Number):void

Draws a small cross as single dot point at the given location.

Parameters

g:YGraphics — The graphics object to draw on.
 
ctx:IPaintContext — The paint context.
 
x:Number — The horizontal location of the center of the dot to draw.
 
y:Number — The vertical location of the center of the dot to draw.

paint()method 
public function paint(g:YGraphics, ctx:IPaintContext):void

Paints the grid by delegating to a paint method matching the gridStyle.

Parameters

g:YGraphics — The graphics context.
 
ctx:IPaintContext — The paint context.

See also

paintCrosses()method 
protected function paintCrosses(g:YGraphics, ctx:IPaintContext):void

Paints a cross at each visible grid point by delegating to drawCrossPoint.

Parameters

g:YGraphics — The graphics object to draw on.
 
ctx:IPaintContext — The paint context.

See also

paintDots()method 
protected function paintDots(g:YGraphics, ctx:IPaintContext):void

Paints a dot at each visible grid point by delegating to drawDotPoint.

Parameters

g:YGraphics — The graphics object to draw on.
 
ctx:IPaintContext — The paint context.

See also

paintLines()method 
protected function paintLines(g:YGraphics, ctx:IPaintContext):void

Paints horizontal and vertical lines through all visible grid points.

Parameters

g:YGraphics — The graphics object to draw on.
 
ctx:IPaintContext — The paint context.

updateDisplayObject()method 
public function updateDisplayObject(oldDisplayObject:DisplayObject, context:IDisplayObjectContext):DisplayObject

Parameters

oldDisplayObject:DisplayObject
 
context:IDisplayObjectContext

Returns
DisplayObject
Constant Detail
GRID_STYLE_CROSSESConstant
public static const GRID_STYLE_CROSSES:Object = GRID_STYLE_CROSSES

For each grid point there is a small cross rendered.

GRID_STYLE_DOTSConstant 
public static const GRID_STYLE_DOTS:Object = GRID_STYLE_DOTS

For each grid point there is a small dot rendered.

GRID_STYLE_LINESConstant 
public static const GRID_STYLE_LINES:Object = GRID_STYLE_LINES

Draws horizontal and vertical lines through the grid points.