equal
deleted
inserted
replaced
25 |
25 |
26 tooltip = "" |
26 tooltip = "" |
27 |
27 |
28 override lazy val peer: JScrollPane = new JScrollPane with SuperMixin { |
28 override lazy val peer: JScrollPane = new JScrollPane with SuperMixin { |
29 override def getToolTipText(event: java.awt.event.MouseEvent): String = |
29 override def getToolTipText(event: java.awt.event.MouseEvent): String = |
30 find_node(Transform.pane_to_graph_coordinates(event.getPoint)) match { |
30 find_visible_node(Transform.pane_to_graph_coordinates(event.getPoint)) match { |
31 case Some(node) => |
31 case Some(node) => |
32 visualizer.model.complete_graph.get_node(node) match { |
32 visualizer.model.full_graph.get_node(node) match { |
33 case Nil => null |
33 case Nil => null |
34 case content => visualizer.make_tooltip(panel.peer, event.getX, event.getY, content) |
34 case content => visualizer.make_tooltip(panel.peer, event.getX, event.getY, content) |
35 } |
35 } |
36 case None => null |
36 case None => null |
37 } |
37 } |
43 horizontalScrollBarPolicy = ScrollPane.BarPolicy.Always |
43 horizontalScrollBarPolicy = ScrollPane.BarPolicy.Always |
44 verticalScrollBarPolicy = ScrollPane.BarPolicy.Always |
44 verticalScrollBarPolicy = ScrollPane.BarPolicy.Always |
45 |
45 |
46 peer.getVerticalScrollBar.setUnitIncrement(10) |
46 peer.getVerticalScrollBar.setUnitIncrement(10) |
47 |
47 |
48 def find_node(at: Point2D): Option[Graph_Display.Node] = |
48 def find_visible_node(at: Point2D): Option[Graph_Display.Node] = |
49 { |
49 { |
50 val m = visualizer.metrics() |
50 val m = visualizer.metrics() |
51 visualizer.model.visible_nodes_iterator |
51 visualizer.model.make_visible_graph().keys_iterator |
52 .find(node => visualizer.Drawer.shape(m, node).contains(at)) |
52 .find(node => visualizer.Drawer.shape(m, node).contains(at)) |
53 } |
53 } |
54 |
54 |
55 def refresh() |
55 def refresh() |
56 { |
56 { |
142 at |
142 at |
143 } |
143 } |
144 |
144 |
145 def fit_to_window() |
145 def fit_to_window() |
146 { |
146 { |
147 if (visualizer.model.visible_nodes_iterator.isEmpty) |
147 if (visualizer.model.make_visible_graph().is_empty) |
148 rescale(1.0) |
148 rescale(1.0) |
149 else { |
149 else { |
150 val box = visualizer.Coordinates.bounding_box() |
150 val box = visualizer.Coordinates.bounding_box() |
151 rescale((size.width / box.width) min (size.height / box.height)) |
151 rescale((size.width / box.width) min (size.height / box.height)) |
152 } |
152 } |
179 } |
179 } |
180 |
180 |
181 def dummy(at: Point2D): Option[Dummy] = |
181 def dummy(at: Point2D): Option[Dummy] = |
182 { |
182 { |
183 val m = visualizer.metrics() |
183 val m = visualizer.metrics() |
184 visualizer.model.visible_edges_iterator.map( |
184 visualizer.model.make_visible_graph().edges_iterator.map( |
185 edge => visualizer.Coordinates(edge).zipWithIndex.map((edge, _))).flatten.find( |
185 edge => visualizer.Coordinates(edge).zipWithIndex.map((edge, _))).flatten.find( |
186 { |
186 { |
187 case (_, ((x, y), _)) => |
187 case (_, ((x, y), _)) => |
188 visualizer.Drawer.shape(m, Graph_Display.Node.dummy). |
188 visualizer.Drawer.shape(m, Graph_Display.Node.dummy). |
189 contains(at.getX() - x, at.getY() - y) |
189 contains(at.getX() - x, at.getY() - y) |
195 |
195 |
196 def pressed(at: Point) |
196 def pressed(at: Point) |
197 { |
197 { |
198 val c = Transform.pane_to_graph_coordinates(at) |
198 val c = Transform.pane_to_graph_coordinates(at) |
199 val l = |
199 val l = |
200 find_node(c) match { |
200 find_visible_node(c) match { |
201 case Some(node) => |
201 case Some(node) => |
202 if (visualizer.Selection.contains(node)) visualizer.Selection.get() |
202 if (visualizer.Selection.contains(node)) visualizer.Selection.get() |
203 else List(node) |
203 else List(node) |
204 case None => Nil |
204 case None => Nil |
205 } |
205 } |
219 { |
219 { |
220 val c = Transform.pane_to_graph_coordinates(at) |
220 val c = Transform.pane_to_graph_coordinates(at) |
221 |
221 |
222 def left_click() |
222 def left_click() |
223 { |
223 { |
224 (find_node(c), m) match { |
224 (find_visible_node(c), m) match { |
225 case (Some(node), Key.Modifier.Control) => visualizer.Selection.add(node) |
225 case (Some(node), Key.Modifier.Control) => visualizer.Selection.add(node) |
226 case (None, Key.Modifier.Control) => |
226 case (None, Key.Modifier.Control) => |
227 |
227 |
228 case (Some(node), Key.Modifier.Shift) => visualizer.Selection.add(node) |
228 case (Some(node), Key.Modifier.Shift) => visualizer.Selection.add(node) |
229 case (None, Key.Modifier.Shift) => |
229 case (None, Key.Modifier.Shift) => |
236 } |
236 } |
237 } |
237 } |
238 |
238 |
239 def right_click() |
239 def right_click() |
240 { |
240 { |
241 val menu = Popups(panel, find_node(c), visualizer.Selection.get()) |
241 val menu = Popups(panel, find_visible_node(c), visualizer.Selection.get()) |
242 menu.show(panel.peer, at.x, at.y) |
242 menu.show(panel.peer, at.x, at.y) |
243 } |
243 } |
244 |
244 |
245 if (clicks < 2) { |
245 if (clicks < 2) { |
246 if (SwingUtilities.isRightMouseButton(e.peer)) right_click() |
246 if (SwingUtilities.isRightMouseButton(e.peer)) right_click() |