Line | Hits | Source |
---|---|---|
1 | /* | |
2 | * Created on Nov 7, 2004 | |
3 | * | |
4 | * Copyright (c) 2004, the JUNG Project and the Regents of the University | |
5 | * of California | |
6 | * All rights reserved. | |
7 | * | |
8 | * This software is open-source under the BSD license; see either | |
9 | * "license.txt" or | |
10 | * http://jung.sourceforge.net/license.txt for a description. | |
11 | */ | |
12 | package edu.uci.ics.jung.graph.decorators; | |
13 | ||
14 | import java.util.Iterator; | |
15 | ||
16 | import edu.uci.ics.jung.graph.ArchetypeGraph; | |
17 | import edu.uci.ics.jung.graph.ArchetypeVertex; | |
18 | import edu.uci.ics.jung.utils.UserData; | |
19 | import edu.uci.ics.jung.utils.UserDataContainer.CopyAction; | |
20 | ||
21 | /** | |
22 | * | |
23 | * @author Joshua O'Madadhain | |
24 | */ | |
25 | public class UserDatumNumberVertexValue implements NumberVertexValue | |
26 | { | |
27 | protected Object key; | |
28 | protected CopyAction copy_action; | |
29 | ||
30 | /** | |
31 | * Creates an instance with the specified key and with a | |
32 | * <code>CopyAction</code> of <code>REMOVE</code>. | |
33 | */ | |
34 | public UserDatumNumberVertexValue(Object key) | |
35 | 0 | { |
36 | 0 | this.key = key; |
37 | 0 | this.copy_action = UserData.REMOVE; |
38 | 0 | } |
39 | ||
40 | /** | |
41 | * Creates an instance with the specified key and <code>CopyAction</code>. | |
42 | */ | |
43 | public UserDatumNumberVertexValue(Object key, CopyAction copy_action) | |
44 | 0 | { |
45 | 0 | this.key = key; |
46 | 0 | this.copy_action = copy_action; |
47 | 0 | } |
48 | ||
49 | public void setCopyAction(CopyAction copy_action) | |
50 | { | |
51 | 0 | this.copy_action = copy_action; |
52 | 0 | } |
53 | ||
54 | /** | |
55 | * @see edu.uci.ics.jung.graph.decorators.NumberVertexValue#getNumber(edu.uci.ics.jung.graph.ArchetypeVertex) | |
56 | */ | |
57 | public Number getNumber(ArchetypeVertex v) | |
58 | { | |
59 | 0 | return (Number)v.getUserDatum(key); |
60 | } | |
61 | ||
62 | /** | |
63 | * @see edu.uci.ics.jung.graph.decorators.NumberVertexValue#setNumber(edu.uci.ics.jung.graph.ArchetypeVertex, java.lang.Number) | |
64 | */ | |
65 | public void setNumber(ArchetypeVertex v, Number n) | |
66 | { | |
67 | 0 | v.setUserDatum(key, n, copy_action); |
68 | 0 | } |
69 | ||
70 | /** | |
71 | * Removes this decoration from <code>g</code>. | |
72 | */ | |
73 | public void clear(ArchetypeGraph g) | |
74 | { | |
75 | 0 | for (Iterator iter = g.getVertices().iterator(); iter.hasNext(); ) |
76 | { | |
77 | 0 | ArchetypeVertex v = (ArchetypeVertex)iter.next(); |
78 | 0 | v.removeUserDatum(key); |
79 | } | |
80 | 0 | } |
81 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |