Packagecom.yworks.canvas.drawing
Classpublic class ShapePaintable
InheritanceShapePaintable Inheritance Object
Implements IDisplayObjectCreator, IPaintable, IBoundsProvider, IHitTestable, IMarqueeTestable
Subclasses GeneralPathVisualCreator

Provides a number of IDisplayObjectCreator implementations for simple geometric primitives. This is an abstract class that provides a number of factory methods that each return a concrete subclass of this.



Public Properties
 PropertyDefined By
  fill : IFill
The fill to use for painting in the created DisplayObject.
ShapePaintable
  stroke : IStroke
The stroke to use for painting in the created DisplayObject.
ShapePaintable
Public Methods
 MethodDefined By
  
Returns a tight rectangular area where the whole rendering would fit into.
ShapePaintable
  
Creates a new DisplayObject from scratch.
ShapePaintable
  
createFixedViewEllipse(center:IPoint, width:Number, height:Number):ShapePaintable
[static] Creates a dynamic display object creator that will use an IPoint to draw and fill an ellipse in the created DisplayObject in the view coordinate system with a zoom level invariant width and height.
ShapePaintable
  
[static] Creates a dynamic display object creator that draws a given path in the created DisplayObject.
ShapePaintable
  
createPointModelEllipse(center:IPoint, width:Number, height:Number):ShapePaintable
[static] Creates a dynamic display object creator that will use an IPoint to draw and fill an ellipse in the created DisplayObject.
ShapePaintable
  
[static] Creates a dynamic display object creator that will use two points to draw a rectangle in the created DisplayObject.
ShapePaintable
  
[static]
ShapePaintable
  
[static] Creates a dynamic display object creator that will use an IRectangle to draw and fill a rectangle in the created DisplayObject.
ShapePaintable
  
[static] Creates a dynamic display object creator that will use a IOrientedRectangle to draw and fill an IOrientedRectangle in the created DisplayObject in the view coordinate system.
ShapePaintable
  
[static] Creates a dynamic display object creator that will use a IRectangle to draw and fill a rectangle in the created DisplayObject in the view coordinate system.
ShapePaintable
  
isHit(x:Number, y:Number, ctx:ICanvasContext):Boolean
Determines if something has been hit at the given coordinates in the world coordinate system.
ShapePaintable
  
Implements the IMarqueeTestable interface and tests for marquee intersections with the shape.
ShapePaintable
  
Performs the actual painting into the given graphics context.
ShapePaintable
  
updateDisplayObject(oldDisplayObject:DisplayObject, context:IDisplayObjectContext):DisplayObject
Updates the given DisplayObject or creates a new one.
ShapePaintable
Property Detail
fillproperty
fill:IFill

The fill to use for painting in the created DisplayObject.


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

The stroke to use for painting in the created DisplayObject.


Implementation
    public function get stroke():IStroke
    public function set stroke(value:IStroke):void
Method Detail
calculateBounds()method
public function calculateBounds(scratch:IMutableRectangle, ctx:ICanvasContext):IRectangle

Returns a tight rectangular area where the whole rendering would fit into.

Implementations can use the scratch rectangle to put their results in and return it as the result of the operation. Client has to always provide a non-null instance as a parameter. They may however decide to return an internally cached or dynamically created IRectangle implementation and disregard the scratch parameter. If calculating the bounds is too expensive or the painting is not bound to a certain area, this method may return null. If nothing is painted, this method should return an empty rectangle, where either or both the width and height is non-positive or ImmutableRectangle.Empty.

Parameters

scratch:IMutableRectangle — An instance that can optionally be used to fill with the corresponding values and be returned
 
ctx:ICanvasContext — The context to calculate the bounds for (currently not used)

Returns
IRectangle — The bounds or null to indicate an unbound area
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.
createFixedViewEllipse()method 
public static function createFixedViewEllipse(center:IPoint, width:Number, height:Number):ShapePaintable

Creates a dynamic display object creator that will use an IPoint to draw and fill an ellipse in the created DisplayObject in the view coordinate system with a zoom level invariant width and height.

Drawing in the view coordinate system will make pen widths not scale. The argument is stored by reference and is queried for each operation. Thus changing the values of the argument after the creation of the IDisplayObjectCreator will change the painting in the created DisplayObject.

Parameters

center:IPoint — he center of the ellipse to draw and fill. The point is stored in world coordinates, the width and height will be interpreted in the view coordinate system, however.
 
width:Number — The width of the ellipse.
 
height:Number — The height of the ellipse.

Returns
ShapePaintable
createPath()method 
public static function createPath(path:GeneralPath):ShapePaintable

Creates a dynamic display object creator that draws a given path in the created DisplayObject.

Parameters

path:GeneralPath — The path to draw.

Returns
ShapePaintable — An IDisplayObjectCreator that fills and draws the path in the created DisplayObject.
createPointModelEllipse()method 
public static function createPointModelEllipse(center:IPoint, width:Number, height:Number):ShapePaintable

Creates a dynamic display object creator that will use an IPoint to draw and fill an ellipse in the created DisplayObject.

The argument is stored by reference and is queried for each operation. Thus changing the values of the argument after the creation of the IDisplayObjectCreator will change the painting in the created DisplayObject.

Parameters

center:IPoint — The center of the ellipse to draw and fill.
 
width:Number — The width of the ellipse.
 
height:Number — The height of the ellipse.

Returns
ShapePaintable — A display object creator that uses the point to draw an ellipse in the created DisplayObject.
createPointModelRectangle()method 
public static function createPointModelRectangle(p1:IPoint, p2:IPoint):ShapePaintable

Creates a dynamic display object creator that will use two points to draw a rectangle in the created DisplayObject.

The argument is stored by reference and is queried for each operation. Thus changing the values of the argument after the creation of the IDisplayObjectCreator will change the painting.

Parameters

p1:IPoint — The first point that defines the bounds of the rectangle.
 
p2:IPoint — The second point that defines the bounds of the rectangle.

Returns
ShapePaintable — An display object creator that uses the points to draw a rectangle in the created DisplayObject.
createPolylinePaintable()method 
public static function createPolylinePaintable(points:IControlPoints):ShapePaintable

Parameters

points:IControlPoints

Returns
ShapePaintable
createRectModelRectangle()method 
public static function createRectModelRectangle(rect:IRectangle):ShapePaintable

Creates a dynamic display object creator that will use an IRectangle to draw and fill a rectangle in the created DisplayObject.

The argument is stored by reference and is queried for each operation. Thus changing the values of the argument after the creation of the IDisplayObjectCreator will change the painting in the created DisplayObject.

Parameters

rect:IRectangle — The rectangle to draw and fill.

Returns
ShapePaintable — A display object creator that uses the rectangle's values to draw a rectangle in the created DisplayObject.
createViewOrientedRectangle()method 
public static function createViewOrientedRectangle(orientedRectangle:IOrientedRectangle):ShapePaintable

Creates a dynamic display object creator that will use a IOrientedRectangle to draw and fill an IOrientedRectangle in the created DisplayObject in the view coordinate system.

Drawing in the view coordinate system will make pen widths not scale. The argument is stored by reference and is queried for each operation. Thus changing the values of the argument after the creation of the IDisplayObjectCreator will change the painting in the created DisplayObject.

Parameters

orientedRectangle:IOrientedRectangle — The oriented rectangle to draw and fill. The rectangle's geometry is stored in world coordinates, it will be painted in the view coordinate system, however.

Returns
ShapePaintable — A display object creator that uses the rectangle's values to draw an oriented rectangle in the created DisplayObject.

See also

createViewRectangle()method 
public static function createViewRectangle(rect:IRectangle):ShapePaintable

Creates a dynamic display object creator that will use a IRectangle to draw and fill a rectangle in the created DisplayObject in the view coordinate system.

Drawing in the view coordinate system will make pen widths not scale. The argument is stored by reference and is queried for each operation. Thus changing the values of the argument after the creation of the IDisplayObjectCreator will change the painting in the created DisplayObject.

Parameters

rect:IRectangle — The rectangle to draw and fill. The rectangle's geometry is stored in world coordinates, it will be painted in the view coordinate system, however.

Returns
ShapePaintable — A display object creator that uses the rectangle's values to draw a rectangle in the created DisplayObject.
isHit()method 
public function isHit(x:Number, y:Number, ctx:ICanvasContext):Boolean

Determines if something has been hit at the given coordinates in the world coordinate system.

Parameters

x:Number — the x-coordinate in world coordinate system
 
y:Number — the y-coordinate in world coordinate system
 
ctx:ICanvasContext — the context the hit test is performed in

Returns
Boolean — whether something has been hit
isInBox()method 
public function isInBox(box:IRectangle, ctx:ICanvasContext):Boolean

Implements the IMarqueeTestable interface and tests for marquee intersections with the shape.

Parameters

box:IRectangle
 
ctx:ICanvasContext

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

Performs the actual painting into the given graphics context.

Parameters

g:YGraphics — The graphics context to paint into
 
ctx:IPaintContext — Currently not used

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.