Packagecom.yworks.canvas.model
Classpublic class BridgeManager
InheritanceBridgeManager Inheritance Object

Helper managing class that can be used in conjunction with CanvasComponent instances to manage the calculation of bridges for paths over obstacles.

This class will typically be used to prepare the IPaintContext for rendering in a CanvasComponent. Setting the canvasComponent property to a non-null value will register this class for the preparation of the context. It will make itself available via the ILookup.lookup() mechanism in the IPaintContext.

During the creation of the visuals, this instance can be queried and the addBridges(IPaintContext,GeneralPath,IAddBridgesCallback) method can be used to calculate bridges for a GeneralPath. Initially IObstacleProvider instances need to be registered with this instance via the AddObstacleProvider instance so that crossings can be later determined between the path and the obstacles.



Public Properties
 PropertyDefined By
  canvasComponent : CanvasComponent
The CanvasComponent that should be managed by this instance.
BridgeManager
  clipMargin : Number
The margin by which the clip should be enlarged to accommodate for clipped away lines being taken into account for bridge calculation.
BridgeManager
  considerCurves : Boolean
Gets or sets a value that determines whether curves (GeneralPath.curveTo()) should be considered as obstacles.
BridgeManager
  crossingDetermination : uint
Tthe crossingDetermination mode that is used by this instance.
BridgeManager
  defaultBridgeHeight : Number
Gets or sets the default height of a bridge that will be used by the default implementation of the IAddBridgesCallback that is initially assigned to the defaultCallback property.
BridgeManager
  defaultBridgeOrientationStyle : uint
BridgeManager
  defaultBridgeWidth : Number
Gets or sets the default width of a bridge that will be used by the default implementation of the IAddBridgesCallback that is initially assigned to the defaultCallback property.
BridgeManager
  defaultCallback : IAddBridgesCallback
The default implementation of the IAddBridgesCallback that will be used if addBridges(GeneralPath,Number,Number,Number,Number,IAddBridgesCallback,IPaintContext,Bridges) is invoked with a null callback argument.
BridgeManager
  defaultCrossingStyle : uint
The default crossing style that will be used by the default implementation of the IAddBridgesCallback that is initially assigned to the defaultCallback property.
BridgeManager
Public Methods
 MethodDefined By
  
Initializes a new instance of the BridgeManager class.
BridgeManager
  
Core method that will add bridges to a GeneralPath using the IAddBridgesCallback callback to determine the type of the bridges.
BridgeManager
  
Adds another pair of an IObstacleProvider implementation and an item that will later be passed to the IObstacleProvider.getObstacles() method to determine the initial obstacles for this instance.
BridgeManager
  
dispose():void
Disposes of this instance by resetting the CanvasComponent property to null.
BridgeManager
  
insertDefaultCustomBridge(context:IPaintContext, path:GeneralPath, x1:Number, y1:Number, x2:Number, y2:Number, gapLength:Number):void
Implementation that will be called by the default value of the defaultCallback to satisfy requests to IAddBridgesCallback.insertCustomBridge().
BridgeManager
  
BridgeManager
  
Convenience method that can be called to dynamically register an obstacle path with the context during the rendering.
BridgeManager
  
registerObstacleCurve(context:IPaintContext, x1:Number, y1:Number, cpx:Number, cpy:Number, x2:Number, y2:Number):void
Convenience method that can be called to dynamically register a single obstacle quadratic curve with the context during the rendering.
BridgeManager
  
registerObstacleLine(context:IPaintContext, x1:Number, y1:Number, x2:Number, y2:Number):void
Convenience method that can be called to dynamically register a single obstacle line with the context during the rendering.
BridgeManager
  
Removes a previously added IObstacleProvider from the list of registered providers.
BridgeManager
  
Convenience method which forces a repaint of the edges of the given canvas.
BridgeManager
Protected Methods
 MethodDefined By
  
Installs this manager for the specified canvas component.
BridgeManager
  
Called to initialize the context with the obstacles.
BridgeManager
  
Reverts the install() method.
BridgeManager
Public Constants
 ConstantDefined By
  DETERMINE_HORIZONTAL_BRIDGES_VERTICAL : uint = 0
[static] Makes horizontal segments bridge over vertical obstacles.
BridgeManager
  DETERMINE_MORE_HORIZONTAL_BRIDGES_LESS_HORIZONTAL : uint = 2
[static] Makes more horizontal edges bridge over edges which are less horizontal.
BridgeManager
  DETERMINE_MORE_VERTICAL_BRIDGES_LESS_VERTICAL : uint = 3
[static] Makes more vertical edges bridge over edges which are less vertical.
BridgeManager
  DETERMINE_VERTICAL_BRIDGES_HORIZONTAL : uint = 1
[static] Makes vertical segments bridge over vertical obstacles.
BridgeManager
  ORIENTATION_DOWN : uint = 6
[static] Adds bridges that point downwards.
BridgeManager
  ORIENTATION_FLOW_LEFT : uint = 1
[static] Adds a bridge to the left of the flow of the path.
BridgeManager
  ORIENTATION_FLOW_RIGHT : uint = 0
[static] Adds a bridge to the right of the flow of the path.
BridgeManager
  ORIENTATION_LEFT : uint = 5
[static] Adds bridges that point to the left.
BridgeManager
  ORIENTATION_NEGATIVE : uint = 3
[static] Adds a bridge in the direction of the negative axes.
BridgeManager
  ORIENTATION_POSITIVE : uint = 2
[static] Adds a bridge in the direction of the positive axes.
BridgeManager
  ORIENTATION_RIGHT : uint = 4
[static] Adds bridges that point to the right.
BridgeManager
  ORIENTATION_UP : uint = 7
[static] Adds bridges that point upwards.
BridgeManager
  STYLE_ARC : uint = 5
[static] The style that for each crossing inserts two quarter circle arcs into the path, that are connected by a straight line.
BridgeManager
  STYLE_ARC_SCALED : uint = 6
[static] The style that for each crossing inserts a half circle into the path.
BridgeManager
  STYLE_CUSTOM : uint = 7
[static] The style that will use the IAddBridgesCallback.InsertCustomBridge() method to insert the bridge.
BridgeManager
  STYLE_GAP : uint = 0
[static] The style that indicates that there should be a gap left in the path.
BridgeManager
  STYLE_RECTANGLE : uint = 1
[static] The style that makes the crossing look like the upper half of a rectangle being inserted into the path.
BridgeManager
  STYLE_RECTANGLE_SCALED : uint = 2
[static] The style that makes the crossing look like the upper half of a rectangle being inserted into the path, where the height has been scaled to keep the ascpet ratio for greater widths.
BridgeManager
  STYLE_TWO_SIDES : uint = 3
[static] The style that for each crossing inserts two sides of a triangle into the path.
BridgeManager
  STYLE_TWO_SIDES_SCALED : uint = 4
[static] The style that for each crossing inserts two sides of a triangle into the path, where the height has been scaled to keep the ascpet ratio for greater widths.
BridgeManager
Property Detail
canvasComponentproperty
canvasComponent:CanvasComponent

The CanvasComponent that should be managed by this instance. This method will install a preparation stage for the IPaintContext in the provided CanvasComponent via the lookup mechanism.


Implementation
    public function get canvasComponent():CanvasComponent
    public function set canvasComponent(value:CanvasComponent):void
clipMarginproperty 
clipMargin:Number

The margin by which the clip should be enlarged to accommodate for clipped away lines being taken into account for bridge calculation.

This value should be set to at least half the value of the width of the bridges used in this context. This is because obstacles might otherwise be clipped from the view and not taken into account for the calculation of the bridges. By default this value will be 2 more than half of the defaultBridgeWidth.


Implementation
    public function get clipMargin():Number
    public function set clipMargin(value:Number):void
considerCurvesproperty 
considerCurves:Boolean

Gets or sets a value that determines whether curves (GeneralPath.curveTo()) should be considered as obstacles.

This can be a costly operation so the default is false.


Implementation
    public function get considerCurves():Boolean
    public function set considerCurves(value:Boolean):void
crossingDeterminationproperty 
crossingDetermination:uint

Tthe crossingDetermination mode that is used by this instance.

The default value is BridgeManager.HORIZONTAL_BRIDGES_VERTICAL.


Implementation
    public function get crossingDetermination():uint
    public function set crossingDetermination(value:uint):void
defaultBridgeHeightproperty 
defaultBridgeHeight:Number

Gets or sets the default height of a bridge that will be used by the default implementation of the IAddBridgesCallback that is initially assigned to the defaultCallback property.

Setting this value will adjust the clipMargin.

The default value is 5.0.


Implementation
    public function get defaultBridgeHeight():Number
    public function set defaultBridgeHeight(value:Number):void

See also

defaultBridgeOrientationStyleproperty 
defaultBridgeOrientationStyle:uint


Implementation
    public function get defaultBridgeOrientationStyle():uint
    public function set defaultBridgeOrientationStyle(value:uint):void
defaultBridgeWidthproperty 
defaultBridgeWidth:Number

Gets or sets the default width of a bridge that will be used by the default implementation of the IAddBridgesCallback that is initially assigned to the defaultCallback property.

Setting this value will adjust the clipMargin.

The default value is 10.0.


Implementation
    public function get defaultBridgeWidth():Number
    public function set defaultBridgeWidth(value:Number):void

See also

defaultCallbackproperty 
defaultCallback:IAddBridgesCallback

The default implementation of the IAddBridgesCallback that will be used if addBridges(GeneralPath,Number,Number,Number,Number,IAddBridgesCallback,IPaintContext,Bridges) is invoked with a null callback argument.


Implementation
    public function get defaultCallback():IAddBridgesCallback
    public function set defaultCallback(value:IAddBridgesCallback):void

See also

defaultCrossingStyleproperty 
defaultCrossingStyle:uint

The default crossing style that will be used by the default implementation of the IAddBridgesCallback that is initially assigned to the defaultCallback property.

The default value is STYLE_ARC.


Implementation
    public function get defaultCrossingStyle():uint
    public function set defaultCrossingStyle(value:uint):void

See also

com.yworks.canvas.model.IAddBridgesCallback..getCrossingStyle()
Constructor Detail
BridgeManager()Constructor
public function BridgeManager()

Initializes a new instance of the BridgeManager class.

Initially the defaultCallback will be set to an instance that will delegate to the set of default properties in this class and the insertDefaultCustomBridge method respectively.

Method Detail
addBridges()method
public function addBridges(context:IPaintContext, path:GeneralPath, callback:IAddBridgesCallback):GeneralPath

Core method that will add bridges to a GeneralPath using the IAddBridgesCallback callback to determine the type of the bridges.

This method may return path itself if no crossings have been determined. Otherwise it will return a new path instance that has the bridges added at the corresponding places.

Parameters

context:IPaintContext — The context to use.
 
path:GeneralPath — The path to calculate the bridged variant for.
 
callback:IAddBridgesCallback — The callback or null that determines the appearance of the bridges.

Returns
GeneralPath — The path that might have been augmented by the bridges.
addObstacleProvider()method 
public function addObstacleProvider(provider:IObstacleProvider):void

Adds another pair of an IObstacleProvider implementation and an item that will later be passed to the IObstacleProvider.getObstacles() method to determine the initial obstacles for this instance.

The IObstacleProvider.getObstacles() method will be invoked during construction of the obstacles.

Parameters

provider:IObstacleProvider — The provider instance to use for later queries.

See also

dispose()method 
public function dispose():void

Disposes of this instance by resetting the CanvasComponent property to null.

getObstacleHash()method 
yworks_internal function getObstacleHash(context:IPaintContext):int

Gets a hash code that describes the current state of the obstacles.

This method can be used to see whether the obstacles have changed their coordinates since the last call.

Parameters

context:IPaintContext — The context to inspect.

Returns
int — A hash of the state of the obstacles.
insertDefaultCustomBridge()method 
public function insertDefaultCustomBridge(context:IPaintContext, path:GeneralPath, x1:Number, y1:Number, x2:Number, y2:Number, gapLength:Number):void

Implementation that will be called by the default value of the defaultCallback to satisfy requests to IAddBridgesCallback.insertCustomBridge().

This implementation will insert a gap style bridge by first creating a line to (x1,y1) and then moving to (x2,y2).

Parameters

context:IPaintContext — The context for the call.
 
path:GeneralPath — The path to append the next segment to.
 
x1:Number — The x coordinate of the starting point of the bridge.
 
y1:Number — The y coordinate of the starting point of the bridge.
 
x2:Number — The x coordinate of the end point of the bridge.
 
y2:Number — The y coordinate of the end point of the bridge.
 
gapLength:Number — The distance between the starting point and the end point.

See also

install()method 
protected function install(canvas:CanvasComponent):void

Installs this manager for the specified canvas component.

Parameters

canvas:CanvasComponent — The canvas component.

onPrepareContext()method 
public function onPrepareContext(context:IPaintContext):IPaintContext

Parameters

context:IPaintContext

Returns
IPaintContext
registerObstacle()method 
public function registerObstacle(context:IPaintContext, path:GeneralPath):void

Convenience method that can be called to dynamically register an obstacle path with the context during the rendering.

Normally all obstacles will be registered initially by method registerObstacles(IPaintContext). This method can be called during the rendering phase to register additional obstacles at a later point in time.

Parameters

context:IPaintContext — The context to register the obstacles with.
 
path:GeneralPath — The path that describes the obstacles

See also

registerObstacleCurve()method 
public function registerObstacleCurve(context:IPaintContext, x1:Number, y1:Number, cpx:Number, cpy:Number, x2:Number, y2:Number):void

Convenience method that can be called to dynamically register a single obstacle quadratic curve with the context during the rendering.

Normally all obstacles will be registered initially by method registerObstacles(). This method can be called during the rendering phase to register additional obstacles at a later point in time.

Parameters

context:IPaintContext — The context to register the obstacles with.
 
x1:Number — The x coordinate of the first point of the curve.
 
y1:Number — The y coordinate of the first point of the curve.
 
cpx:Number — The x coordinate of the control point of the curve.
 
cpy:Number — The y coordinate of the control point of the curve.
 
x2:Number — The x coordinate of the second point of the curve.
 
y2:Number — The y coordinate of the second point of the curve.

See also

registerObstacleLine()method 
public function registerObstacleLine(context:IPaintContext, x1:Number, y1:Number, x2:Number, y2:Number):void

Convenience method that can be called to dynamically register a single obstacle line with the context during the rendering.

Normally all obstacles will be registered initially by method registerObstacles(IPaintContext). This method can be called during the rendering phase to register additional obstacles at a later point in time.

Parameters

context:IPaintContext — The context to register the obstacles with.
 
x1:Number — The x coordinate of the first point of the line.
 
y1:Number — The y coordinate of the first point of the line.
 
x2:Number — The x coordinate of the second point of the line.
 
y2:Number — The y coordinate of the second point of the line.

See also

registerObstacles()method 
protected function registerObstacles(context:IPaintContext):void

Called to initialize the context with the obstacles.

Parameters

context:IPaintContext — The context that will be used to store the obstacles with.

See also

removeObstacleProvider()method 
public function removeObstacleProvider(provider:IObstacleProvider):void

Removes a previously added IObstacleProvider from the list of registered providers.

Parameters

provider:IObstacleProvider — The provider instance to remove from this instance.

See also

repaintGraphCanvas()method 
public function repaintGraphCanvas(graphCanvas:GraphCanvasComponent):void

Convenience method which forces a repaint of the edges of the given canvas.

This method can be called after the edges have changed to repaint all edges in order to update the bridges.

Parameters

graphCanvas:GraphCanvasComponent — The canvas to repaint.

uninstall()method 
protected function uninstall(canvas:CanvasComponent):void

Reverts the install() method.

Parameters

canvas:CanvasComponent — The canvas component.

Constant Detail
DETERMINE_HORIZONTAL_BRIDGES_VERTICALConstant
public static const DETERMINE_HORIZONTAL_BRIDGES_VERTICAL:uint = 0

Makes horizontal segments bridge over vertical obstacles.

Horizontal segments do not cross each other, as well as vertical ones will not cross each other. Horizontal segment are segments with a slope between 1 and -1. All others are vertical segments. For non-parallel intersecting pairs of segments there does not need to be a crossing unless only one of them is vertical.

DETERMINE_MORE_HORIZONTAL_BRIDGES_LESS_HORIZONTALConstant 
public static const DETERMINE_MORE_HORIZONTAL_BRIDGES_LESS_HORIZONTAL:uint = 2

Makes more horizontal edges bridge over edges which are less horizontal.

The smaller the absolute slope of an edge, the more horizontal it is. For each non-parallel intersecting pair of segments, there will be a crossing.

DETERMINE_MORE_VERTICAL_BRIDGES_LESS_VERTICALConstant 
public static const DETERMINE_MORE_VERTICAL_BRIDGES_LESS_VERTICAL:uint = 3

Makes more vertical edges bridge over edges which are less vertical.

The larger the absolute slope of an edge, the more vertical it is. For each non-parallel intersecting pair of segments, there will be a crossing.

DETERMINE_VERTICAL_BRIDGES_HORIZONTALConstant 
public static const DETERMINE_VERTICAL_BRIDGES_HORIZONTAL:uint = 1

Makes vertical segments bridge over vertical obstacles.

Horizontal segments do not cross each other, as well as vertical ones will not cross each other. Horizontal segment are segments with a slope between 1 and -1. All others are vertical segments. For non-parallel intersecting pairs of segments there does not need to be a crossing unless only one of them is horizontal.

ORIENTATION_DOWNConstant 
public static const ORIENTATION_DOWN:uint = 6

Adds bridges that point downwards.

ORIENTATION_FLOW_LEFTConstant 
public static const ORIENTATION_FLOW_LEFT:uint = 1

Adds a bridge to the left of the flow of the path.

ORIENTATION_FLOW_RIGHTConstant 
public static const ORIENTATION_FLOW_RIGHT:uint = 0

Adds a bridge to the right of the flow of the path.

ORIENTATION_LEFTConstant 
public static const ORIENTATION_LEFT:uint = 5

Adds bridges that point to the left.

ORIENTATION_NEGATIVEConstant 
public static const ORIENTATION_NEGATIVE:uint = 3

Adds a bridge in the direction of the negative axes.

ORIENTATION_POSITIVEConstant 
public static const ORIENTATION_POSITIVE:uint = 2

Adds a bridge in the direction of the positive axes.

ORIENTATION_RIGHTConstant 
public static const ORIENTATION_RIGHT:uint = 4

Adds bridges that point to the right.

ORIENTATION_UPConstant 
public static const ORIENTATION_UP:uint = 7

Adds bridges that point upwards.

STYLE_ARCConstant 
public static const STYLE_ARC:uint = 5

The style that for each crossing inserts two quarter circle arcs into the path, that are connected by a straight line.

STYLE_ARC_SCALEDConstant 
public static const STYLE_ARC_SCALED:uint = 6

The style that for each crossing inserts a half circle into the path.

STYLE_CUSTOMConstant 
public static const STYLE_CUSTOM:uint = 7

The style that will use the IAddBridgesCallback.InsertCustomBridge() method to insert the bridge.

STYLE_GAPConstant 
public static const STYLE_GAP:uint = 0

The style that indicates that there should be a gap left in the path.

STYLE_RECTANGLEConstant 
public static const STYLE_RECTANGLE:uint = 1

The style that makes the crossing look like the upper half of a rectangle being inserted into the path.

STYLE_RECTANGLE_SCALEDConstant 
public static const STYLE_RECTANGLE_SCALED:uint = 2

The style that makes the crossing look like the upper half of a rectangle being inserted into the path, where the height has been scaled to keep the ascpet ratio for greater widths.

STYLE_TWO_SIDESConstant 
public static const STYLE_TWO_SIDES:uint = 3

The style that for each crossing inserts two sides of a triangle into the path.

STYLE_TWO_SIDES_SCALEDConstant 
public static const STYLE_TWO_SIDES_SCALED:uint = 4

The style that for each crossing inserts two sides of a triangle into the path, where the height has been scaled to keep the ascpet ratio for greater widths.