Packagecom.yworks.graph.drawing
Classpublic class PathBasedEdgeStyleRenderer
InheritancePathBasedEdgeStyleRenderer Inheritance AbstractEdgeStyleRenderer Inheritance AbstractStyleRenderer Inheritance Object
Implements IObstacleProvider
Subclasses PolylineEdgeStyleRenderer

An abstract base class for IEdgeStyleRenderer implementations that are based on the calculation of a GeneralPath.

See also

IEdgeStyleRenderer
com.yworks.canvas.drawing.GeneralPath


Public Properties
 PropertyDefined By
 Inheriteditem : IModelItem
[read-only] Gets the currently configured item.
AbstractStyleRenderer
 Inheritedstyle : IVisualStyle
[read-only] Gets the currently configured style.
AbstractStyleRenderer
 InheritedstyleDescriptor : ICanvasObjectDescriptor
[read-only] Gets the ICanvasObjectDescriptor to use for new installations.
AbstractStyleRenderer
Protected Properties
 PropertyDefined By
  addBridges : Boolean
[read-only] Determines whether the rendered path should use the BridgeManager to add bridges to it.
PathBasedEdgeStyleRenderer
  path : GeneralPath
The path instance that this instance is working with.
PathBasedEdgeStyleRenderer
Public Methods
 MethodDefined By
  
[override] Returns a tight rectangular area where the whole rendering would fit into.
PathBasedEdgeStyleRenderer
  
[override]
PathBasedEdgeStyleRenderer
 Inherited
Configures the style and item parameters, calls configure and returns this.
AbstractStyleRenderer
 Inherited
Configures the style and item parameters, does not call configure and returns this.
AbstractStyleRenderer
 Inherited
Configures the style and item parameters, calls configure and returns this.
AbstractStyleRenderer
  
[override] This method is overridden for performance reasons.
PathBasedEdgeStyleRenderer
 Inherited
Configures the style and item parameters, calls configure and returns this.
AbstractStyleRenderer
  
Yield the obstacles that the item that provided this instance would add to the scene for the given IPaintContext.
PathBasedEdgeStyleRenderer
  
[override] Returns a representation of the visible path of the edge in form of a GeneralPath
PathBasedEdgeStyleRenderer
  
Returns an IDisplayObjectCreator for the given path and stroke.
PathBasedEdgeStyleRenderer
 Inherited
Gets an implementation of the IPathGeometry interface that can handle the provided edge and its associated style.
AbstractEdgeStyleRenderer
 Inherited
Returns the number of "segments" this edge's path consists of.
AbstractEdgeStyleRenderer
 Inherited
getSegmentTangent(segment:int, ratio:Number, c:YPoint, up:YPoint):Boolean
Calculates the tangent on the edge's path at the given segment and ratio point.
AbstractEdgeStyleRenderer
  
getSourceArrowAnchor(path:GeneralPath, arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean
[static]
PathBasedEdgeStyleRenderer
 Inherited
getTangent(ratio:Number, c:YPoint, up:YPoint):Boolean
Calculates the tangent on the edge's path at the given ratio point.
AbstractEdgeStyleRenderer
  
getTargetArrowAnchor(path:GeneralPath, arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean
[static]
PathBasedEdgeStyleRenderer
 Inherited
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
[override] This method is overridden for performance reasons.
PathBasedEdgeStyleRenderer
  
[override] 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.
PathBasedEdgeStyleRenderer
 Inherited
Calls configure and tests the item using the style for a visible intersection with the clip bounds.
AbstractStyleRenderer
 Inherited
lookup(type:Class):Object
Implements the ILookup interface.
AbstractStyleRenderer
  
updateDisplayObject(oldDisplayObject:DisplayObject, context:IDisplayObjectContext):DisplayObject
[override]
PathBasedEdgeStyleRenderer
  
Updates the given IDisplayObjectCreator for the given path and stroke.
PathBasedEdgeStyleRenderer
Protected Methods
 MethodDefined By
  
configure():void
[override] Prepares this instance for subsequent calls after the style and item have been initialized.
PathBasedEdgeStyleRenderer
  
This method should create the basic uncropped path given the control points.
PathBasedEdgeStyleRenderer
 Inherited
[override] Factory method for the StyleDescriptor property.
AbstractEdgeStyleRenderer
  
cropPath(pathToCrop:GeneralPath):void
Crops the edge's path at the nodes.
PathBasedEdgeStyleRenderer
  
Yields the IAddBridgesCallback to use for adding bridges to the created path.
PathBasedEdgeStyleRenderer
  
getSmoothing():Number
Gets the smoothing factor
PathBasedEdgeStyleRenderer
  
getSourceArrowAnchor(arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean
[override] Calculate and update the anchor and the source arrow's direction vector.
PathBasedEdgeStyleRenderer
  
getStroke():IStroke
Gets the pen to use for painting the path.
PathBasedEdgeStyleRenderer
  
getTargetArrowAnchor(arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean
[override] Calculate and update the anchor and the target arrow's direction vector.
PathBasedEdgeStyleRenderer
 Inherited
setItem(item:IModelItem):void
Called by the various descriptor getters to initialize the item.
AbstractStyleRenderer
 Inherited
Called by the various descriptor getters to initialize the style.
AbstractStyleRenderer
Property Detail
addBridgesproperty
addBridges:Boolean  [read-only]

Determines whether the rendered path should use the BridgeManager to add bridges to it.


Implementation
    protected function get addBridges():Boolean
pathproperty 
protected var path:GeneralPath

The path instance that this instance is working with.

Method Detail
calculateBounds()method
override 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 
override 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 
override public function createDisplayObject(context:IDisplayObjectContext):DisplayObject

Parameters

context:IDisplayObjectContext

Returns
DisplayObject
createPath()method 
protected function createPath():GeneralPath

This method should create the basic uncropped path given the control points.

Returns
GeneralPath — A path that has to be cropped, yet.
cropPath()method 
protected function cropPath(pathToCrop:GeneralPath):void

Crops the edge's path at the nodes.

This implementation uses the IEdgeIntersectionCalculator instances found in the lookup of the source and target port of the edge to perform the actual cropping.

Parameters

pathToCrop:GeneralPath — The path that should be cropped.

See also

getAddBridgesCallback()method 
protected function getAddBridgesCallback():IAddBridgesCallback

Yields the IAddBridgesCallback to use for adding bridges to the created path.

The return value of this method (which may be null) will be passed to the BridgeManager's addBridges() method.

Returns
IAddBridgesCallback — This implementation returns null
getHitTestable()method 
override public function getHitTestable(item:IModelItem, style:IVisualStyle):IHitTestable

This method is overridden for performance reasons.

This implementation does not call configure. If subclasses depend on a configured instance in an override of isHit, they need to override this method, too and call configure if the base call returns a non-null value.

Parameters

item:IModelItem
 
style:IVisualStyle

Returns
IHitTestable

See also

getObstacles()method 
public function getObstacles(ctx:IPaintContext):GeneralPath

Yield the obstacles that the item that provided this instance would add to the scene for the given IPaintContext.

The implementation should only yield a non-null GeneralPath if it may be visible in the provided IPaintContext.

Parameters

ctx:IPaintContext — The context for which the obstacles are queried.

Returns
GeneralPath — A path that describes the obstacles or null if there are no obstacles for the given context.
getPath()method 
override public function getPath():GeneralPath

Returns a representation of the visible path of the edge in form of a GeneralPath

Returns
GeneralPath — An instance that describes the visible path or null if this is not applicable for the current geometry.
getPathDisplayObjectCreator()method 
public function getPathDisplayObjectCreator(path:GeneralPath, stroke:IStroke):IDisplayObjectCreator

Returns an IDisplayObjectCreator for the given path and stroke.

The DisplayObject created by this creator is only responsible for rendering the edge path itself while the arrows are rendered by their own display objects.

Parameters

path:GeneralPath — The path to get the display object creator for.
 
stroke:IStroke — The stroke that shall be used by the created display objects.

Returns
IDisplayObjectCreator — An IDisplayObjectCreator for the given path and stroke.
getSmoothing()method 
protected function getSmoothing():Number

Gets the smoothing factor

Returns
Number — The smoothing factor
getSourceArrowAnchor()method 
override protected function getSourceArrowAnchor(arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean

Calculate and update the anchor and the source arrow's direction vector.

Abstract method, has to be overridden by implementations.

Parameters

arrow:IArrow — The arrow to calculate the anchor for.
 
anchorPoint:IPointSetter — The tip of the arrow.
 
arrowDirection:IPointSetter — The direction vector of the arrow.

Returns
Boolean — Whether an anchor has been successfully determined.
getSourceArrowAnchor()method 
public static function getSourceArrowAnchor(path:GeneralPath, arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean

Parameters

path:GeneralPath
 
arrow:IArrow
 
anchorPoint:IPointSetter
 
arrowDirection:IPointSetter

Returns
Boolean
getStroke()method 
protected function getStroke():IStroke

Gets the pen to use for painting the path.

Returns
IStroke — the stroke or null.
getTargetArrowAnchor()method 
override protected function getTargetArrowAnchor(arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean

Calculate and update the anchor and the target arrow's direction vector.

Abstract method, has to be overridden by implementations.

Parameters

arrow:IArrow — The arrow to calculate the anchor for.
 
anchorPoint:IPointSetter — The tip of the arrow.
 
arrowDirection:IPointSetter — The direction vector of the arrow.

Returns
Boolean — Whether an anchor has been successfully determined.
getTargetArrowAnchor()method 
public static function getTargetArrowAnchor(path:GeneralPath, arrow:IArrow, anchorPoint:IPointSetter, arrowDirection:IPointSetter):Boolean

Parameters

path:GeneralPath
 
arrow:IArrow
 
anchorPoint:IPointSetter
 
arrowDirection:IPointSetter

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

This method is overridden for performance reasons.

This implementation uses the isVisible property as an early exit indicator. If isVisible returns false for a certain rectangle, the instance will not be configured but a non-hit will be assumed. Otherwise, this instance will be configured and the standard path based hit test routine is used.

Subclasses should not depend on the fact that configure has already been called. This may not be the case. If your subclass depends on configure being called, override getHitTestable and call configure after the base class call.

Parameters

x:Number
 
y:Number
 
ctx:ICanvasContext

Returns
Boolean

See also

isInBox()method 
override 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
updateDisplayObject()method 
override public function updateDisplayObject(oldDisplayObject:DisplayObject, context:IDisplayObjectContext):DisplayObject

Parameters

oldDisplayObject:DisplayObject
 
context:IDisplayObjectContext

Returns
DisplayObject
updatePathDisplayObjectCreator()method 
public function updatePathDisplayObjectCreator(creator:IDisplayObjectCreator, path:GeneralPath, stroke:IStroke):IDisplayObjectCreator

Updates the given IDisplayObjectCreator for the given path and stroke.

If the given creator is not of the same type as getPathDisplayObjectCreator returns, a new instance will be created.

Parameters

creator:IDisplayObjectCreator — The IDisplayObjectCreator to update.
 
path:GeneralPath — The path to get the display object creator for. If null the existing path will be kept.
 
stroke:IStroke — The stroke that shall be used by the created display objects. If null the existing stroke will be kept.

Returns
IDisplayObjectCreator — The updated IDisplayObjectCreator for the given path and stroke or a new instance if updating was not possible.