Coverage details for edu.uci.ics.jung.graph.filters.GraphAssemblyRecord

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 package edu.uci.ics.jung.graph.filters;
11  
12 import edu.uci.ics.jung.graph.Graph;
13  
14 /**
15  * Contains an audit trail of a graph filtering step. Maintains the name
16  * of the filters used, a history of previous filters, and links to
17  * the original graph that was used to generate the graph.
18  *
19  * @author danyelf
20  */
21 public class GraphAssemblyRecord {
22  
23     /**
24      * The key that identifes this <tt>GraphAssemblyRecord</tt> in the
25      * {@link edu.uci.ics.jung.utils.UserData UserData}.
26      */
272    public static final Object FILTER_GRAPH_KEY = "edu.uci.ics.jung.filter.UnassembledGraph_FilterData";
28  
29     private String name;
30     private Graph originalGraph;
31  
32     /**
33      * Creates a <tt>GraphAssemblyRecord<tt>, recording the original
34      * <tt>Graph</tt> and the name of the filter that produced it.
35      * <p>
36      * This should be done automatically during the <tt>assemble()</tt>
37      * call to the <tt>UnassembledGraph</tt>.
38      * @param graph
39      */
405    GraphAssemblyRecord(UnassembledGraph graph) {
415        this.originalGraph = graph.getOriginalGraph();
425        this.name = graph.getFilterName();
435    }
44     
45     /**
46      * Returns the original graph that created this subset. Warning:
47      * because this stays around, the original Graph will NOT be
48      * garbage collected! Be sure to delete this user data if you
49      * want to allow the original graph's memory to be reallocated.
50      * @return a pointer to the original Graph.
51      */
52     public Graph getOriginalGraph() {
530        return originalGraph;
54     }
55     
56     /**
57      * Returns the name of the filter that generated this Graph. If a series
58      * of filters were used (as in the second example at
59      * <tt>{@link EfficientFilter EfficientFilter}</tt>,
60      * then they are all returned, collated together.
61      * @return the name of the filter
62      */
63     public String getName() {
640        return name;
65     }
66     
67     /**
68      * Returns the GraphAssemblyRecord, if it exists, of the original
69      * graph. If the original graph was generated by a different filter
70      * (as in the first example at
71      * <tt>{@link EfficientFilter EfficientFilter}</tt>,
72      * then there is a "previous" graph--and thus a previous <tt>GraphAssemblyRecord</tt>.
73      */
74     public GraphAssemblyRecord getPreviousAssemblyRecord() {
750        GraphAssemblyRecord gar = (GraphAssemblyRecord) originalGraph.getUserDatum( FILTER_GRAPH_KEY );
760        return gar;
77     }
78     
79  
80     /**
81      * Returns the collated name of the sequence of filters. Names are
82      * returned in reverse order, separated by ":::".
83      * If the original graph was generated by a different filter (as in the
84      * first example at
85      * <tt>{@link EfficientFilter EfficientFilter}</tt>,
86      * then there is a "previous" graph--and thus a previous <tt>GraphAssemblyRecord</tt>.
87      * This follows the chain back and returns the collated set of names.
88      */
89     public String getNameExtended() {
900        if (getPreviousAssemblyRecord() != null) {
910            return (name + ":::" + getPreviousAssemblyRecord().getNameExtended() );
92         } else {
930            return name;
94         }
95     }
96  
97     /**
98      * Returns the first original graph
99      * If the original graph was generated by a different filter (as in the
100      * first example at
101      * <tt>{@link EfficientFilter EfficientFilter}</tt>,
102      * then there is a "previous" graph--and thus a previous <tt>GraphAssemblyRecord</tt>.
103      * This follows the chain back and returns the first Graph.
104      */
105     public Graph getOriginalExtended() {
1060        if (getPreviousAssemblyRecord() != null) {
1070            return (getPreviousAssemblyRecord().getOriginalExtended() );
108         } else {
1090            return originalGraph;
110         }
111     }
112  
113     /**
114      * Returns the <tt>GraphAssemblyRecord</tt> for a particular graph. Expects the
115      * data to be stored in the user data.
116      * @param g A <tt>Graph</tt> that may be a filtered version of some other graph.
117      * @return The <tt>GraphAssemblyRecord</tt> associated with the graph, or
118      * <tt>null</tt>, if there isn't one.
119      *
120      * @see #FILTER_GRAPH_KEY
121      * @see Graph#getUserDatum
122      */
123     public static GraphAssemblyRecord getAssemblyRecord( Graph g) {
1244        GraphAssemblyRecord gar = (GraphAssemblyRecord) g.getUserDatum( FILTER_GRAPH_KEY );
1254        return gar;
126     }
127  
128 }

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.