Packagecom.yworks.canvas.drawing
Classpublic class GridSnapResultPaintable
InheritanceGridSnapResultPaintable Inheritance Object
Implements IDisplayObjectCreator

This class visualizes the snapping of a moved object to a grid point. It paints '+' symbols at the snappedGridPoint as well as at all eight grid points around it using horizontalSpacing and verticalSpacing of the gridInfo to determine their position. If the spacing in view coordinates between the snappedGridPoint and any of these grid points is smaller then the minimumSpacing, a grid point further away from the snappedGridPoint is used instead to fulfill the minimumSpacing. This way the snap result visualization adapts to the current zoom level but does place it's painted points only on grid coordinates.

See also

GridInfo


Public Properties
 PropertyDefined By
  gridInfo : GridInfo
The grid info containing the horizontal and vertical grid spacing.
GridSnapResultPaintable
  minimumSpacing : Number
The minimum spacing of the painted grid points around the snappedGridPoint in view coordinates .
GridSnapResultPaintable
  snappedGridPoint : IPoint
The grid point the moved object has snapped to.
GridSnapResultPaintable
  stroke : IStroke
The stroke used in the paint method.
GridSnapResultPaintable
Public Methods
 MethodDefined By
  
Creates a new DisplayObject from scratch.
GridSnapResultPaintable
  
Paints '+' symbols at the snappedGridPoint as well as at all eight grid points around it using horizontalGridWidth and verticalGridWidth to determine their position.
GridSnapResultPaintable
  
paintGridPoint(g:YGraphics, ctx:IPaintContext, x:Number, y:Number, size:Number = 4):void
Paints a '+' symbol at the given x and y coordinates stretching size long to each side.
GridSnapResultPaintable
  
updateDisplayObject(oldDisplayObject:DisplayObject, context:IDisplayObjectContext):DisplayObject
Updates the given DisplayObject or creates a new one.
GridSnapResultPaintable
Property Detail
gridInfoproperty
gridInfo:GridInfo

The grid info containing the horizontal and vertical grid spacing.


Implementation
    public function get gridInfo():GridInfo
    public function set gridInfo(value:GridInfo):void
minimumSpacingproperty 
minimumSpacing:Number

The minimum spacing of the painted grid points around the snappedGridPoint in view coordinates .

The default value is 40.


Implementation
    public function get minimumSpacing():Number
    public function set minimumSpacing(value:Number):void

See also

snappedGridPointproperty 
snappedGridPoint:IPoint

The grid point the moved object has snapped to.


Implementation
    public function get snappedGridPoint():IPoint
    public function set snappedGridPoint(value:IPoint):void
strokeproperty 
stroke:IStroke

The stroke used in the paint method.


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

See also

Method Detail
createDisplayObject()method
public function createDisplayObject(context:IDisplayObjectContext):DisplayObject

Creates a new DisplayObject from scratch.

Parameters

context:IDisplayObjectContext — The context for which the display object is created.

Returns
DisplayObject — A DisplayObject.
paint()method 
public function paint(g:YGraphics, ctx:IPaintContext):void

Paints '+' symbols at the snappedGridPoint as well as at all eight grid points around it using horizontalGridWidth and verticalGridWidth to determine their position. It delegates to paintGridPoint to paint each of these grid points.

Parameters

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

See also

snappedGridPoint
GridInfo.horizontalSpacing
GridInfo.verticalSpacing
paintGridPoint
paintGridPoint()method 
public function paintGridPoint(g:YGraphics, ctx:IPaintContext, x:Number, y:Number, size:Number = 4):void

Paints a '+' symbol at the given x and y coordinates stretching size long to each side.

Parameters

g:YGraphics — The graphics object to paint upon.
 
ctx:IPaintContext — The paint context.
 
x:Number — The horizontal position of the center of the plus sign.
 
y:Number — The vertical position of the center of the plus sign.
 
size:Number (default = 4) — The size the plus sign stretches to each side.

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

Updates the given DisplayObject or creates a new one.

Implementors can decide whether they update the given display object or create a new one. Updating can mean re-rendering or updating size and/or coordinates.

Parameters

oldDisplayObject:DisplayObject — The display object to update.
 
context:IDisplayObjectContext — The context for which the display object should be updated.

Returns
DisplayObject — The updated display object or a completely new display object.