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

Provides a number of IPaintable 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 this paintable.
ShapePaintable
  stroke : IStroke
The stroke to use for this paintable.
ShapePaintable
Public Methods
 MethodDefined By
  
Returns a tight rectangular area where the whole rendering would fit into.
ShapePaintable
  
createFixedViewEllipse(center:IPoint, width:Number, height:Number):ShapePaintable
[static] Creates a dynamic paintable that will use an IPoint to draw and fill an ellipse in the view coordinate system with a zoom level invariant width and height.
ShapePaintable
  
[static] Creates a dynamic paintable that draws a given path.
ShapePaintable
  
createPointModelEllipse(center:IPoint, width:Number, height:Number):ShapePaintable
[static] Creates a dynamic paintable that will use an IPoint to draw and fill an ellipse.
ShapePaintable
  
[static] Creates a dynamic paintable that will use two points to draw a rectangle in the view.
ShapePaintable
  
[static]
ShapePaintable
  
[static] Creates a dynamic paintable that will use an IRectangle to draw and fill a rectangle.
ShapePaintable
  
[static] Creates a dynamic paintable that will use a IOrientedRectangle to draw and fill an IOrientedRectangle in the view coordinate system.
ShapePaintable
  
[static] Creates a dynamic paintable that will use a IRectangle to draw and fill a rectangle 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
Property Detail
fillproperty
fill:IFill

The fill to use for this paintable.


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

The stroke to use for this paintable.


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
createFixedViewEllipse()method 
public static function createFixedViewEllipse(center:IPoint, width:Number, height:Number):ShapePaintable

Creates a dynamic paintable that will use an IPoint to draw and fill an ellipse 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 IPaintable will change the paintable.

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 paintable that draws a given path.

Parameters

path:GeneralPath — The path to draw.

Returns
ShapePaintable — A paintable that fills and draws the path.
createPointModelEllipse()method 
public static function createPointModelEllipse(center:IPoint, width:Number, height:Number):ShapePaintable

Creates a dynamic paintable that will use an IPoint to draw and fill an ellipse.

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

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 paintable that uses the point to draw an ellipse.
createPointModelRectangle()method 
public static function createPointModelRectangle(p1:IPoint, p2:IPoint):ShapePaintable

Creates a dynamic paintable that will use two points to draw a rectangle in the view.

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

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 — A paintable that uses the points to draw a rectangle.
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 paintable that will use an IRectangle to draw and fill a rectangle.

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

Parameters

rect:IRectangle — The rectangle to draw and fill.

Returns
ShapePaintable — A paintable that uses the rectangle's values to draw a rectangle.
createViewOrientedRectangle()method 
public static function createViewOrientedRectangle(orientedRectangle:IOrientedRectangle):ShapePaintable

Creates a dynamic paintable that will use a IOrientedRectangle to draw and fill an IOrientedRectangle 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 IPaintable will change the paintable.

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 paintable that uses the rectangle's values to draw an oriented rectangle.

See also

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

Creates a dynamic paintable that will use a IRectangle to draw and fill a rectangle 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 IPaintable will change the paintable.

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 paintable that uses the rectangle's values to draw a rectangle.
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