View Javadoc

1   package edu.uci.ics.jung.visualization;
2   
3   import java.awt.BasicStroke;
4   import java.awt.Font;
5   import java.awt.Paint;
6   import java.awt.Shape;
7   import java.awt.Stroke;
8   
9   import javax.swing.CellRendererPane;
10  import javax.swing.Icon;
11  import javax.swing.JComponent;
12  
13  import org.apache.commons.collections15.Predicate;
14  import org.apache.commons.collections15.Transformer;
15  
16  import edu.uci.ics.jung.algorithms.layout.GraphElementAccessor;
17  import edu.uci.ics.jung.graph.Graph;
18  import edu.uci.ics.jung.graph.util.Context;
19  import edu.uci.ics.jung.graph.util.EdgeIndexFunction;
20  import edu.uci.ics.jung.graph.util.EdgeType;
21  import edu.uci.ics.jung.visualization.picking.PickedState;
22  import edu.uci.ics.jung.visualization.renderers.EdgeLabelRenderer;
23  import edu.uci.ics.jung.visualization.renderers.VertexLabelRenderer;
24  import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator;
25  
26  public interface RenderContext<V, E> {
27  
28      float[] dotting = {1.0f, 3.0f};
29      float[] dashing = {5.0f};
30  
31      /**
32       * A stroke for a dotted line: 1 pixel width, round caps, round joins, and an 
33       * array of {1.0f, 3.0f}.
34       */
35      Stroke DOTTED = new BasicStroke(1.0f,
36              BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dotting, 0f);
37  
38      /**
39       * A stroke for a dashed line: 1 pixel width, square caps, beveled joins, and an
40       * array of {5.0f}.
41       */
42      Stroke DASHED = new BasicStroke(1.0f,
43              BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 1.0f, dashing, 0f);
44  
45      /**
46       * Specifies the offset for the edge labels.
47       */
48      int LABEL_OFFSET = 10;
49  
50      int getLabelOffset();
51      
52      void setLabelOffset(int labelOffset);
53      
54      float getArrowPlacementTolerance();
55  
56      void setArrowPlacementTolerance(float arrow_placement_tolerance);
57  
58      Transformer<Context<Graph<V,E>,E>,Shape> getEdgeArrowTransformer();
59  
60      void setEdgeArrowTransformer(Transformer<Context<Graph<V,E>,E>,Shape> edgeArrowTransformer);
61  
62      Predicate<Context<Graph<V,E>,E>> getEdgeArrowPredicate() ;
63  
64      void setEdgeArrowPredicate(Predicate<Context<Graph<V,E>,E>> edgeArrowPredicate);
65  
66      Transformer<E,Font> getEdgeFontTransformer();
67  
68      void setEdgeFontTransformer(Transformer<E,Font> edgeFontTransformer);
69  
70      Predicate<Context<Graph<V,E>,E>> getEdgeIncludePredicate();
71  
72      void setEdgeIncludePredicate(Predicate<Context<Graph<V,E>,E>> edgeIncludePredicate);
73  
74      Transformer<Context<Graph<V,E>,E>,Number> getEdgeLabelClosenessTransformer();
75  
76      void setEdgeLabelClosenessTransformer(
77      		Transformer<Context<Graph<V,E>,E>,Number> edgeLabelClosenessTransformer);
78  
79      EdgeLabelRenderer getEdgeLabelRenderer();
80  
81      void setEdgeLabelRenderer(EdgeLabelRenderer edgeLabelRenderer);
82  
83      Transformer<E,Paint> getEdgeFillPaintTransformer();
84  
85      void setEdgeFillPaintTransformer(Transformer<E,Paint> edgePaintTransformer);
86  
87      Transformer<E,Paint> getEdgeDrawPaintTransformer();
88  
89      void setEdgeDrawPaintTransformer(Transformer<E,Paint> edgeDrawPaintTransformer);
90  
91      Transformer<E,Paint> getArrowDrawPaintTransformer();
92  
93      void setArrowDrawPaintTransformer(Transformer<E,Paint> arrowDrawPaintTransformer);
94  
95      Transformer<E,Paint> getArrowFillPaintTransformer();
96  
97      void setArrowFillPaintTransformer(Transformer<E,Paint> arrowFillPaintTransformer);
98  
99      Transformer<Context<Graph<V,E>,E>,Shape> getEdgeShapeTransformer();
100 
101     void setEdgeShapeTransformer(Transformer<Context<Graph<V,E>,E>,Shape> edgeShapeTransformer);
102 
103     Transformer<E,String> getEdgeLabelTransformer();
104 
105     void setEdgeLabelTransformer(Transformer<E,String> edgeStringer);
106 
107     Transformer<E,Stroke> getEdgeStrokeTransformer();
108 
109     void setEdgeStrokeTransformer(Transformer<E,Stroke> edgeStrokeTransformer);
110     
111     Transformer<E,Stroke> getEdgeArrowStrokeTransformer();
112 
113     void setEdgeArrowStrokeTransformer(Transformer<E,Stroke> edgeArrowStrokeTransformer);
114     
115     GraphicsDecorator getGraphicsContext();
116     
117     void setGraphicsContext(GraphicsDecorator graphicsContext);
118 
119     EdgeIndexFunction<V, E> getParallelEdgeIndexFunction();
120 
121     void setParallelEdgeIndexFunction(
122             EdgeIndexFunction<V, E> parallelEdgeIndexFunction);
123 
124     PickedState<E> getPickedEdgeState();
125 
126     void setPickedEdgeState(PickedState<E> pickedEdgeState);
127 
128     PickedState<V> getPickedVertexState();
129 
130     void setPickedVertexState(PickedState<V> pickedVertexState);
131 
132     CellRendererPane getRendererPane();
133 
134     void setRendererPane(CellRendererPane rendererPane);
135 
136     JComponent getScreenDevice();
137 
138     void setScreenDevice(JComponent screenDevice);
139 
140     Transformer<V,Font> getVertexFontTransformer();
141 
142     void setVertexFontTransformer(Transformer<V,Font> vertexFontTransformer);
143 
144     Transformer<V,Icon> getVertexIconTransformer();
145 
146     void setVertexIconTransformer(Transformer<V,Icon> vertexIconTransformer);
147 
148     Predicate<Context<Graph<V,E>,V>> getVertexIncludePredicate();
149 
150     void setVertexIncludePredicate(Predicate<Context<Graph<V,E>,V>> vertexIncludePredicate);
151 
152     VertexLabelRenderer getVertexLabelRenderer();
153 
154     void setVertexLabelRenderer(VertexLabelRenderer vertexLabelRenderer);
155 
156     Transformer<V,Paint> getVertexFillPaintTransformer();
157 
158     void setVertexFillPaintTransformer(Transformer<V,Paint> vertexFillPaintTransformer);
159 
160     Transformer<V,Paint> getVertexDrawPaintTransformer();
161 
162     void setVertexDrawPaintTransformer(Transformer<V,Paint> vertexDrawPaintTransformer);
163 
164     Transformer<V,Shape> getVertexShapeTransformer();
165 
166     void setVertexShapeTransformer(Transformer<V,Shape> vertexShapeTransformer);
167 
168     Transformer<V,String> getVertexLabelTransformer();
169 
170     void setVertexLabelTransformer(Transformer<V,String> vertexStringer);
171 
172     Transformer<V,Stroke> getVertexStrokeTransformer();
173 
174     void setVertexStrokeTransformer(Transformer<V,Stroke> vertexStrokeTransformer);
175 
176 //    MutableTransformer getViewTransformer();
177 
178 //    void setViewTransformer(MutableTransformer viewTransformer);
179     
180     class DirectedEdgeArrowPredicate<V,E> 
181     	implements Predicate<Context<Graph<V,E>,E>> {
182 
183         public boolean evaluate(Context<Graph<V,E>,E> c) {
184             return c.graph.getEdgeType(c.element) == EdgeType.DIRECTED;
185         }
186         
187     }
188     
189     class UndirectedEdgeArrowPredicate<V,E> 
190     	implements Predicate<Context<Graph<V,E>,E>> {
191     	//extends AbstractGraphPredicate<V,E> {
192 
193         public boolean evaluate(Context<Graph<V,E>,E> c) {
194             return c.graph.getEdgeType(c.element) == EdgeType.UNDIRECTED;
195         }
196         
197     }
198     
199     MultiLayerTransformer getMultiLayerTransformer();
200     
201     void setMultiLayerTransformer(MultiLayerTransformer basicTransformer);
202     
203 	/**
204 	 * @return the pickSupport
205 	 */
206 	GraphElementAccessor<V, E> getPickSupport();
207 
208 	/**
209 	 * @param pickSupport the pickSupport to set
210 	 */
211 	void setPickSupport(GraphElementAccessor<V, E> pickSupport);
212 	
213 
214 }