edu.uci.ics.jung.graph.decorators
Class GlobalStringLabeller

java.lang.Object
  extended byedu.uci.ics.jung.graph.decorators.StringLabeller
      extended byedu.uci.ics.jung.graph.decorators.GlobalStringLabeller

public class GlobalStringLabeller
extends StringLabeller

The GlobalStringLabeller applies labels to all vertices in a series of graphs. That is, rather than storing one instance per graph, it stores one instance globally that maps from vertex ID to label.

Author:
danyelf

Nested Class Summary
 
Nested classes inherited from class edu.uci.ics.jung.graph.decorators.StringLabeller
StringLabeller.UniqueLabelException
 
Field Summary
 
Fields inherited from class edu.uci.ics.jung.graph.decorators.StringLabeller
DEFAULT_STRING_LABELER_KEY
 
Method Summary
static StringLabeller getInstance()
           
 java.lang.String getLabel(Vertex v)
          Gets the String label associated with a particular Vertex.
static StringLabeller getLabeller(Graph g)
          Gets a labeller associated with this graph.
static boolean hasStringLabeller(Graph g)
          Checks if a labeller--any labeller--is associated with this graph.
static boolean hasStringLabeller(Graph g, java.lang.Object key)
          Checks for a labeller attached to a particular key in the graph.
 void setLabel(Vertex v, java.lang.String l)
          Associates a Vertex with a Label, overrwriting any previous labels on this vertex or vertices equal to it.
static StringLabeller setLabellerTo(Graph g)
          Sets the default StringLabeller of this graph to be a ToStringLabeller.
static StringLabeller setLabellerTo(Graph g, java.lang.Object key)
          Sets the StringLabeller of this graph, at this key, to be a ToStringLabeller.
 
Methods inherited from class edu.uci.ics.jung.graph.decorators.StringLabeller
assignDefaultLabels, clear, getGraph, getLabeller, getVertex, removeLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLabellerTo

public static StringLabeller setLabellerTo(Graph g,
                                           java.lang.Object key)
Sets the StringLabeller of this graph, at this key, to be a ToStringLabeller.


getInstance

public static StringLabeller getInstance()
Returns:

getLabeller

public static StringLabeller getLabeller(Graph g)
Description copied from class: StringLabeller
Gets a labeller associated with this graph. If no Labeller is associated, creates one and returns it. This method is the same as getLabeller with a key argument, but uses the DEFAULT_STRING_LABELER_KEY as its UserData key. param g The Graph to check.


setLabellerTo

public static StringLabeller setLabellerTo(Graph g)
Sets the default StringLabeller of this graph to be a ToStringLabeller.


hasStringLabeller

public static boolean hasStringLabeller(Graph g)
Checks if a labeller--any labeller--is associated with this graph.

Parameters:
g - The graph to check.

hasStringLabeller

public static boolean hasStringLabeller(Graph g,
                                        java.lang.Object key)
Checks for a labeller attached to a particular key in the graph. Useful for creating more than one Labeller for a particular Graph.

Parameters:
g - the Graph
key - the UserData key to which it is attached
Returns:
true if the graph has this labeller.

getLabel

public java.lang.String getLabel(Vertex v)
Gets the String label associated with a particular Vertex.

Overrides:
getLabel in class StringLabeller
Parameters:
v - a Vertex
Returns:
the label associated with that vertex If the vertex is not in the graph, throws a FatalException

setLabel

public void setLabel(Vertex v,
                     java.lang.String l)
              throws StringLabeller.UniqueLabelException
Associates a Vertex with a Label, overrwriting any previous labels on this vertex or vertices equal to it.

Overrides:
setLabel in class StringLabeller
Parameters:
v - a Vertex
l - a Label to be associated with this vertex
Throws:
UniqueLabelException - thrown if this label is already associated with some other vertex.
StringLabeller.UniqueLabelException