2 * Copyright (c) 2005, the JUNG Project and the Regents of the University of
3 * California All rights reserved.
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.
8 * Created on Aug 23, 2005
11 package edu.uci.ics.jung.algorithms.layout;
13 import java.awt.Dimension;
14 import java.awt.geom.Point2D;
16 import org.apache.commons.collections15.Transformer;
18 import edu.uci.ics.jung.algorithms.util.IterativeContext;
19 import edu.uci.ics.jung.graph.Graph;
22 * a pure decorator for the Layout interface. Intended to be overridden
23 * to provide specific behavior decoration
28 public abstract class LayoutDecorator<V, E> implements Layout<V, E>, IterativeContext {
30 protected Layout<V, E> delegate;
33 * Creates an instance backed by the specified delegate layout.
35 public LayoutDecorator(Layout<V, E> delegate) {
36 this.delegate = delegate;
40 * Returns the backing (delegate) layout.
42 public Layout<V,E> getDelegate() {
47 * Sets the backing (delegate) layout.
49 public void setDelegate(Layout<V,E> delegate) {
50 this.delegate = delegate;
54 * @see edu.uci.ics.jung.algorithms.util.IterativeContext#done()
57 if(delegate instanceof IterativeContext) {
58 ((IterativeContext)delegate).step();
64 * @see edu.uci.ics.jung.algorithms.layout.Layout#initialize()
66 public void initialize() {
67 delegate.initialize();
72 * @see edu.uci.ics.jung.algorithms.layout.Layout#setInitializer(org.apache.commons.collections15.Transformer)
74 public void setInitializer(Transformer<V, Point2D> initializer) {
75 delegate.setInitializer(initializer);
81 * @see edu.uci.ics.jung.algorithms.layout.Layout#setLocation(java.lang.Object, java.awt.geom.Point2D)
83 public void setLocation(V v, Point2D location) {
84 delegate.setLocation(v, location);
88 * @see edu.uci.ics.jung.algorithms.layout.Layout#getSize()
90 public Dimension getSize() {
91 return delegate.getSize();
95 * @see edu.uci.ics.jung.algorithms.layout.Layout#getGraph()
97 public Graph<V, E> getGraph() {
98 return delegate.getGraph();
102 * @see edu.uci.ics.jung.algorithms.layout.Layout#transform(Object)
104 public Point2D transform(V v) {
105 return delegate.transform(v);
109 * @see edu.uci.ics.jung.algorithms.util.IterativeContext#done()
111 public boolean done() {
112 if(delegate instanceof IterativeContext) {
113 return ((IterativeContext)delegate).done();
119 * @see edu.uci.ics.jung.algorithms.layout.Layout#lock(Object, boolean)
121 public void lock(V v, boolean state) {
122 delegate.lock(v, state);
126 * @see edu.uci.ics.jung.algorithms.layout.Layout#isLocked(Object)
128 public boolean isLocked(V v) {
129 return delegate.isLocked(v);
133 * @see edu.uci.ics.jung.algorithms.layout.Layout#setSize(Dimension)
135 public void setSize(Dimension d) {
140 * @see edu.uci.ics.jung.algorithms.layout.Layout#reset()
142 public void reset() {
146 public void setGraph(Graph<V, E> graph) {
147 delegate.setGraph(graph);