y.layout.labeling
Class AbstractLabelingAlgorithm

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

public abstract class AbstractLabelingAlgorithm
extends AbstractLayoutStage

This class an anstract 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
AbstractLabelingAlgorithm()
           
 
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)
           
 YList getRects()
          Debug only.
 boolean getRemoveEdgeOverlaps()
          Returns how label candidates which overlap with edges are handeled.
 boolean getRemoveNodeOverlaps()
          Returns how label candidates which overlap with nodes are handeled.
 Object getSelectionKey()
          Sets the labeling selection.
 boolean isEdgeGroupOverlapAllowed()
          Returns whether edge labels may overlap with edges belonging to the same edge group.
 boolean isStoreRects()
          Debug only.
 void label(LayoutGraph gl)
          Place the labels in the graph.
protected abstract  void label(LayoutGraph g, y.layout.labeling.Label[] labels)
          Place some 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.
protected  void removeEdgesOverlaps(LayoutGraph gd, y.layout.labeling.Label[] labels)
          Determines which candidates overlap with edges and remove them from the candidate list.
protected  void removeNodesOverlaps(LayoutGraph gd, y.layout.labeling.Label[] labels)
          Determines which candidates overlap with nodes and remove them from the candidate list.
 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)
           
 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.
 
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

public AbstractLabelingAlgorithm()
Method Detail

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 handeled. 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 handeled. 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.


removeNodesOverlaps

protected void removeNodesOverlaps(LayoutGraph gd,
                                   y.layout.labeling.Label[] labels)
Determines which candidates overlap with nodes and remove them from the candidate list.

Parameters:
gd - the graph
labels - a list of LabelCandidates

removeEdgesOverlaps

protected void removeEdgesOverlaps(LayoutGraph gd,
                                   y.layout.labeling.Label[] labels)
Determines which candidates overlap with edges and remove them from the candidate list.

Parameters:
gd - the graph
labels - a list of LabelCandidates

setProfitModel

public void setProfitModel(ProfitModel model)

getProfit

public double getProfit(LabelCandidate l)

label

protected abstract void label(LayoutGraph g,
                              y.layout.labeling.Label[] labels)
Place some labels in the graph.


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-2003,
yWorks GmbH.
All rights reserved.

2003