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

java.lang.Object
  extended by edu.uci.ics.jung.graph.decorators.StringLabeller
      extended by edu.uci.ics.jung.graph.decorators.ToStringLabeller
All Implemented Interfaces:
VertexStringer

public class ToStringLabeller
extends StringLabeller

Labels vertices by their toString. This class functions as a drop-in replacement for the default StringLabeller method. This class does not guarantee unique labels; or even consistent ones; as a result, getVertexByLabel will always return NULL.

Author:
danyelf

Nested Class Summary
 
Nested classes/interfaces 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, graph, labelToVertex, vertexToLabel
 
Constructor Summary
protected ToStringLabeller(Graph g)
           
 
Method Summary
 void assignDefaultLabels(Set vertices, int offset)
          This method is not meaningful; it throws an IllegalArgumentException
 String getLabel(ArchetypeVertex v)
          Retunrs v.toString()
 Vertex getVertex(String label)
          Always returns null: this impl doesn't keep a table, and so can't meaningfully address this.
 Vertex removeLabel(String string)
          This method is not meaningful; it throws an IllegalArgumentException
 void setLabel(Vertex v, String l)
          This method always throws an IllegalArgument exception: you cannot externally set the setstring method.
static StringLabeller setLabellerTo(Graph g)
          Sets the default StringLabeller of this graph to be a ToStringLabeller.
static StringLabeller setLabellerTo(Graph g, 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
clear, getGraph, getLabeller, getLabeller, hasStringLabeller, hasStringLabeller
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToStringLabeller

protected ToStringLabeller(Graph g)
Parameters:
g -
Method Detail

assignDefaultLabels

public void assignDefaultLabels(Set vertices,
                                int offset)
This method is not meaningful; it throws an IllegalArgumentException

Overrides:
assignDefaultLabels in class StringLabeller
Parameters:
vertices - The set of Vertices to label. All must be part of this graph.
offset - The starting value to number vertices from

removeLabel

public Vertex removeLabel(String string)
This method is not meaningful; it throws an IllegalArgumentException

Overrides:
removeLabel in class StringLabeller

setLabellerTo

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


setLabellerTo

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


getLabel

public String getLabel(ArchetypeVertex v)
Retunrs v.toString()

Specified by:
getLabel in interface VertexStringer
Overrides:
getLabel in class StringLabeller
Parameters:
v - a Vertex inside the Graph.

getVertex

public Vertex getVertex(String label)
Always returns null: this impl doesn't keep a table, and so can't meaningfully address this.

Overrides:
getVertex in class StringLabeller

setLabel

public void setLabel(Vertex v,
                     String l)
              throws StringLabeller.UniqueLabelException
This method always throws an IllegalArgument exception: you cannot externally set the setstring method.

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