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