edu.uci.ics.jung.visualization.decorators
Class EdgeWeightLabeller<E>

java.lang.Object
  extended by edu.uci.ics.jung.visualization.decorators.EdgeWeightLabeller<E>
All Implemented Interfaces:
NumberEdgeValue<E>

public class EdgeWeightLabeller<E>
extends Object
implements NumberEdgeValue<E>

A EdgeWeightLabeller applies a label to the edges of a Graph. All edge weights are integers; weights need not be unique. (The cost of not being unique is that there's no way to look up edges by weight.) Note that this stores information with the graph, and as such is not flexible to addition and substraction of nodes.

Author:
danyelf TODO : Should store weight in a decorator, per-Edge instead of per-Graph.

Constructor Summary
EdgeWeightLabeller()
           
 
Method Summary
 void clear()
          Clears all weights stored by this decorator.
 Number getNumber(E e)
           
 int getWeight(E e)
          Gets the weight of a particualr edge.
 Number removeWeight(E e)
          Removes the weight stored by this decorator for the indicated edge e, and returns the value of this weight (or null if there was no such weight for this edge).
 void setNumber(E e, Number n)
           
 void setWeight(E e, int i)
          Sets an edge to this weight.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EdgeWeightLabeller

public EdgeWeightLabeller()
Method Detail

getWeight

public int getWeight(E e)
Gets the weight of a particualr edge. Throws an exception if the edge is not weighted, or if the edge is not a part of the graph.

Parameters:
e - an edge that has been weighted.

setWeight

public void setWeight(E e,
                      int i)
Sets an edge to this weight.

Parameters:
e - the edge
i - the weight
Throws:
if - the edge is not part of the graph

removeWeight

public Number removeWeight(E e)
Removes the weight stored by this decorator for the indicated edge e, and returns the value of this weight (or null if there was no such weight for this edge).


clear

public void clear()
Clears all weights stored by this decorator.


getNumber

public Number getNumber(E e)
Specified by:
getNumber in interface NumberEdgeValue<E>
Parameters:
e - the edge to examine
Returns:
the Number associated with this edge
See Also:
edu.uci.ics.jung.graph.decorators.NumberEdgeValue#getNumber(edu.uci.ics.jung.graph.ArchetypeEdge)

setNumber

public void setNumber(E e,
                      Number n)
Specified by:
setNumber in interface NumberEdgeValue<E>
Parameters:
e - the edge whose value we're setting
n - the Number to which we're setting the edge
See Also:
edu.uci.ics.jung.graph.decorators.NumberEdgeValue#setNumber(edu.uci.ics.jung.graph.ArchetypeEdge, java.lang.Number)


Copyright © 2008 null. All Rights Reserved.