Packagecom.yworks.graph.drawing
Classpublic class AbstractStyleRenderer
InheritanceAbstractStyleRenderer Inheritance Object
Implements IStyleRenderer, IBoundsProvider, ILookup, IHitTestable, IMarqueeTestable, IVisibilityTest, IDisplayObjectCreator
Subclasses AbstractEdgeStyleRenderer, AbstractLabelStyleRenderer, AbstractNodeStyleRenderer, DelegatingStyleRenderer, SimplePortStyleRenderer

An abstract generic implementation of an IStyleRenderer that can be used to install an IModelItem with a corresponding IVisualStyle and a concrete style implementation.



Public Properties
 PropertyDefined By
  item : IModelItem
[read-only] Gets the currently configured item.
AbstractStyleRenderer
  style : IVisualStyle
[read-only] Gets the currently configured style.
AbstractStyleRenderer
  styleDescriptor : ICanvasObjectDescriptor
[read-only] Gets the ICanvasObjectDescriptor to use for new installations.
AbstractStyleRenderer
Public Methods
 MethodDefined By
  
Returns a tight rectangular area where the whole rendering would fit into.
AbstractStyleRenderer
  
Creates a new DisplayObject which represents the styled model item.
AbstractStyleRenderer
  
Configures the style and item parameters, calls configure and returns this.
AbstractStyleRenderer
  
Configures the style and item parameters, does not call configure and returns this.
AbstractStyleRenderer
  
Configures the style and item parameters, calls configure and returns this.
AbstractStyleRenderer
  
Configures the style and item parameters, calls configure and returns this.
AbstractStyleRenderer
  
Configures the style and item parameters, calls configure and returns this.
AbstractStyleRenderer
  
install(canvas:CanvasComponent, group:ICanvasObjectGroup, modelItem:IModelItem):Array
Installs the model in the canvas at the given group using the styleDescriptor.
AbstractStyleRenderer
  
isHit(x:Number, y:Number, ctx:ICanvasContext):Boolean
Hit tests the item by trying to apply the flash internal hit testing.
AbstractStyleRenderer
  
Returns true if the corresponding item is considered to intersect the given rectangular box. This method may return false if the item cannot be selected using a selection marquee or optionally if the item is only partially contained within the box.
AbstractStyleRenderer
  
Calls configure and tests the item using the style for a visible intersection with the clip bounds.
AbstractStyleRenderer
  
lookup(type:Class):Object
Implements the ILookup interface.
AbstractStyleRenderer
  
updateDisplayObject(oldDisplayObject:DisplayObject, context:IDisplayObjectContext):DisplayObject
Updates the given DisplayObject.
AbstractStyleRenderer
Protected Methods
 MethodDefined By
  
configure():void
Prepares this instance for subsequent calls after the style and item have been initialized.
AbstractStyleRenderer
  
Factory method for the StyleDescriptor property.
AbstractStyleRenderer
  
setItem(item:IModelItem):void
Called by the various descriptor getters to initialize the item.
AbstractStyleRenderer
  
Called by the various descriptor getters to initialize the style.
AbstractStyleRenderer
Property Detail
itemproperty
item:IModelItem  [read-only]

Gets the currently configured item.


Implementation
    public function get item():IModelItem
styleproperty 
style:IVisualStyle  [read-only]

Gets the currently configured style.


Implementation
    public function get style():IVisualStyle
styleDescriptorproperty 
styleDescriptor:ICanvasObjectDescriptor  [read-only]

Gets the ICanvasObjectDescriptor to use for new installations. If the field has not yet been initialized upon first access, the factory method createStyleDescriptor will be called.


Implementation
    public function get styleDescriptor():ICanvasObjectDescriptor
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
configure()method 
protected function configure():void

Prepares this instance for subsequent calls after the style and item have been initialized.

Upon invocation the style and item fields have been populated by the getDisplayObjectCreator or getBoundsProvider methods.

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

Creates a new DisplayObject which represents the styled model item.

Subclasses have to override this method

Parameters

context:IDisplayObjectContext

Returns
DisplayObject

See also

createStyleDescriptor()method 
protected function createStyleDescriptor():ICanvasObjectDescriptor

Factory method for the StyleDescriptor property. This method will be called upon first access to the styleDescriptor property.

Returns
ICanvasObjectDescriptor — An ICanvasObjectDescriptor instance that will delegate to this instance's methods
getBoundsProvider()method 
public function getBoundsProvider(item:IModelItem, style:IVisualStyle):IBoundsProvider

Configures the style and item parameters, calls configure and returns this.

Parameters

item:IModelItem — The item to retrieve the bounds provider for. The value will be stored in the item field by setItem
 
style:IVisualStyle — The style to associate with the item. The value will be stored in the style field by setStyle.

Returns
IBoundsProviderthis
getContext()method 
public function getContext(item:IModelItem, style:IVisualStyle):ILookup

Configures the style and item parameters, does not call configure and returns this.

As this method may be called often it will not automatically call configure, instead subclasses should ensure that in the lookup method call they should call configure only if needed, i.e. if they decide to return this or an instance that depends on a correctly configured this.

Parameters

item:IModelItem — The item to query the context for. The value will be stored in the item field by setItem.
 
style:IVisualStyle — The style to associate with the item. The value will be stored in the style field by setStyle.

Returns
ILookupthis
getDisplayObjectCreator()method 
public function getDisplayObjectCreator(item:IModelItem, style:IVisualStyle):IDisplayObjectCreator

Configures the style and item parameters, calls configure and returns this.

Parameters

item:IModelItem — The item to retrieve the display object creator for. The value will be stored in the item field by setItem.
 
style:IVisualStyle — The style to associate with the item. The value will be stored in the style field by setStyle.

Returns
IDisplayObjectCreatorthis
getHitTestable()method 
public function getHitTestable(item:IModelItem, style:IVisualStyle):IHitTestable

Configures the style and item parameters, calls configure and returns this.

Parameters

item:IModelItem — The item to query hit test with. The value will be stored in the item field by setItem.
 
style:IVisualStyle — The style to associate with the item. The value will be stored in the style field by setStyle.

Returns
IHitTestablethis
getMarqueeTestable()method 
public function getMarqueeTestable(item:IModelItem, style:IVisualStyle):IMarqueeTestable

Configures the style and item parameters, calls configure and returns this.

Parameters

item:IModelItem — The item to query for marquee intersection tests. The value will be stored in the item field by setItem.
 
style:IVisualStyle — The style to associate with the item. The value will be stored in the style field by setStyle.

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

Installs the model in the canvas at the given group using the styleDescriptor.

Parameters

canvas:CanvasComponent
 
group:ICanvasObjectGroup
 
modelItem:IModelItem

Returns
Array
isHit()method 
public function isHit(x:Number, y:Number, ctx:ICanvasContext):Boolean

Hit tests the item by trying to apply the flash internal hit testing.

This implementation does not take ICanvasContext.hitTestRadius into account.

Parameters

x:Number
 
y:Number
 
ctx:ICanvasContext

Returns
Boolean
isInBox()method 
public function isInBox(box:IRectangle, ctx:ICanvasContext):Boolean

Returns true if the corresponding item is considered to intersect the given rectangular box. This method may return false if the item cannot be selected using a selection marquee or optionally if the item is only partially contained within the box.

Parameters

box:IRectangle — The box describing the marquee's bounds
 
ctx:ICanvasContext — The current canvas context

Returns
Booleantrue if the item is considered to be captured by the marquee
isVisible()method 
public function isVisible(clip:IRectangle, ctx:ICanvasContext):Boolean

Calls configure and tests the item using the style for a visible intersection with the clip bounds.

This simple implementation uses calculateBounds to determine the visibility. Subclasses may choose to override this behavior for improved performance but need to make sure to call configure if they depend on a configured instance.

Parameters

clip:IRectangle — The clip bounds
 
ctx:ICanvasContext — The current canvas context

Returns
Booleantrue if the item may be painted within the clip bounds.
lookup()method 
public function lookup(type:Class):Object

Implements the ILookup interface.

This method will be used by default if getContext has been queried for a lookup implementation. Note that it cannot be assumed that configure has already been invoked. However, normally item and style will be correctly configured if invoked directly after getContext. Subclass implementations should make sure to configure this instance before they return this as a result of a successful lookup.

Parameters

type:Class — The type to query for

Returns
Object — An implementation of the given type or null
setItem()method 
protected function setItem(item:IModelItem):void

Called by the various descriptor getters to initialize the item.

Sets the item field to the given argument.

Parameters

item:IModelItem — The item to use for the subsequent calls

setStyle()method 
protected function setStyle(style:IVisualStyle):void

Called by the various descriptor getters to initialize the style.

Sets the style field to the given argument.

Parameters

style:IVisualStyle — The style to use for the subsequent calls

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

Updates the given DisplayObject.

Parameters

oldDisplayObject:DisplayObject
 
context:IDisplayObjectContext

Returns
DisplayObject

See also