Packagecom.yworks.graph.drawing
Classpublic class SimpleAbstractPortStyle
InheritanceSimpleAbstractPortStyle Inheritance Object
Implements IPortStyle

A simple abstract port style whose renderer refers to the paint, calculateBounds, isVisible, isHit, isInBox and lookup methods implemented in the style.

To use this style, one has to subclass SimpleAbstractPortStyle and override at least the paint and calculateBounds method. The default implementations of the other methods do use the port's bounds rectangle e.g. for hit or visibility tests.



Public Properties
 PropertyDefined By
  styleRenderer : IStyleRenderer
[read-only] Gets the renderer implementation that has been supplied to this instance upon creation.
SimpleAbstractPortStyle
Public Methods
 MethodDefined By
  
Creates a new instance
SimpleAbstractPortStyle
  
clone():Object
Returns this instance.
SimpleAbstractPortStyle
  
install(canvas:CanvasComponent, group:ICanvasObjectGroup, modelItem:IModelItem):Array
Prepares the rendering of an IModelItem in a CanvasComponent by adding ICanvasObject's to the provided canvas.
SimpleAbstractPortStyle
Protected Methods
 MethodDefined By
  
Calculates the bounds for the port in the given context.
SimpleAbstractPortStyle
  
This style's renderer delegates the display object creation to this method.
SimpleAbstractPortStyle
  
isHit(port:IPort, x:Number, y:Number, ctx:ICanvasContext):Boolean
Determines whether the visual representation of the port has been hit at the given location.
SimpleAbstractPortStyle
  
isInBox(port:IPort, box:IRectangle, ctx:ICanvasContext):Boolean
Determines whether the visualization for the specified port is included in the marquee selection.
SimpleAbstractPortStyle
  
isVisible(port:IPort, clip:IRectangle, ctx:ICanvasContext):Boolean
Determines whether the visualization for the specified port is visible in the context.
SimpleAbstractPortStyle
  
lookup(port:IPort, type:Class):Object
Performs the lookup operation for the lookup calls to the renderer.
SimpleAbstractPortStyle
  
updateDisplayObject(port:IPort, oldDisplayObject:DisplayObject, ctx:IDisplayObjectContext):DisplayObject
This style's renderer delegates updating the display object to this method.
SimpleAbstractPortStyle
Property Detail
styleRendererproperty
styleRenderer:IStyleRenderer  [read-only]

Gets the renderer implementation that has been supplied to this instance upon creation.


Implementation
    public function get styleRenderer():IStyleRenderer
Constructor Detail
SimpleAbstractPortStyle()Constructor
public function SimpleAbstractPortStyle()

Creates a new instance

Method Detail
calculateBounds()method
protected function calculateBounds(port:IPort, scratch:IMutableRectangle, ctx:ICanvasContext):IRectangle

Calculates the bounds for the port in the given context.

This method is called in response to a calculateBounds call to the instance that has been queried from the renderer.

Subclasses have to override this method.

Parameters

port:IPort — The port to which this style instance is assigned.
 
scratch:IMutableRectangle — The mutable rectangle to set the calculated bounds.
 
ctx:ICanvasContext — The canvas context.

Returns
IRectangle — The visual bounds of the visual representation.

See also

clone()method 
public function clone():Object

Returns this instance.

If subclasses implement properties which should be set in the clone, too, this method has to be overridden.

Returns
Objectthis;
createDisplayObject()method 
protected function createDisplayObject(port:IPort, ctx:IDisplayObjectContext):DisplayObject

This style's renderer delegates the display object creation to this method.

Subclasses have to override this method and implement their own createDisplayObject method.

Parameters

port:IPort — The display object context.
 
ctx:IDisplayObjectContext — The port to render.

Returns
DisplayObject

Throws
IllegalOperationError — if not overridden.

See also

install()method 
public function install(canvas:CanvasComponent, group:ICanvasObjectGroup, modelItem:IModelItem):Array

Prepares the rendering of an IModelItem in a CanvasComponent by adding ICanvasObject's to the provided canvas.

Implementations may add zero or more ICanvasObject instances to the given CanvasComponent. The group parameter can be used as a hint for implementations. They can add their newly created canvas objects to the given group. However they are not obliged to do that.

Parameters

canvas:CanvasComponent — The canvas to install the canvas objects in.
 
group:ICanvasObjectGroup — A hint that tells the implementation where to add the canvas objects.
 
modelItem:IModelItem — The item to install a visual representation for.

Returns
Array — An array of zero or more canvas objects that have been installed in the canvas by this method or null if nothing was installed.
isHit()method 
protected function isHit(port:IPort, x:Number, y:Number, ctx:ICanvasContext):Boolean

Determines whether the visual representation of the port has been hit at the given location.

This method is called in response to a isHit call to the instance that has benn queried from the renderer. This implementation uses the port bounds to determine whether the port has been hit.

Parameters

port:IPort — The port to which this style instance is assigned.
 
x:Number — The x coordinate to test.
 
y:Number — The y coordinate to test.
 
ctx:ICanvasContext — The canvas context.

Returns
Booleantrue if the specified port representation is hit; false otherwise.

See also

isInBox()method 
protected function isInBox(port:IPort, box:IRectangle, ctx:ICanvasContext):Boolean

Determines whether the visualization for the specified port is included in the marquee selection.

This method is called in response to a isInBox call to the instance that has been queried from the renderer. This implementation simply tests whether the port bounds intersect the marquee box.

Parameters

port:IPort — The port to which this style instance is assigned.
 
box:IRectangle — The marquee selection box.
 
ctx:ICanvasContext — The canvas context.

Returns
Booleantrue if the specified port is selected by the marquee rectangle; false otherwise.

See also

isVisible()method 
protected function isVisible(port:IPort, clip:IRectangle, ctx:ICanvasContext):Boolean

Determines whether the visualization for the specified port is visible in the context.

This method is called in response to a isVisible call to the instance that has been queried from the renderer. This implementation simply tests whether the bounds intersect the clip.

Parameters

port:IPort — The port to which this style instance is assigned.
 
clip:IRectangle — The clipping rectangle.
 
ctx:ICanvasContext — The canvas context.

Returns
Booleantrue if the specified port is visible in the clipping rectangle, false otherwise.

See also

lookup()method 
protected function lookup(port:IPort, type:Class):Object

Performs the lookup operation for the lookup calls to the renderer.

This implementation yields null for everything but:

For these interfaces an implementation will be returned that delegates to the methods in this instance.

Parameters

port:IPort — The port to use for the context query.
 
type:Class — The type to query.

Returns
Object — An implementation of the type or null.
updateDisplayObject()method 
protected function updateDisplayObject(port:IPort, oldDisplayObject:DisplayObject, ctx:IDisplayObjectContext):DisplayObject

This style's renderer delegates updating the display object to this method.

This implementation just delegates to createDisplayObject so subclasses should override this method to improve rendering performance.

Parameters

port:IPort — The display object context.
 
oldDisplayObject:DisplayObject — The port to render.
 
ctx:IDisplayObjectContext — The display object to update.

Returns
DisplayObject

See also