Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.uci.ics.jung.graph.decorators
Class StringLabeller

    java.lang.Object
      edu.uci.ics.jung.graph.decorators.StringLabeller

All Implemented Interfaces:
  VertexStringer

Direct Known Subclasses:
  GlobalStringLabeller, ToStringLabeller

public class StringLabeller
extends Object
implements VertexStringer

A StringLabeller applies a set of labels to a Graph. The Labeller, specifically, attaches itself to a Graph's UserData, and maintains an index of Strings that are labels. Note that the strings must be unique so that getVertex( label ) will work.

Author:
  danyelf

Nested Class Summary
`static class` | `StringLabeller.UniqueLabelException` A minor class to store exceptions from duplicate labels in the Graph.

Field Summary
`static Object` | `DEFAULT_STRING_LABELER_KEY` The key that hasLabeller() and getLabeller() use.
`protected Graph` | `graph`
`protected Map` | `labelToVertex`
`protected Map` | `vertexToLabel`

Constructor Summary
`protected` | `StringLabeller(Graph g)`

Method Summary
`void` | `assignDefaultLabels(Set vertices, int offset)` Assigns textual labels to every vertex passed in.
`void` | `clear()` Wipes the entire table.
`Graph` | `getGraph()` Gets the graph associated with this StringLabeller
`String` | `getLabel(ArchetypeVertex v)` Gets the String label associated with a particular Vertex.
`static StringLabeller` | `getLabeller(Graph g)` Gets a labeller associated with this graph.
`static StringLabeller` | `getLabeller(Graph g, Object key)` Returns a labeller attached to a particular key in the graph.
`Vertex` | `getVertex(String label)` Gets the Vertex from the graph associated with this label.
`static boolean` | `hasStringLabeller(Graph g)` Checks if a labeller is associated with this graph.
`static boolean` | `hasStringLabeller(Graph g, Object key)` Checks for a labeller attached to a particular key in the graph.
`Vertex` | `removeLabel(String string)`
`void` | `setLabel(Vertex v, String l)` Associates a Vertex with a Label, overrwriting any previous labels on this vertex.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_STRING_LABELER_KEY

    public static final Object DEFAULT_STRING_LABELER_KEY

  The key that hasLabeller() and getLabeller() use.

### labelToVertex

    protected Map labelToVertex

### vertexToLabel

    protected Map vertexToLabel

### graph

    protected Graph graph

Constructor Detail

### StringLabeller

    protected StringLabeller(Graph g)

Parameters:
  `g` - The graph to which this labeller should attach itself

Method Detail

### getLabeller

    public static StringLabeller getLabeller(Graph g)

  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.

### hasStringLabeller

    public static boolean hasStringLabeller(Graph g)

  Checks if a labeller is associated with this graph.

  Parameters:
    `g` - The graph to check.

### hasStringLabeller

    public static boolean hasStringLabeller(Graph g,
                                            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.

### getLabeller

    public static StringLabeller getLabeller(Graph g,
                                             Object key)

  Returns 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:
    a StringLabeller

### getGraph

    public Graph getGraph()

  Gets the graph associated with this StringLabeller

  Returns:
    a Graph that uses this StringLabeller.

### getLabel

    public String getLabel(ArchetypeVertex v)

  Gets the String label associated with a particular Vertex.

  Specified by:
    `getLabel` in interface `VertexStringer`
  Parameters:
    `v` - a Vertex inside the Graph.
  Throws:
    `FatalException` - if the Vertex is not in the Graph associated with this Labeller.

### getVertex

    public Vertex getVertex(String label)

  Gets the Vertex from the graph associated with this label.

  Parameters:
    `label` -

### setLabel

    public void setLabel(Vertex v,
                         String l)
                  throws StringLabeller.UniqueLabelException

  Associates a Vertex with a Label, overrwriting any previous labels on this vertex.

  Parameters:
    `v` - a Vertex in the labeller's graph
    `l` - a Label to be associated with this vertex
  Throws:
    `FatalException` - thrown if this vertex isn't in the Labeller's graph
    `StringLabeller.UniqueLabelException` - thrown if this label is already associated with some other vertex.

### assignDefaultLabels

    public void assignDefaultLabels(Set vertices,
                                    int offset)
                             throws StringLabeller.UniqueLabelException

  Assigns textual labels to every vertex passed in. Walks through the graph in iterator order, assigning labels "offset", "offset+1" "offset+2". The count starts at offset.

  Parameters:
    `vertices` - The set of Vertices to label. All must be part of this graph.
    `offset` - The starting value to number vertices from
  Throws:
    `StringLabeller.UniqueLabelException` - Is thrown if some other vertexc is already numbered.
    `FatalException` - if any Vertex is not part of the Graph.

### removeLabel

    public Vertex removeLabel(String string)

  Parameters:
    `string` -

### clear

    public void clear()

  Wipes the entire table. Resets everything.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD