Line | Hits | Source |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2003, the JUNG Project and the Regents of the University of | |
3 | * California All rights reserved. | |
4 | * | |
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. | |
7 | */ | |
8 | package edu.uci.ics.jung.visualization.contrib; | |
9 | ||
10 | import java.awt.BorderLayout; | |
11 | import java.awt.Color; | |
12 | ||
13 | import javax.swing.JComponent; | |
14 | ||
15 | import edu.uci.ics.jung.visualization.BirdsEyeVisualizationViewer; | |
16 | import edu.uci.ics.jung.visualization.GraphDraw; | |
17 | import edu.uci.ics.jung.visualization.Layout; | |
18 | import edu.uci.ics.jung.visualization.Renderer; | |
19 | ||
20 | /** | |
21 | * Similar to GraphDraw, but with no method calls that will modify the | |
22 | * underlying graph. This component is used as the view to create a | |
23 | * birds-eye zoom/pan tool | |
24 | * | |
25 | * @author Tom Nelson - adapted from code written by Danyel Fisher | |
26 | * @deprecated As of version 1.7. See SatelliteViewDemo for an example of how to do this. | |
27 | */ | |
28 | public class BirdsEyeGraphDraw extends JComponent { | |
29 | ||
30 | /** | |
31 | * the GraphDraw to manage | |
32 | */ | |
33 | protected GraphDraw gd; | |
34 | ||
35 | /** | |
36 | * the first SettableRenderer created | |
37 | */ | |
38 | private final Renderer originalRenderer; | |
39 | ||
40 | /** | |
41 | * the renderer that is passed thru to the VisualizationViewer | |
42 | */ | |
43 | Renderer r; | |
44 | ||
45 | /** | |
46 | * the layout in use | |
47 | */ | |
48 | Layout layout; | |
49 | ||
50 | /** | |
51 | * the VisualizationViewer for this GraphDraw. It does not | |
52 | * modify the underlying graph | |
53 | */ | |
54 | BirdsEyeVisualizationViewer vv; | |
55 | ||
56 | /** | |
57 | * Creates a read-only graph drawing environment that draws this graph object. By | |
58 | * default, uses the Spring layout, the Fade renderer and the | |
59 | * AbstractSettable renderer, | |
60 | * | |
61 | * @param g the graph | |
62 | * @param scalex the scale in the horizontal axis | |
63 | * @param scaley the scale in the vertical axis | |
64 | */ | |
65 | 0 | public BirdsEyeGraphDraw(GraphDraw gd, float scalex, float scaley) { |
66 | 0 | this.gd = gd; |
67 | //StringLabeller sl = StringLabeller.getLabeller(g); | |
68 | 0 | layout = gd.getVisualizationViewer().getGraphLayout(); |
69 | 0 | originalRenderer = gd.getVisualizationViewer().getRenderer();//new SettableRenderer(sl); |
70 | 0 | r = originalRenderer; |
71 | 0 | vv = new BirdsEyeVisualizationViewer(gd.getVisualizationViewer(), scalex, scaley); |
72 | 0 | setLayout(new BorderLayout()); |
73 | 0 | add(vv, BorderLayout.CENTER); |
74 | 0 | } |
75 | ||
76 | /** | |
77 | * Returns the visualizationviewer that actually does the graph drawing. | |
78 | * | |
79 | * @return | |
80 | */ | |
81 | public BirdsEyeVisualizationViewer getVisualizationViewer() { | |
82 | 0 | return vv; |
83 | } | |
84 | ||
85 | public void setBackground(Color bg) { | |
86 | 0 | super.setBackground(bg); |
87 | 0 | vv.setBackground(bg); |
88 | 0 | } |
89 | ||
90 | /** | |
91 | * A method to set the renderer. Passes it to the VisualizationViewer | |
92 | * | |
93 | * @param r | |
94 | * the new renderer | |
95 | */ | |
96 | public void setRenderer(Renderer r) { | |
97 | 0 | this.r = r; |
98 | 0 | vv.setRenderer(r); |
99 | 0 | } |
100 | ||
101 | /** | |
102 | * resets to the original renderer. Passes is to the VisualizationViewer | |
103 | * | |
104 | */ | |
105 | public void resetRenderer() { | |
106 | 0 | this.r = originalRenderer; |
107 | 0 | vv.setRenderer(r); |
108 | 0 | } |
109 | ||
110 | /** | |
111 | * getter for the original renderer | |
112 | * @return the original renderer | |
113 | */ | |
114 | public Renderer getRender() { | |
115 | 0 | return originalRenderer; |
116 | } | |
117 | ||
118 | ||
119 | /** | |
120 | * Dynamically chooses a new GraphLayout. | |
121 | * | |
122 | * @param l | |
123 | * the new graph layout algorithm | |
124 | */ | |
125 | public void setGraphLayout(Layout l) { | |
126 | 0 | this.layout = l; |
127 | 0 | vv.setGraphLayout(l); |
128 | 0 | } |
129 | ||
130 | /** | |
131 | * Returns the currently operative layout. | |
132 | */ | |
133 | public Layout getGraphLayout() { | |
134 | 0 | return layout; |
135 | } | |
136 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |