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.visualization;
11
12 import java.awt.Graphics;
13 import java.awt.RenderingHints.Key;
14 import java.awt.geom.Point2D;
15 import java.util.Map;
16
17 import javax.swing.event.ChangeEvent;
18 import javax.swing.event.ChangeListener;
19 import javax.swing.event.EventListenerList;
20
21 import edu.uci.ics.jung.algorithms.layout.GraphElementAccessor;
22 import edu.uci.ics.jung.algorithms.layout.Layout;
23 import edu.uci.ics.jung.visualization.picking.PickedState;
24 import edu.uci.ics.jung.visualization.renderers.Renderer;
25
26 /**
27 * @author tom
28 *
29 * @param <V>
30 * @param <E>
31 */
32 public interface VisualizationServer<V, E> {
33
34 /**
35 * set whether this class uses its offscreen image or not. If
36 * true, then doubleBuffering in the superclass is set to 'false'
37 */
38 void setDoubleBuffered(boolean doubleBuffered);
39
40 /**
41 * whether this class uses double buffering. The superclass
42 * will be the opposite state.
43 */
44 boolean isDoubleBuffered();
45
46 /**
47 * @return Returns the model.
48 */
49 VisualizationModel<V, E> getModel();
50
51 /**
52 * @param model The model to set.
53 */
54 void setModel(VisualizationModel<V, E> model);
55
56 /**
57 * In response to changes from the model, repaint the
58 * view, then fire an event to any listeners.
59 * Examples of listeners are the GraphZoomScrollPane and
60 * the BirdsEyeVisualizationViewer
61 */
62 void stateChanged(ChangeEvent e);
63
64 /**
65 * Sets the showing Renderer to be the input Renderer. Also
66 * tells the Renderer to refer to this visualizationviewer
67 * as a PickedKey. (Because Renderers maintain a small
68 * amount of state, such as the PickedKey, it is important
69 * to create a separate instance for each VV instance.)
70 */
71 void setRenderer(Renderer<V, E> r);
72
73 /**
74 * Returns the renderer used by this instance.
75 */
76 Renderer<V, E> getRenderer();
77
78 /**
79 * Removes the current graph layout, and adds a new one.
80 * @param layout the new layout to set
81 */
82 void setGraphLayout(Layout<V, E> layout);
83
84 /**
85 * Removes the current graph layout, and adds a new one,
86 * optionally re-scaling the view to show the entire layout
87 * @param layout the new layout to set
88 * @param scaleToLayout whether to scale the view to show the whole layout
89 */
90 // void setGraphLayout(Layout<V, E> layout, boolean scaleToLayout);
91
92 /**
93 * Returns the current graph layout.
94 * Passes thru to the model
95 */
96 Layout<V, E> getGraphLayout();
97
98 /**
99 *
100 * @see javax.swing.JComponent#setVisible(boolean)
101 */
102 void setVisible(boolean aFlag);
103
104 /**
105 * Returns a flag that says whether the visRunner thread is running. If
106 * it is not, then you may need to restart the thread.
107 */
108 // boolean isVisRunnerRunning();
109
110 /**
111 * Transform the mouse point with the inverse transform
112 * of the VisualizationViewer. This maps from screen coordinates
113 * to graph coordinates.
114 * @param p the point to transform (typically, a mouse point)
115 * @return a transformed Point2D
116 */
117 // Point2D inverseTransform(Point2D p);
118 //
119 // Point2D inverseViewTransform(Point2D p);
120 //
121 // Point2D inverseLayoutTransform(Point2D p);
122
123 /**
124 * Transform the mouse point with the current transform
125 * of the VisualizationViewer. This maps from graph coordinates
126 * to screen coordinates.
127 * @param p the point to transform
128 * @return a transformed Point2D
129 */
130 // Point2D transform(Point2D p);
131 //
132 // Point2D viewTransform(Point2D p);
133 //
134 // Point2D layoutTransform(Point2D p);
135
136 /**
137 * @param transformer The transformer to set.
138 */
139 // void setViewTransformer(MutableTransformer transformer);
140 //
141 // void setLayoutTransformer(MutableTransformer transformer);
142 //
143 // MutableTransformer getViewTransformer();
144 //
145 // MutableTransformer getLayoutTransformer();
146
147 /**
148 * @return Returns the renderingHints.
149 */
150 Map<Key, Object> getRenderingHints();
151
152 /**
153 * @param renderingHints The renderingHints to set.
154 */
155 void setRenderingHints(Map<Key, Object> renderingHints);
156
157 /**
158 * @param paintable The paintable to add.
159 */
160 void addPreRenderPaintable(Paintable paintable);
161
162 /**
163 * @param paintable The paintable to remove.
164 */
165 void removePreRenderPaintable(Paintable paintable);
166
167 /**
168 * @param paintable The paintable to add.
169 */
170 void addPostRenderPaintable(Paintable paintable);
171
172 /**
173 * @param paintable The paintable to remove.
174 */
175 void removePostRenderPaintable(Paintable paintable);
176
177 /**
178 * Adds a <code>ChangeListener</code>.
179 * @param l the listener to be added
180 */
181 void addChangeListener(ChangeListener l);
182
183 /**
184 * Removes a ChangeListener.
185 * @param l the listener to be removed
186 */
187 void removeChangeListener(ChangeListener l);
188
189 /**
190 * Returns an array of all the <code>ChangeListener</code>s added
191 * with addChangeListener().
192 *
193 * @return all of the <code>ChangeListener</code>s added or an empty
194 * array if no listeners have been added
195 */
196 ChangeListener[] getChangeListeners();
197
198 /**
199 * Notifies all listeners that have registered interest for
200 * notification on this event type. The event instance
201 * is lazily created.
202 * @see EventListenerList
203 */
204 void fireStateChanged();
205
206 /**
207 * @return Returns the pickedState.
208 */
209 PickedState<V> getPickedVertexState();
210
211 /**
212 * @return Returns the pickedState.
213 */
214 PickedState<E> getPickedEdgeState();
215
216 /**
217 * @param pickedState The pickedState to set.
218 */
219 void setPickedVertexState(PickedState<V> pickedVertexState);
220
221 void setPickedEdgeState(PickedState<E> pickedEdgeState);
222
223 /**
224 * @return Returns the GraphElementAccessor.
225 */
226 GraphElementAccessor<V, E> getPickSupport();
227
228 /**
229 * @param pickSupport The pickSupport to set.
230 */
231 void setPickSupport(GraphElementAccessor<V, E> pickSupport);
232
233 Point2D getCenter();
234
235 RenderContext<V, E> getRenderContext();
236
237 void setRenderContext(RenderContext<V, E> renderContext);
238
239 void repaint();
240
241 /**
242 * an interface for the preRender and postRender
243 */
244 interface Paintable {
245 public void paint(Graphics g);
246 public boolean useTransform();
247 }
248
249
250
251 }