1 /*
2 * Copyright (c) 2003, The JUNG Authors
3 *
4 * All rights reserved.
5 *
6 * This software is open-source under the BSD license; see either
7 * "license.txt" or
8 * https://github.com/jrtom/jung/blob/master/LICENSE 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> the vertex type
30 * @param <E> the edge type
31 */
32 public interface VisualizationServer<V, E> {
33
34 /**
35 * Specify whether this class uses its offscreen image or not.
36 *
37 * @param doubleBuffered if true, then doubleBuffering in the superclass is set to 'false'
38 */
39 void setDoubleBuffered(boolean doubleBuffered);
40
41 /**
42 * Returns whether this class uses double buffering. The superclass
43 * will be the opposite state.
44 * @return the double buffered state
45 */
46 boolean isDoubleBuffered();
47
48 /**
49 * @return the model.
50 */
51 VisualizationModel<V, E> getModel();
52
53 /**
54 * @param model the model for this class to use
55 */
56 void setModel(VisualizationModel<V, E> model);
57
58 /**
59 * In response to changes from the model, repaint the
60 * view, then fire an event to any listeners.
61 * Examples of listeners are the GraphZoomScrollPane and
62 * the BirdsEyeVisualizationViewer
63 * @param e the change event
64 */
65 void stateChanged(ChangeEvent e);
66
67 /**
68 * Sets the showing Renderer to be the input Renderer. Also
69 * tells the Renderer to refer to this instance
70 * as a PickedKey. (Because Renderers maintain a small
71 * amount of state, such as the PickedKey, it is important
72 * to create a separate instance for each VV instance.)
73 * @param r the renderer to use
74 */
75 void setRenderer(Renderer<V, E> r);
76
77 /**
78 * @return the renderer used by this instance.
79 */
80 Renderer<V, E> getRenderer();
81
82 /**
83 * Replaces the current graph layout with {@code layout}.
84 * @param layout the new layout to set
85 */
86 void setGraphLayout(Layout<V, E> layout);
87
88 /**
89 * @return the current graph layout.
90 */
91 Layout<V, E> getGraphLayout();
92
93 /**
94 * Makes the component visible if {@code aFlag} is true, or invisible if false.
95 * @param aFlag true iff the component should be visible
96 * @see javax.swing.JComponent#setVisible(boolean)
97 */
98 void setVisible(boolean aFlag);
99
100 /**
101 * @return the renderingHints
102 */
103 Map<Key, Object> getRenderingHints();
104
105 /**
106 * @param renderingHints The renderingHints to set.
107 */
108 void setRenderingHints(Map<Key, Object> renderingHints);
109
110 /**
111 * @param paintable The paintable to add.
112 */
113 void addPreRenderPaintable(Paintable paintable);
114
115 /**
116 * @param paintable The paintable to remove.
117 */
118 void removePreRenderPaintable(Paintable paintable);
119
120 /**
121 * @param paintable The paintable to add.
122 */
123 void addPostRenderPaintable(Paintable paintable);
124
125 /**
126 * @param paintable The paintable to remove.
127 */
128 void removePostRenderPaintable(Paintable paintable);
129
130 /**
131 * Adds a <code>ChangeListener</code>.
132 * @param l the listener to be added
133 */
134 void addChangeListener(ChangeListener l);
135
136 /**
137 * Removes a ChangeListener.
138 * @param l the listener to be removed
139 */
140 void removeChangeListener(ChangeListener l);
141
142 /**
143 * Returns an array of all the <code>ChangeListener</code>s added
144 * with addChangeListener().
145 *
146 * @return all of the <code>ChangeListener</code>s added or an empty
147 * array if no listeners have been added
148 */
149 ChangeListener[] getChangeListeners();
150
151 /**
152 * Notifies all listeners that have registered interest for
153 * notification on this event type. The event instance
154 * is lazily created.
155 * @see EventListenerList
156 */
157 void fireStateChanged();
158
159 /**
160 * @return the vertex PickedState instance
161 */
162 PickedState<V> getPickedVertexState();
163
164 /**
165 * @return the edge PickedState instance
166 */
167 PickedState<E> getPickedEdgeState();
168
169 void setPickedVertexState(PickedState<V> pickedVertexState);
170
171 void setPickedEdgeState(PickedState<E> pickedEdgeState);
172
173 /**
174 * @return the GraphElementAccessor
175 */
176 GraphElementAccessor<V, E> getPickSupport();
177
178 /**
179 * @param pickSupport The pickSupport to set.
180 */
181 void setPickSupport(GraphElementAccessor<V, E> pickSupport);
182
183 Point2D getCenter();
184
185 RenderContext<V, E> getRenderContext();
186
187 void setRenderContext(RenderContext<V, E> renderContext);
188
189 void repaint();
190
191 /**
192 * an interface for the preRender and postRender
193 */
194 interface Paintable {
195 public void paint(Graphics g);
196 public boolean useTransform();
197 }
198 }