Packagecom.yworks.yfiles.layout.router.polyline
Classpublic class PenaltySettings
InheritancePenaltySettings Inheritance YObject Inheritance Object

Provides the cost penalties that are applied for violating restrictions during a path search.

The com.yworks.yfiles.layout.router.polyline.PathSearch calculates the 'shortest' path from a source to a target at which 'shortest' path means the path with the lowest costs. Costs results from violations of restrictions that are defined by the different com.yworks.yfiles.layout.router.polyline.PathSearchExtension s. This class defines penalties for the various violations. The path search can be adapted to specific needs by varying these penalties. In order to avoid a certain violation, the appropriate penalty must be increased.

See also

com.yworks.yfiles.layout.router.polyline.PathSearch
com.yworks.yfiles.layout.router.polyline.PathSearchExtension


Public Properties
 PropertyDefined By
  bendPenalty : Number
Specifies the penalty for an edge bend.
PenaltySettings
  bendsInNodeToEdgeDistancePenalty : Number
Specifies the penalty for an edge bend being closer to the border of the source node, the target node or one of their ancestor group nodes than the minimal node to edge distance.
PenaltySettings
  edgeCrossingPenalty : Number
Specifies the penalty for a crossing of two edges.
PenaltySettings
  edgeLabelCrossingPenalty : Number
Getter: Returns the penalty for an edge crossing an edge label.
PenaltySettings
  edgeLengthPenalty : Number
Specifies the penalty for the edge length.
PenaltySettings
  groupNodeCrossingPenalty : Number
Specifies the penalty for an edge crossing a group node.
PenaltySettings
  invalidEdgeGroupingPenalty : Number
Specifies the penalty for an edge with a group id that is not grouped at source or target side.
PenaltySettings
  minimalEdgeToEdgeDistancePenalty : Number
Specifies the penalty for violations of the minimal distance between any two edges.
PenaltySettings
  minimalFirstLastSegmentLengthPenalty : Number
Specifies the penalty for violations of the minimal length of the first and last segment of an edge.
PenaltySettings
  minimalGroupNodeToEdgeDistancePenalty : Number
Specifies the penalty for violations of the minimal distance between any edge and any group node side.
PenaltySettings
  minimalNodeCornerDistancePenalty : Number
Specifies the penalty for violations of the minimal distance the edge shall keep from node corners when entering or leaving the node.
PenaltySettings
  minimalNodeToEdgeDistancePenalty : Number
Specifies the penalty for violations of the minimal distance between any edge and any non-group node side.
PenaltySettings
  monotonyViolationPenalty : Number
Specifies the penalty for violation the monotonic path restrictions of an edge.
PenaltySettings
  nodeCrossingPenalty : Number
Specifies the penalty for an edge crossing a regular node.
PenaltySettings
  nodeLabelCrossingPenalty : Number
Getter: Returns the penalty for an edge crossing a node label.
PenaltySettings
  partitionGridCellReentrancePenalty : Number
Specifies the penalty for an edge leaving and reentering in the same partition grid cell.
PenaltySettings
  portViolationPenalty : Number
Specifies the penalty if an edge does not comply with its com.yworks.yfiles.layout.PortCandidate s or com.yworks.yfiles.layout.PortConstraint s.
PenaltySettings
Public Methods
 MethodDefined By
  
PenaltySettings(init:Boolean = true)
Creates a new instance.
PenaltySettings
  
Creates a copy of this instance.
PenaltySettings
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
PenaltySettings
 Inherited
hashCode():int
YObject
  
[static] Creates a new instance.
PenaltySettings
Protected Methods
 MethodDefined By
  
Initializes this object.
PenaltySettings
  
Factory method, which is used by createCopy().
PenaltySettings
Public Constants
 ConstantDefined By
  OPTIMIZATION_BALANCED : PenaltySettings
[static] Optimization strategy that balances bends and edge crossings in the edge routes.
PenaltySettings
  OPTIMIZATION_EDGE_BENDS : PenaltySettings
[static] Optimization strategy that minimizes bends in the edge routes.
PenaltySettings
  OPTIMIZATION_EDGE_CROSSINGS : PenaltySettings
[static] Optimization strategy that minimizes edge crossings in the edge routes.
PenaltySettings
  OPTIMIZATION_EDGE_LENGTHS : PenaltySettings
[static] Optimization strategy that minimizes the length of the edge routes.
PenaltySettings
Property Detail
bendPenaltyproperty
bendPenalty:Number

Specifies the penalty for an edge bend. This penalty will make routes with many bends more expensive than routes with few or no bends, so edges will have preferably few bends.

Increasing bend penalty will raise the importance of avoiding bends in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions. A high bend penalty will result in routes that will preferably cross other edges instead of bending to avoid other edges. When rising edge bend penalty, the resulting route will have more edge crossings. Note that a very low bend penalty (less than 1) can lead to squiggles when the algorithm tries to avoid more expensive restrictions.

OPTIMIZATION_EDGE_BENDS is a predefined configuration of PenaltySettings where bends are expensive and more other edges will be crossed to avoid bending.

By default this value is set to 3. The value must be >= 0, otherwise the default value will be assigned.


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

See also

bendsInNodeToEdgeDistancePenaltyproperty 
bendsInNodeToEdgeDistancePenalty:Number

Specifies the penalty for an edge bend being closer to the border of the source node, the target node or one of their ancestor group nodes than the minimal node to edge distance. This penalty will make routes that bend too close to their source or target node more expensive than routes that keep the specified minimal node to edge distance.

Increasing bends in node to edge distance penalty will raise the importance of avoiding bends that violate the minimal node to edge distance while decreasing this penalty will raise the importance of all other restrictions. This penalty supports com.yworks.yfiles.layout.router.polyline.EdgeRouter.minimalNodeToEdgeDistance . In case the path search finally reaches the target node, the minimal node to edge distance for this node must be violated. Punishing bends too close to the node forces the edge to directly cross this distance and connect to the node.

By default this value is set to 10. The value must be >= 0, otherwise the default value will be assigned. In principle, this penalty can always be set to the same value as minimalNodeToEdgeDistancePenalty since they are used for the same feature.


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

See also

edgeCrossingPenaltyproperty 
edgeCrossingPenalty:Number

Specifies the penalty for a crossing of two edges. This penalty will make routes that cross many other edges more expensive than routes that only cross some other edges or no edges at all, so edges preferably won't cross other edges.

Increasing edge crossing penalty will raise the importance of avoiding edge crossings in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions. When rising edge crossing penalty, the resulting route will be longer and have more bends because crossing other edges needs to be avoided.

OPTIMIZATION_EDGE_CROSSINGS is a predefined configuration of PenaltySettings where edge crossings are expensive and the routes get favourably longer with more bends to avoid crossing other edges.

By default this value is set to 1. The value must be >= 0, otherwise the default value will be assigned.


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

See also

edgeLabelCrossingPenaltyproperty 
edgeLabelCrossingPenalty:Number

Getter: Returns the penalty for an edge crossing an edge label. This penalty will make routes that cross edge labels of fixed edges more expensive than routes that avoid crossing edge labels, so edges won't preferably cross any edge labels that belong to fixed edges.

Increasing edge label crossing penalty will raise the importance of avoiding edge labels crossings in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions. A high label crossing penalty will cause edges to bend more often to avoid passing straight through the label.

The crossing penalty can be weighted for each label individually using the com.yworks.yfiles.layout.router.polyline.EdgeRouter.LABEL_CROSSING_COST_FACTOR_DPKEY.

Use com.yworks.yfiles.layout.router.polyline.EdgeRouter.considerEdgeLabelsEnabled to set whether edge labels should be considered when routing the edges.

Setter: Sets the penalty for an edge crossing an edge label. This penalty will make routes that cross edge labels of fixed edges more expensive than routes that avoid crossing edge labels, so edges won't preferably cross any edge labels that belong to fixed edges.

Increasing edge label crossing penalty will raise the importance of avoiding edge labels crossings in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions. A high label crossing penalty will cause edges to bend more often to avoid passing straight through the label.

Use com.yworks.yfiles.layout.router.polyline.EdgeRouter.considerEdgeLabelsEnabled to set whether edge labels should be considered when routing the edges.

By default this value is set to 13. The value must be >= 0, otherwise the default value will be assigned.


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

See also

edgeLengthPenaltyproperty 
edgeLengthPenalty:Number

Specifies the penalty for the edge length. This penalty will make long routes more expensive than short routes so edges will be routed preferably short.

Increasing edge length penalty will raise the importance of short edges in relation to all other penalties while decreasing this penalty will raise the importance of all other restrictions. A high edge length penalty will result in routes that have less bends and more edge crossings to keep the edge as short as possible.

OPTIMIZATION_EDGE_LENGTHS is a predefined configuration of PenaltySettings where short edges are preferred over a small amount of bends and edge crossings.

By default this value is set to 1. The value must be >= 0, otherwise the default value will be assigned.


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

See also

groupNodeCrossingPenaltyproperty 
groupNodeCrossingPenalty:Number

Specifies the penalty for an edge crossing a group node. This penalty will make routes that cross group nodes more expensive than routes that avoid crossing group nodes, so edges won't preferably cross any group nodes.

Increasing group node crossing penalty will raise the importance of avoiding group node crossings in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions.

Like node crossing penalty (nodeCrossingPenalty), this penalty should be one of the highest penalties to make sure that these nodes are avoided. But as group nodes may be very large it might be useful to allow group node crossings to achieve more direct edge routes.


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

See also

invalidEdgeGroupingPenaltyproperty 
invalidEdgeGroupingPenalty:Number

Specifies the penalty for an edge with a group id that is not grouped at source or target side. This penalty will make routes for grouped edges that don't use partly the same path as the other edges in this group more expensive than routes that stick to the group.

Increasing invalid edge grouping penalty will raise the importance of grouping edges with the same group id while decreasing this penalty will raise the importance of all other restrictions. As edge groups require that the route of an edge belonging to an edge group stays partly identical to the other edges of the group, the route may not be the optimal way regarding the other restrictions. To keep the edges together as long as possible this penalty should be higher than most others.

Grouped edges have the same source or target group id assigned in the data provider registered at the graph with the com.yworks.yfiles.layout.PortConstraintKeys.SOURCE_GROUPID_KEY or com.yworks.yfiles.layout.PortConstraintKeys.TARGET_GROUPID_KEY key.

By default this value is set to 25. The value must be >= 0, otherwise the default value will be assigned.


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

See also

minimalEdgeToEdgeDistancePenaltyproperty 
minimalEdgeToEdgeDistancePenalty:Number

Specifies the penalty for violations of the minimal distance between any two edges. This penalty will make routes that pass other edges too close more expensive than routes that keep the specified minimal edge to edge distance.

Increasing minimal edge to edge distance penalty will raise the importance of keeping the minimal distance to other edges while decreasing this penalty will raise the importance of all other restrictions. When this penalty has a high value, edges will keep the specified distance. This may also reduce the number of edge that pass through a small channel between nodes. So, if such a channel is part of the shortest routes for many edges, some of them will take a longer way.

Use com.yworks.yfiles.layout.router.polyline.EdgeLayoutDescriptor.minimalEdgeToEdgeDistance to set the minimal distance for a certain edge to any other edge.

By default this value is set to 5. The value must be >= 0, otherwise the default value will be assigned.


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

See also

minimalFirstLastSegmentLengthPenaltyproperty 
minimalFirstLastSegmentLengthPenalty:Number

Specifies the penalty for violations of the minimal length of the first and last segment of an edge. This penalty will make routes whose first/last bend is too close to their source or target node more expensive than routes that keep the specified minimal first/last segment length.

Increasing minimal first last segment length penalty will raise the importance of keeping the first and last segment as long as they fit the minimal first/last segment length while decreasing this penalty will raise the importance of all other restrictions.

Use com.yworks.yfiles.layout.router.polyline.EdgeLayoutDescriptor.minimalFirstSegmentLength to set the minimal length of the first segment and com.yworks.yfiles.layout.router.polyline.EdgeLayoutDescriptor.minimalLastSegmentLength to set the minimal length of the last segment of a certain edge.

By default this value is set to 12. The value must be >= 0, otherwise the default value will be assigned.


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

See also

minimalGroupNodeToEdgeDistancePenaltyproperty 
minimalGroupNodeToEdgeDistancePenalty:Number

Specifies the penalty for violations of the minimal distance between any edge and any group node side. This penalty will make routes that pass group nodes too close more expensive than routes that keep the specified minimal node to edge distance.

Increasing minimal group node to edge distance penalty will raise the importance of keeping the minimal distance to group nodes while decreasing this penalty will raise the importance of all other restrictions. A high penalty for violating the minimal distance between edges and group nodes will produce edges that rather use a long route around group nodes to keep the specified distance than pass through a small channel between two group nodes.

Use com.yworks.yfiles.layout.router.polyline.EdgeRouter.minimalNodeToEdgeDistance to set the minimal distance.

By default this value is set to 10. The value must be >= 0, otherwise the default value will be assigned.


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

See also

minimalNodeCornerDistancePenaltyproperty 
minimalNodeCornerDistancePenalty:Number

Specifies the penalty for violations of the minimal distance the edge shall keep from node corners when entering or leaving the node. This penalty will make routes that end too close to the corner of their source or target node more expensive than routes that keep the specified minimal node corner distance.

Increasing node corner distance penalty will raise the importance of keeping the minimal distance to the corner of the adjacent nodes while decreasing this penalty will raise the importance of all other restrictions.

Use com.yworks.yfiles.layout.router.polyline.EdgeLayoutDescriptor.minimalNodeCornerDistance to set the minimal distance for a certain edge.

By default this value is set to 6. The value must be >= 0, otherwise the default value will be assigned.


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

See also

minimalNodeToEdgeDistancePenaltyproperty 
minimalNodeToEdgeDistancePenalty:Number

Specifies the penalty for violations of the minimal distance between any edge and any non-group node side. This penalty will make routes that pass normal nodes too close more expensive than routes that keep the specified minimal node to edge distance.

Increasing minimal node to edge distance penalty will raise the importance of keeping the minimal distance to nodes while decreasing this penalty will raise the importance of all other restrictions. A high penalty for violating the minimal distance between edges and nodes will produce edges that rather use a long route around nodes to keep the specified distance than pass through a small channel between two nodes.

By default this value is set to 10. The value must be >= 0, otherwise the default value will be assigned.


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

See also

monotonyViolationPenaltyproperty 
monotonyViolationPenalty:Number

Specifies the penalty for violation the monotonic path restrictions of an edge. This penalty will make routes with detours more expensive than routes that stay monotone.

Increasing monotony violation penalty will raise the importance of avoiding detours in the specified direction while decreasing this penalty will raise the importance of all other restrictions.

Use com.yworks.yfiles.layout.router.polyline.EdgeLayoutDescriptor.monotonicPathRestriction to set the monotonic path restrictions of a certain edge.

By default this value is set to 14. The value must be >= 0, otherwise the default value will be assigned.


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

See also

nodeCrossingPenaltyproperty 
nodeCrossingPenalty:Number

Specifies the penalty for an edge crossing a regular node. This penalty will make routes that cross normal nodes more expensive than routes that avoid crossing nodes, so edges won't preferably cross any nodes.

Increasing node crossing penalty will raise the importance of avoiding node crossings in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions.

Node crossing penalty should always be one of the highest penalties to make sure that edges go around nodes.

By default this value is set to 30. The value must be >= 0, otherwise the default value will be assigned.


Implementation
    public function get nodeCrossingPenalty():Number
    public function set nodeCrossingPenalty(value:Number):void
nodeLabelCrossingPenaltyproperty 
nodeLabelCrossingPenalty:Number

Getter: Returns the penalty for an edge crossing a node label. This penalty will make routes that cross node labels more expensive than routes that avoid crossing node labels, so edges won't preferably cross any node labels.

Increasing node label crossing penalty will raise the importance of avoiding node labels crossings in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions. A high label crossing penalty will cause edges to bend more often to avoid passing straight through the label.

The crossing penalty can be weighted for each label individually using the com.yworks.yfiles.layout.router.polyline.EdgeRouter.LABEL_CROSSING_COST_FACTOR_DPKEY.

Use com.yworks.yfiles.layout.router.polyline.EdgeRouter.considerNodeLabelsEnabled to set whether node labels should be considered when routing the edges at all.

Note that this only applies to labels that are placed outside the bounds of their owner nodes as long as the node crossing penalty (nodeCrossingPenalty) is higher than the node label crossing penalty. Unless the route connects from outside a group to one of its inner nodes, then the node label will also be considered.

Setter: Sets the penalty for an edge crossing a node label. This penalty will make routes that cross node labels more expensive than routes that avoid crossing node labels, so edges won't preferably cross any node labels.

Increasing node label crossing penalty will raise the importance of avoiding node labels crossings in relation to other penalties while decreasing this penalty will raise the importance of all other restrictions. A high label crossing penalty will cause edges to bend more often to avoid passing straight through the label.

Use com.yworks.yfiles.layout.router.polyline.EdgeRouter.considerNodeLabelsEnabled to set whether node labels should be considered when routing the edges.

Note that this only applies to labels that are placed outside the bounds of their owner nodes as long as the node crossing penalty (nodeCrossingPenalty) is higher than the node label crossing penalty. Unless the route connects from outside a group to one of its inner nodes, then the node label will also be considered.

By default this value is set to 13. The value must be >= 0, otherwise the default value will be assigned.


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

See also

partitionGridCellReentrancePenaltyproperty 
partitionGridCellReentrancePenalty:Number

Specifies the penalty for an edge leaving and reentering in the same partition grid cell. This penalty will make routes that reenter the same partition grid cell more expensive than routes taking a more direct way.

Increasing partition grid reentrance penalty will raise the importance of taking the most direct way through the partition grid while decreasing this penalty will raise the importance of all other restrictions.

By default this value is set to 7. The value must be >= 0, otherwise the default value will be assigned.


Implementation
    public function get partitionGridCellReentrancePenalty():Number
    public function set partitionGridCellReentrancePenalty(value:Number):void
portViolationPenaltyproperty 
portViolationPenalty:Number

Specifies the penalty if an edge does not comply with its com.yworks.yfiles.layout.PortCandidate s or com.yworks.yfiles.layout.PortConstraint s. This penalty will make routes that start or end on a point that doesn't answer to its port constraints more expensive than routes that obey them.

Increasing port violation penalty will raise the importance of keeping port constraints while decreasing this penalty will raise the importance of all other restrictions. It is recommended to have high penalties for port violation since the constraints loose purpose if they are disregarded.

By default this value is set to 115. The value must be >= 0, otherwise the default value will be assigned.


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

See also

Constructor Detail
PenaltySettings()Constructor
public function PenaltySettings(init:Boolean = true)

Creates a new instance.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
createCopy()method
public function createCopy():PenaltySettings

Creates a copy of this instance. Uses newInstance() to get a new instance.

Returns
PenaltySettings — a copy of this instance

See also

getClass()method 
override public function getClass():Class

Returns
Class
initPenaltySettings()method 
protected final function initPenaltySettings():void

Initializes this object. See the documentation of the corresponding factory method newPenaltySettings() for details.

See also

newInstance()method 
protected function newInstance():PenaltySettings

Factory method, which is used by createCopy(). Subclasses can override this method in order to return a more specialized version.

Returns
PenaltySettings — a specialized instance of this class

See also

newPenaltySettings()method 
public static function newPenaltySettings():PenaltySettings

Creates a new instance.

Returns
PenaltySettings
Constant Detail
OPTIMIZATION_BALANCEDConstant
public static const OPTIMIZATION_BALANCED:PenaltySettings

Optimization strategy that balances bends and edge crossings in the edge routes. These are the default settings.

OPTIMIZATION_EDGE_BENDSConstant 
public static const OPTIMIZATION_EDGE_BENDS:PenaltySettings

Optimization strategy that minimizes bends in the edge routes. Edges may cross other edges to prevent bending to run around them.

OPTIMIZATION_EDGE_CROSSINGSConstant 
public static const OPTIMIZATION_EDGE_CROSSINGS:PenaltySettings

Optimization strategy that minimizes edge crossings in the edge routes. This may cause more bends.

OPTIMIZATION_EDGE_LENGTHSConstant 
public static const OPTIMIZATION_EDGE_LENGTHS:PenaltySettings

Optimization strategy that minimizes the length of the edge routes. There may be more edge crossings.