Initial opendaylight infrastructure commit!!
[controller.git] / third-party / net.sf.jung2 / src / main / java / edu / uci / ics / jung / algorithms / layout / LayoutDecorator.java
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.algorithms.layout;
12
13 import java.awt.Dimension;
14 import java.awt.geom.Point2D;
15
16 import org.apache.commons.collections15.Transformer;
17
18 import edu.uci.ics.jung.algorithms.util.IterativeContext;
19 import edu.uci.ics.jung.graph.Graph;
20
21 /**
22  * a pure decorator for the Layout interface. Intended to be overridden
23  * to provide specific behavior decoration
24  * 
25  * @author Tom Nelson 
26  *
27  */
28 public abstract class LayoutDecorator<V, E> implements Layout<V, E>, IterativeContext {
29     
30     protected Layout<V, E> delegate;
31     
32     /**
33      * Creates an instance backed by the specified delegate layout.
34      */
35     public LayoutDecorator(Layout<V, E> delegate) {
36         this.delegate = delegate;
37     }
38
39     /**
40      * Returns the backing (delegate) layout.
41      */
42     public Layout<V,E> getDelegate() {
43         return delegate;
44     }
45
46     /**
47      * Sets the backing (delegate) layout.
48      */
49     public void setDelegate(Layout<V,E> delegate) {
50         this.delegate = delegate;
51     }
52
53     /**
54      * @see edu.uci.ics.jung.algorithms.util.IterativeContext#done()
55      */
56     public void step() {
57         if(delegate instanceof IterativeContext) {
58                 ((IterativeContext)delegate).step();
59         }
60     }
61
62     /**
63          * 
64          * @see edu.uci.ics.jung.algorithms.layout.Layout#initialize()
65          */
66         public void initialize() {
67                 delegate.initialize();
68         }
69
70         /**
71          * @param initializer
72          * @see edu.uci.ics.jung.algorithms.layout.Layout#setInitializer(org.apache.commons.collections15.Transformer)
73          */
74         public void setInitializer(Transformer<V, Point2D> initializer) {
75                 delegate.setInitializer(initializer);
76         }
77
78         /**
79          * @param v
80          * @param location
81          * @see edu.uci.ics.jung.algorithms.layout.Layout#setLocation(java.lang.Object, java.awt.geom.Point2D)
82          */
83         public void setLocation(V v, Point2D location) {
84                 delegate.setLocation(v, location);
85         }
86
87     /**
88      * @see edu.uci.ics.jung.algorithms.layout.Layout#getSize()
89      */
90     public Dimension getSize() {
91         return delegate.getSize();
92     }
93
94     /**
95      * @see edu.uci.ics.jung.algorithms.layout.Layout#getGraph()
96      */
97     public Graph<V, E> getGraph() {
98         return delegate.getGraph();
99     }
100
101     /**
102      * @see edu.uci.ics.jung.algorithms.layout.Layout#transform(Object)
103      */
104     public Point2D transform(V v) {
105         return delegate.transform(v);
106     }
107
108     /**
109      * @see edu.uci.ics.jung.algorithms.util.IterativeContext#done()
110      */
111     public boolean done() {
112         if(delegate instanceof IterativeContext) {
113                 return ((IterativeContext)delegate).done();
114         }
115         return true;
116     }
117
118     /**
119      * @see edu.uci.ics.jung.algorithms.layout.Layout#lock(Object, boolean)
120      */
121     public void lock(V v, boolean state) {
122         delegate.lock(v, state);
123     }
124
125     /**
126      * @see edu.uci.ics.jung.algorithms.layout.Layout#isLocked(Object)
127      */
128     public boolean isLocked(V v) {
129         return delegate.isLocked(v);
130     }
131     
132     /**
133      * @see edu.uci.ics.jung.algorithms.layout.Layout#setSize(Dimension)
134      */
135     public void setSize(Dimension d) {
136         delegate.setSize(d);
137     }
138
139     /**
140      * @see edu.uci.ics.jung.algorithms.layout.Layout#reset()
141      */
142     public void reset() {
143         delegate.reset();
144     }
145     
146     public void setGraph(Graph<V, E> graph) {
147         delegate.setGraph(graph);
148     }
149 }