Coverage details for edu.uci.ics.jung.visualization.subLayout.SubLayoutDecorator

LineHitsSource
1 /*
2  * Copyright (c) 2005, 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 Aug 23, 2005
9  */
10  
11 package edu.uci.ics.jung.visualization.subLayout;
12  
13 import java.awt.geom.Point2D;
14 import java.util.Collection;
15 import java.util.Iterator;
16 import java.util.LinkedHashSet;
17  
18 import edu.uci.ics.jung.graph.ArchetypeVertex;
19 import edu.uci.ics.jung.graph.Vertex;
20 import edu.uci.ics.jung.visualization.Layout;
21 import edu.uci.ics.jung.visualization.LayoutDecorator;
22  
23 /**
24  * Extends the base decorator class and overrides methods to
25  * cause the location methods to check with the sublayouts
26  * for location information
27  *
28  * @author Tom Nelson - RABA Technologies
29  *
30  *
31  */
32 public class SubLayoutDecorator extends LayoutDecorator {
33  
340    final protected Collection subLayouts = new LinkedHashSet();
35     
36     public SubLayoutDecorator(Layout delegate) {
370        super(delegate);
380    }
39     
40     public void addSubLayout(SubLayout subLayout) {
410        subLayouts.add(subLayout);
420        fireStateChanged();
430    }
44     
45     public boolean removeSubLayout(SubLayout subLayout) {
460        boolean wasThere = subLayouts.remove(subLayout);
470        fireStateChanged();
480        return wasThere;
49     }
50     
51     public void removeAllSubLayouts() {
520        subLayouts.clear();
530        fireStateChanged();
540    }
55     
56     protected Point2D getLocationInSubLayout(ArchetypeVertex v) {
570        Point2D location = null;
580        for(Iterator iterator=subLayouts.iterator(); iterator.hasNext(); ) {
590            SubLayout subLayout = (SubLayout)iterator.next();
600            location = subLayout.getLocation(v);
610            if(location != null) {
620                break;
63             }
64         }
650        return location;
66     }
67     
68     public Point2D getLocation(ArchetypeVertex v) {
690        Point2D p = getLocationInSubLayout(v);
700        if(p != null) {
710            return p;
72         } else {
730            return super.getLocation(v);
74         }
75     }
76     
77     public void forceMove(Vertex picked, double x, double y) {
780        Point2D p = getLocationInSubLayout(picked);
790        if(p != null) {
800            p.setLocation(x, y);
81         } else {
820            super.forceMove(picked, x, y);
83         }
840        fireStateChanged();
850    }
86  
87 }

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.