1
2
3
4
5
6
7
8
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 com.google.common.base.Function;
17
18 import edu.uci.ics.jung.algorithms.util.IterativeContext;
19 import edu.uci.ics.jung.graph.Graph;
20
21
22
23
24
25
26
27
28 public abstract class LayoutDecorator<V, E> implements Layout<V, E>, IterativeContext {
29
30 protected Layout<V, E> delegate;
31
32
33
34
35
36 public LayoutDecorator(Layout<V, E> delegate) {
37 this.delegate = delegate;
38 }
39
40
41
42
43 public Layout<V,E> getDelegate() {
44 return delegate;
45 }
46
47 public void setDelegate(Layout<V,E> delegate) {
48 this.delegate = delegate;
49 }
50
51 public void step() {
52 if(delegate instanceof IterativeContext) {
53 ((IterativeContext)delegate).step();
54 }
55 }
56
57 public void initialize() {
58 delegate.initialize();
59 }
60
61 public void setInitializer(Function<V, Point2D> initializer) {
62 delegate.setInitializer(initializer);
63 }
64
65 public void setLocation(V v, Point2D location) {
66 delegate.setLocation(v, location);
67 }
68
69 public Dimension getSize() {
70 return delegate.getSize();
71 }
72
73 public Graph<V, E> getGraph() {
74 return delegate.getGraph();
75 }
76
77 public Point2D transform(V v) {
78 return delegate.apply(v);
79 }
80
81 public boolean done() {
82 if(delegate instanceof IterativeContext) {
83 return ((IterativeContext)delegate).done();
84 }
85 return true;
86 }
87
88 public void lock(V v, boolean state) {
89 delegate.lock(v, state);
90 }
91
92 public boolean isLocked(V v) {
93 return delegate.isLocked(v);
94 }
95
96 public void setSize(Dimension d) {
97 delegate.setSize(d);
98 }
99
100 public void reset() {
101 delegate.reset();
102 }
103
104 public void setGraph(Graph<V, E> graph) {
105 delegate.setGraph(graph);
106 }
107 }