Coverage details for edu.uci.ics.jung.graph.decorators.ToStringLabeller

LineHitsSource
1 /*
2  * Copyright (c) 2003, the JUNG Project and the Regents of the University
3  * of California
4  * All rights reserved.
5  *
6  * This software is open-source under the BSD license; see either
7  * "license.txt" or
8  * http://jung.sourceforge.net/license.txt for a description.
9  */
10 /*
11  * Created on Apr 13, 2004
12  */
13 package edu.uci.ics.jung.graph.decorators;
14  
15 import java.util.Set;
16  
17 import edu.uci.ics.jung.graph.ArchetypeVertex;
18 import edu.uci.ics.jung.graph.Graph;
19 import edu.uci.ics.jung.graph.Vertex;
20 import edu.uci.ics.jung.utils.UserData;
21  
22 /**
23  * Labels vertices by their toString. This class functions as a drop-in
24  * replacement for the default StringLabeller method. This class does not
25  * guarantee unique labels; or even consistent ones; as a result,
26  * getVertexByLabel will always return NULL.
27  *
28  * @author danyelf
29  */
30 public class ToStringLabeller extends StringLabeller {
31  
32     /**
33      * This method is not meaningful; it throws an IllegalArgumentException
34      */
35     public void assignDefaultLabels(Set vertices, int offset)
36     {
371        throw new IllegalArgumentException();
38     }
39     /**
40      * This method is not meaningful; it throws an IllegalArgumentException
41      */
42     public Vertex removeLabel(String string) {
431        throw new IllegalArgumentException();
44     }
45     /**
46      * @param g
47      */
48     protected ToStringLabeller(Graph g) {
491        super(g);
501        labelToVertex = null;
511        vertexToLabel = null;
52         // TODO Auto-generated constructor stub for ToStringLabeller
531    }
54  
55     /**
56      * Sets the StringLabeller of this graph, at this key, to be a
57      * ToStringLabeller.
58      */
59     public static StringLabeller setLabellerTo(Graph g, Object key) {
601        StringLabeller sl = new ToStringLabeller(g);
611        if (key != null) g.addUserDatum(key, sl, UserData.REMOVE);
621        return sl;
63     }
64  
65     /**
66      * Sets the default StringLabeller of this graph to be a ToStringLabeller.
67      */
68     public static StringLabeller setLabellerTo(Graph g) {
691        return setLabellerTo(g, StringLabeller.DEFAULT_STRING_LABELER_KEY);
70     }
71  
72     /**
73      * Retunrs v.toString()
74      */
75     public String getLabel(ArchetypeVertex v) {
7620        return v.toString();
77     }
78  
79     /**
80      * Always returns null: this impl doesn't keep a table, and so can't
81      * meaningfully address this.
82      */
83     public Vertex getVertex(String label) {
8410        return null;
85     }
86  
87     /**
88      * This method always throws an IllegalArgument exception: you cannot
89      * externally set the setstring method.
90      */
91     public void setLabel(Vertex v, String l) throws UniqueLabelException {
921        throw new IllegalArgumentException(
93                 "Can't manually set labels on a ToString labeller");
94     }
95 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.