| Line | Hits | Source |
|---|---|---|
| 1 | /* | |
| 2 | * Created on Apr 27, 2005 | |
| 3 | * | |
| 4 | * Copyright (c) 2005, 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.impl; | |
| 13 | ||
| 14 | import java.util.Iterator; | |
| 15 | import java.util.Set; | |
| 16 | ||
| 17 | import edu.uci.ics.jung.exceptions.FatalException; | |
| 18 | import edu.uci.ics.jung.graph.ArchetypeEdge; | |
| 19 | import edu.uci.ics.jung.graph.ArchetypeGraph; | |
| 20 | import edu.uci.ics.jung.graph.ArchetypeVertex; | |
| 21 | ||
| 22 | /** | |
| 23 | * | |
| 24 | * @author Joshua O'Madadhain | |
| 25 | */ | |
| 26 | 147163 | public abstract class AbstractArchetypeEdge extends AbstractElement implements |
| 27 | ArchetypeEdge | |
| 28 | { | |
| 29 | ||
| 30 | public Set getIncidentElements() | |
| 31 | { | |
| 32 | 0 | return getIncidentVertices(); |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#getEqualEdge(edu.uci.ics.jung.graph.ArchetypeGraph) | |
| 37 | */ | |
| 38 | public ArchetypeEdge getEqualEdge(ArchetypeGraph ag) | |
| 39 | { | |
| 40 | 276839 | if (ag instanceof AbstractArchetypeGraph) |
| 41 | { | |
| 42 | 124463 | AbstractArchetypeGraph aag = (AbstractArchetypeGraph)ag; |
| 43 | 124463 | return aag.getEdgeByID(this.getID()); |
| 44 | } | |
| 45 | else | |
| 46 | 152376 | return null; |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * @deprecated As of version 1.4, renamed to getEqualEdge(ag). | |
| 51 | */ | |
| 52 | public ArchetypeEdge getEquivalentEdge(ArchetypeGraph ag) | |
| 53 | { | |
| 54 | 0 | return getEqualEdge(ag); |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#numVertices() | |
| 59 | */ | |
| 60 | public int numVertices() | |
| 61 | { | |
| 62 | 0 | return getIncidentVertices().size(); |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#isIncident(edu.uci.ics.jung.graph.ArchetypeVertex) | |
| 67 | */ | |
| 68 | public boolean isIncident(ArchetypeVertex v) | |
| 69 | { | |
| 70 | 0 | return getIncidentVertices().contains(v); |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * @see edu.uci.ics.jung.graph.ArchetypeEdge#copy(edu.uci.ics.jung.graph.ArchetypeGraph) | |
| 75 | */ | |
| 76 | public ArchetypeEdge copy(ArchetypeGraph g) | |
| 77 | { | |
| 78 | 907 | if (g == this.getGraph()) |
| 79 | 1 | throw new IllegalArgumentException("Source and destination " + |
| 80 | "graphs must be different"); | |
| 81 | ||
| 82 | 906 | for (Iterator iter = getIncidentVertices().iterator(); iter.hasNext(); ) |
| 83 | { | |
| 84 | 1775 | ArchetypeVertex av = (ArchetypeVertex)iter.next(); |
| 85 | 1775 | if (av.getEqualVertex(g) == null) |
| 86 | 1 | throw new IllegalArgumentException("Cannot create edge: " + |
| 87 | "source edge's incident vertex " + av + "has no equivalent " + | |
| 88 | "in target graph"); | |
| 89 | } | |
| 90 | ||
| 91 | AbstractArchetypeEdge e; | |
| 92 | try | |
| 93 | { | |
| 94 | 905 | e = (AbstractArchetypeEdge)this.clone(); |
| 95 | } | |
| 96 | 0 | catch (CloneNotSupportedException cnse) |
| 97 | { | |
| 98 | 0 | throw new FatalException("Can't copy edge " + this, cnse); |
| 99 | 905 | } |
| 100 | 905 | e.initialize(); |
| 101 | 905 | e.importUserData(this); |
| 102 | 905 | return e; |
| 103 | } | |
| 104 | ||
| 105 | /** | |
| 106 | * Returns <code>true</code> if <code>o</code> is an instance of | |
| 107 | * <code>ArchetypeEdge</code> that is equivalent to this edge. | |
| 108 | * Respects the edge | |
| 109 | * equivalences which are established by <code>copy()</code> and | |
| 110 | * referenced by <code>getEquivalentEdge()</code>. | |
| 111 | * | |
| 112 | * @see java.lang.Object#equals(java.lang.Object) | |
| 113 | * @see ArchetypeEdge#getEqualEdge(ArchetypeGraph) | |
| 114 | * @see ArchetypeEdge#copy | |
| 115 | */ | |
| 116 | public boolean equals(Object o) | |
| 117 | { | |
| 118 | 277648 | if (this == o) |
| 119 | { | |
| 120 | 1464 | return true; |
| 121 | } | |
| 122 | 276184 | if (!(o instanceof ArchetypeEdge)) |
| 123 | 0 | return false; |
| 124 | 276184 | ArchetypeEdge e = (ArchetypeEdge) o; |
| 125 | 276184 | return (this == e.getEqualEdge(this.getGraph())); |
| 126 | } | |
| 127 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |