Line | Hits | Source |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2005, 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 | * Created on Jul 21, 2005 | |
9 | */ | |
10 | ||
11 | package edu.uci.ics.jung.visualization.transform; | |
12 | ||
13 | import java.awt.Color; | |
14 | import java.awt.Graphics; | |
15 | import java.awt.Graphics2D; | |
16 | import java.awt.geom.Ellipse2D; | |
17 | ||
18 | import edu.uci.ics.jung.visualization.VisualizationViewer; | |
19 | import edu.uci.ics.jung.visualization.VisualizationViewer.Paintable; | |
20 | import edu.uci.ics.jung.visualization.control.ModalGraphMouse; | |
21 | /** | |
22 | * A class to make it easy to add an | |
23 | * examining lens to a jung graph application. See HyperbolicTransformerDemo, | |
24 | * ViewLensSupport and LayoutLensSupport | |
25 | * for examples of how to use it. | |
26 | * | |
27 | * @author Tom Nelson - RABA Technologies | |
28 | * | |
29 | * | |
30 | */ | |
31 | public abstract class AbstractLensSupport implements LensSupport { | |
32 | ||
33 | protected VisualizationViewer vv; | |
34 | protected VisualizationViewer.GraphMouse graphMouse; | |
35 | protected MutableTransformer savedViewTransformer; | |
36 | protected LensTransformer lensTransformer; | |
37 | protected ModalGraphMouse lensGraphMouse; | |
38 | protected Lens lens; | |
39 | protected LensControls lensControls; | |
40 | protected String defaultToolTipText; | |
41 | ||
42 | protected static final String instructions = | |
43 | "<html><center>Mouse-Drag the Lens center to move it<p>"+ | |
44 | "Mouse-Drag the Lens edge to resize it<p>"+ | |
45 | "Ctrl+MouseWheel to change magnification</center></html>"; | |
46 | ||
47 | /** | |
48 | * create the base class, setting common members and creating | |
49 | * a custom GraphMouse | |
50 | * @param vv the VisualizationViewer to work on | |
51 | */ | |
52 | 0 | public AbstractLensSupport(VisualizationViewer vv, ModalGraphMouse lensGraphMouse) { |
53 | 0 | this.vv = vv; |
54 | 0 | this.savedViewTransformer = vv.getViewTransformer(); |
55 | 0 | this.graphMouse = vv.getGraphMouse(); |
56 | 0 | this.defaultToolTipText = vv.getToolTipText(); |
57 | ||
58 | 0 | this.lensGraphMouse = lensGraphMouse;//new ModalLensGraphMouse(); |
59 | 0 | } |
60 | ||
61 | public void activate(boolean state) { | |
62 | 0 | if(state) activate(); |
63 | 0 | else deactivate(); |
64 | 0 | } |
65 | ||
66 | public LensTransformer getLensTransformer() { | |
67 | 0 | return lensTransformer; |
68 | } | |
69 | ||
70 | /** | |
71 | * @return Returns the hyperbolicGraphMouse. | |
72 | */ | |
73 | public ModalGraphMouse getGraphMouse() { | |
74 | 0 | return lensGraphMouse; |
75 | } | |
76 | ||
77 | /** | |
78 | * the background for the hyperbolic projection | |
79 | * @author Tom Nelson - RABA Technologies | |
80 | * | |
81 | * | |
82 | */ | |
83 | public static class Lens implements Paintable { | |
84 | LensTransformer lensTransformer; | |
85 | Ellipse2D ellipse; | |
86 | ||
87 | public Lens(LensTransformer lensTransformer) { | |
88 | this.lensTransformer = lensTransformer; | |
89 | this.ellipse = lensTransformer.getEllipse(); | |
90 | } | |
91 | ||
92 | /** | |
93 | * @return Returns the hyperbolicTransformer. | |
94 | */ | |
95 | ||
96 | public void paint(Graphics g) { | |
97 | ||
98 | Graphics2D g2d = (Graphics2D)g; | |
99 | g.setColor(Color.decode("0xdddddd")); | |
100 | g2d.fill(ellipse); | |
101 | } | |
102 | ||
103 | public boolean useTransform() { | |
104 | return false; | |
105 | } | |
106 | } | |
107 | ||
108 | /** | |
109 | * the background for the hyperbolic projection | |
110 | * @author Tom Nelson - RABA Technologies | |
111 | * | |
112 | * | |
113 | */ | |
114 | public static class LensControls implements Paintable { | |
115 | LensTransformer lensTransformer; | |
116 | Ellipse2D ellipse; | |
117 | ||
118 | public LensControls(LensTransformer lensTransformer) { | |
119 | this.lensTransformer = lensTransformer; | |
120 | this.ellipse = lensTransformer.getEllipse(); | |
121 | } | |
122 | ||
123 | /** | |
124 | * @return Returns the hyperbolicTransformer. | |
125 | */ | |
126 | ||
127 | public void paint(Graphics g) { | |
128 | ||
129 | Graphics2D g2d = (Graphics2D)g; | |
130 | g.setColor(Color.gray); | |
131 | g2d.draw(ellipse); | |
132 | int centerX = (int)Math.round(ellipse.getCenterX()); | |
133 | int centerY = (int)Math.round(ellipse.getCenterY()); | |
134 | g.drawOval(centerX-10, centerY-10, 20, 20); | |
135 | } | |
136 | ||
137 | public boolean useTransform() { | |
138 | return false; | |
139 | } | |
140 | } | |
141 | ||
142 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |