y.layout.labeling
Class AbstractLabelingAlgorithm

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.labeling.AbstractLabelingAlgorithm
All Implemented Interfaces:
Layouter, LayoutStage
Direct Known Subclasses:
MISLabelingAlgorithm

public abstract class AbstractLabelingAlgorithm
extends AbstractLayoutStage

This class is an abstract base class for labeling algorithms. A labeling algorithm places a set of labels.

 

Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
protected AbstractLabelingAlgorithm()
          Creates a new instance of this class.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns true.
 void doLayout(LayoutGraph graph)
          Place the labels in the graph.
 boolean getPlaceEdgeLabels()
          Returns if labels assigned to nodes in a graph should be placed.
 boolean getPlaceNodeLabels()
          Returns if labels assigned to nodes in a graph should be placed.
 double getProfit(LabelCandidate l)
          Returns the profit model that is used to rank the available positions for each label.
 ProfitModel getProfitModel()
           
 YList getRects()
          Debug only.
 boolean getRemoveEdgeOverlaps()
          Returns how label candidates which overlap with edges are handled.
 boolean getRemoveNodeOverlaps()
          Returns how label candidates which overlap with nodes are handled.
 Object getSelectionKey()
          Sets the labeling selection.
 boolean isApplyPostprocessing()
          Returns true if the postprocessing step is applied.
 boolean isEdgeGroupOverlapAllowed()
          Returns whether edge labels may overlap with edges belonging to the same edge group.
 boolean isStoreRects()
          Debug only.
 boolean isUseAlternativeSideHandling()
          Returns true if the preference on which side of an edge a corresponding label should be placed is interpreted by human perception instead of always following the edge from source to target.
 void label(LayoutGraph gl)
          Place the labels in the graph.
 void label(LayoutGraph gl, Object key)
          Place a subset of the labels.
 void label(LayoutGraph gl, YList nodeLabels, YList edgeLabels)
          Place some labels in the graph.
 void setApplyPostprocessing(boolean applyPostprocessing)
          Sets if the postprocessing step should be applied.
 void setEdgeGroupOverlapAllowed(boolean edgeGroupOverlapAllowed)
          Sets the policy for edge groups.
 void setPlaceEdgeLabels(boolean value)
          Sets if labels assigned to nodes in a graph should be placed.
 void setPlaceNodeLabels(boolean value)
          Sets if labels assigned to nodes in a graph should be placed.
 void setProfitModel(ProfitModel model)
          Sets the profit model that is used to rank the available positions for each label.
 void setRemoveEdgeOverlaps(boolean flag)
          Sets how to handle label candidates which overlap with edges.
 void setRemoveNodeOverlaps(boolean flag)
          Sets how to handle label candidates which overlap with nodes.
 void setSelection(Object key)
          Sets the key, under which the labeling selection can be retrieved.
 void setStoreRects(boolean s)
          Debug only.
 void setUseAlternativeSideHandling(boolean useAlternativeSideHandling)
          If set, the preference on which side of an edge a corresponding label should be placed is interpreted by human perception instead of always following the edge from source to target.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractLabelingAlgorithm

protected AbstractLabelingAlgorithm()
Creates a new instance of this class.

Method Detail

getProfitModel

public ProfitModel getProfitModel()

isApplyPostprocessing

public boolean isApplyPostprocessing()
Returns true if the postprocessing step is applied. The postprocessing step tries to further reduce the number of overlaps.


setApplyPostprocessing

public void setApplyPostprocessing(boolean applyPostprocessing)
Sets if the postprocessing step should be applied. The postprocessing step tries to further reduce the number of overlaps.

Note: the postprocessing step is only applied to edge labels whose edge label model is FreeEdgeLabelModel and node labels whose node lable model is FreeNodeLabelModel.


isUseAlternativeSideHandling

public boolean isUseAlternativeSideHandling()
Returns true if the preference on which side of an edge a corresponding label should be placed is interpreted by human perception instead of always following the edge from source to target.


setUseAlternativeSideHandling

public void setUseAlternativeSideHandling(boolean useAlternativeSideHandling)
If set, the preference on which side of an edge a corresponding label should be placed is interpreted by human perception instead of always following the edge from source to target.

Note: the alternative side handling is only applied to edge labels whose edge label model is FreeEdgeLabelModel.


setRemoveNodeOverlaps

public void setRemoveNodeOverlaps(boolean flag)
Sets how to handle label candidates which overlap with nodes. If true these candidates are not considered, if false these candidates are considered, but a penalty is assigned to them.


setRemoveEdgeOverlaps

public void setRemoveEdgeOverlaps(boolean flag)
Sets how to handle label candidates which overlap with edges. If true these candidates are not considered, if false these candidates are considered, but a penalty is assigned to them.


getRemoveNodeOverlaps

public boolean getRemoveNodeOverlaps()
Returns how label candidates which overlap with nodes are handled. If true these candidates are not considered, if false these candidates are considered, but a penalty is assigned to them.


getRemoveEdgeOverlaps

public boolean getRemoveEdgeOverlaps()
Returns how label candidates which overlap with edges are handled. If true these candidates are not considered, if false these candidates are considered, but a penalty is assigned to them.


setPlaceNodeLabels

public void setPlaceNodeLabels(boolean value)
Sets if labels assigned to nodes in a graph should be placed. If true node labels are placed, if false node labels are ignored. This method has higher priority than the selection, i.e. even if a node label is selected it is not set when setPlaceNodeLabels(false) has been invoked before.


setPlaceEdgeLabels

public void setPlaceEdgeLabels(boolean value)
Sets if labels assigned to nodes in a graph should be placed. If true node labels placed, if false node labels are ignored. This method has higher priority than the selection, i.e. even if an edge label is selected it is not set when setPlaceEdgeLabels(false) has been invoked before.


getPlaceNodeLabels

public boolean getPlaceNodeLabels()
Returns if labels assigned to nodes in a graph should be placed. If true node labels placed, if false node labels are ignored.


getPlaceEdgeLabels

public boolean getPlaceEdgeLabels()
Returns if labels assigned to nodes in a graph should be placed. If true node labels placed, if false node labels are ignored.


setSelection

public void setSelection(Object key)
Sets the key, under which the labeling selection can be retrieved. If the selection is set, only selected labels are placed.

Parameters:
key - The key for a DataProvider. Labels which should be placed return true.

getSelectionKey

public Object getSelectionKey()
Sets the labeling selection. If the selection is set, only selected labels are placed.


canLayout

public boolean canLayout(LayoutGraph graph)
Returns true.


doLayout

public void doLayout(LayoutGraph graph)
Place the labels in the graph. This method is equivalent to the label() method.

Parameters:
graph - The graph to label.

label

public void label(LayoutGraph gl)
Place the labels in the graph.

Parameters:
gl - The graph to label.

label

public void label(LayoutGraph gl,
                  Object key)
Place a subset of the labels.

Parameters:
key - The key for a DataProvider in gl. Labels which should be placed return true.

label

public void label(LayoutGraph gl,
                  YList nodeLabels,
                  YList edgeLabels)
Place some labels in the graph. The selection is ignored, if set.


setProfitModel

public void setProfitModel(ProfitModel model)
Sets the profit model that is used to rank the available positions for each label. The higher the rank of a position, the more likely it will be chosen by the algorithm. By default an instance of type LabelRanking is set.


getProfit

public double getProfit(LabelCandidate l)
Returns the profit model that is used to rank the available positions for each label. The higher the rank of a position, the more likely it will be chosen by the algorithm. By default an instance of type LabelRanking is set.


getRects

public YList getRects()
Debug only. Returns the set of all generated candidate rectangles.


setStoreRects

public void setStoreRects(boolean s)
Debug only. Sets whether the candidate rectangles should be stored to be retrieved.


isStoreRects

public boolean isStoreRects()
Debug only. Returns whether the candidate rectangles should be stored to be retrieved.


isEdgeGroupOverlapAllowed

public boolean isEdgeGroupOverlapAllowed()
Returns whether edge labels may overlap with edges belonging to the same edge group.


setEdgeGroupOverlapAllowed

public void setEdgeGroupOverlapAllowed(boolean edgeGroupOverlapAllowed)
Sets the policy for edge groups. If edge labels overlap with other edges of the same group, this flag decides whether these positions are allowed.


© Copyright 2000-2008,
yWorks GmbH.
All rights reserved.