|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uci.ics.jung.graph.decorators.StringLabeller
public class StringLabeller
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.
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 |
---|
public static final Object DEFAULT_STRING_LABELER_KEY
protected Map labelToVertex
protected Map vertexToLabel
protected Graph graph
Constructor Detail |
---|
protected StringLabeller(Graph g)
g
- The graph to which this labeller should attach itselfMethod Detail |
---|
public static StringLabeller getLabeller(Graph g)
public static boolean hasStringLabeller(Graph g)
g
- The graph to check.public static boolean hasStringLabeller(Graph g, Object key)
g
- the Graphkey
- the UserData key to which it is attached
public static StringLabeller getLabeller(Graph g, Object key)
g
- the Graphkey
- the UserData key to which it is attached
public Graph getGraph()
public String getLabel(ArchetypeVertex v)
getLabel
in interface VertexStringer
v
- a Vertex inside the Graph.
FatalException
- if the Vertex is not in the Graph associated with this
Labeller.public Vertex getVertex(String label)
label
- public void setLabel(Vertex v, String l) throws StringLabeller.UniqueLabelException
v
- a Vertex in the labeller's graphl
- a Label to be associated with this vertex
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.public void assignDefaultLabels(Set vertices, int offset) throws StringLabeller.UniqueLabelException
vertices
- The set of Vertices to label. All must be part of this graph.offset
- The starting value to number vertices from
StringLabeller.UniqueLabelException
- Is thrown if some other vertexc is already numbered.
FatalException
- if any Vertex is not part of the Graph.public Vertex removeLabel(String string)
string
- public void clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |