.. | .. |
---|
1 | 1 | package timeflow.views; |
---|
2 | 2 | |
---|
3 | 3 | import timeflow.app.ui.ComponentCluster; |
---|
4 | | -import timeflow.data.db.*; |
---|
| 4 | +import timeflow.app.ui.EditRecordPanel; |
---|
| 5 | +import timeflow.data.db.DBUtils; |
---|
5 | 6 | import timeflow.data.time.*; |
---|
6 | 7 | import timeflow.model.*; |
---|
7 | | -import timeflow.views.CalendarView.CalendarPanel; |
---|
8 | | -import timeflow.views.CalendarView.ScrollingCalendar; |
---|
9 | | -import timeflow.vis.*; |
---|
| 8 | +//import timeflow.views.CalendarView.CalendarPanel; |
---|
| 9 | +//import timeflow.views.CalendarView.ScrollingCalendar; |
---|
| 10 | +import timeflow.vis.Mouseover; |
---|
| 11 | +import timeflow.vis.TimeScale; |
---|
| 12 | +import timeflow.vis.VisualAct; |
---|
10 | 13 | import timeflow.vis.timeline.*; |
---|
11 | 14 | |
---|
12 | 15 | import java.awt.*; |
---|
13 | 16 | import java.awt.event.*; |
---|
14 | | -import java.awt.image.*; |
---|
| 17 | +//import java.awt.image.*; |
---|
15 | 18 | |
---|
16 | 19 | import javax.swing.*; |
---|
17 | 20 | |
---|
18 | | -import java.util.*; |
---|
| 21 | +import java.util.ArrayList; |
---|
19 | 22 | |
---|
20 | 23 | public class TimelineView extends AbstractView |
---|
21 | 24 | { |
---|
.. | .. |
---|
67 | 70 | |
---|
68 | 71 | // top part of grid: zoom buttons. |
---|
69 | 72 | ComponentCluster buttons = new ComponentCluster("Zoom"); |
---|
70 | | - ImageIcon zoomOutIcon = new ImageIcon("images/zoom_out.gif"); |
---|
71 | | - JButton zoomOut = new JButton(zoomOutIcon); |
---|
| 73 | + //ImageIcon zoomOutIcon = new ImageIcon("images/zoom_out.gif"); |
---|
| 74 | + JButton zoomIn = new JButton("In 1/2X"); |
---|
| 75 | + buttons.addContent(zoomIn); |
---|
| 76 | + zoomIn.addActionListener(new ActionListener() |
---|
| 77 | + { |
---|
| 78 | + @Override |
---|
| 79 | + public void actionPerformed(ActionEvent e) |
---|
| 80 | + { |
---|
| 81 | + Interval zoom = visuals.getViewInterval().subinterval(0.333, 0.667).intersection(visuals.getGlobalInterval()); |
---|
| 82 | + moveTime(zoom); |
---|
| 83 | + } |
---|
| 84 | + }); |
---|
| 85 | + |
---|
| 86 | + JButton zoomOut = new JButton("Out 2X"); |
---|
72 | 87 | buttons.addContent(zoomOut); |
---|
73 | 88 | zoomOut.addActionListener(new ActionListener() |
---|
74 | 89 | { |
---|
75 | | - |
---|
76 | 90 | @Override |
---|
77 | 91 | public void actionPerformed(ActionEvent e) |
---|
78 | 92 | { |
---|
.. | .. |
---|
82 | 96 | }); |
---|
83 | 97 | |
---|
84 | 98 | ImageIcon zoomOut100Icon = new ImageIcon("images/zoom_out_100.gif"); |
---|
85 | | - JButton zoomOutAll = new JButton(zoomOut100Icon); |
---|
| 99 | + JButton zoomOutAll = new JButton("Fit 100%"); |
---|
86 | 100 | buttons.addContent(zoomOutAll); |
---|
87 | 101 | zoomOutAll.addActionListener(new ActionListener() |
---|
88 | 102 | { |
---|
.. | .. |
---|
221 | 235 | |
---|
222 | 236 | public void run() |
---|
223 | 237 | { |
---|
224 | | - int n = 15; |
---|
| 238 | + int n = 8; |
---|
225 | 239 | for (int i = 0; i < n; i++) |
---|
226 | 240 | { |
---|
227 | | - long start = ((n - i) * i1.start + i * i2.start) / n; |
---|
228 | | - long end = ((n - i) * i1.end + i * i2.end) / n; |
---|
| 241 | + final long start = ((n - i) * i1.start + i * i2.start) / n; |
---|
| 242 | + final long end = ((n - i) * i1.end + i * i2.end) / n; |
---|
229 | 243 | try |
---|
230 | 244 | { |
---|
231 | | - visuals.setTimeBounds(start, end); |
---|
232 | | - redraw(); |
---|
| 245 | +// visuals.setTimeBounds(start, end); |
---|
| 246 | +// redraw(); |
---|
| 247 | + SwingUtilities.invokeAndWait(new Runnable() |
---|
| 248 | + { |
---|
| 249 | + |
---|
| 250 | + @Override |
---|
| 251 | + public void run() |
---|
| 252 | + { |
---|
| 253 | + visuals.setTimeBounds(start, end); |
---|
| 254 | + redraw(); |
---|
| 255 | + } |
---|
| 256 | + }); |
---|
233 | 257 | |
---|
234 | | - sleep(20); |
---|
| 258 | + //sleep(20); |
---|
235 | 259 | } catch (Exception e) |
---|
236 | 260 | { |
---|
237 | 261 | } |
---|
.. | .. |
---|
312 | 336 | { |
---|
313 | 337 | if (e.getClickCount() == 2) |
---|
314 | 338 | { |
---|
315 | | - moveTime(visuals.getViewInterval().subinterval(.333, .667)); |
---|
| 339 | + Point p = new Point(e.getX(), e.getY()); |
---|
| 340 | + Mouseover o = find(p); |
---|
| 341 | + //moveTime(visuals.getViewInterval().subinterval(.333, .667)); |
---|
| 342 | + boolean onAct = o != null && o.thing instanceof VisualAct; |
---|
| 343 | + if (onAct) |
---|
| 344 | + { |
---|
| 345 | + VisualAct v = (VisualAct) o.thing; |
---|
| 346 | + selectedAct = v.getAct(); |
---|
| 347 | + EditRecordPanel.edit(getModel(), selectedAct); |
---|
| 348 | + } else |
---|
| 349 | + { |
---|
| 350 | + selectedTime = getTime(p); |
---|
| 351 | + EditRecordPanel.add(getModel(), selectedTime); |
---|
| 352 | + } |
---|
316 | 353 | } |
---|
317 | 354 | } |
---|
318 | 355 | |
---|
.. | .. |
---|
358 | 395 | int a = firstMouse.x; |
---|
359 | 396 | int b = mouse.x; |
---|
360 | 397 | |
---|
| 398 | + if (a == b) |
---|
| 399 | + { |
---|
| 400 | + return; |
---|
| 401 | + } |
---|
| 402 | + |
---|
361 | 403 | long start = visuals.getTimeScale().toTime(a); |
---|
362 | 404 | long end = visuals.getTimeScale().toTime(b); |
---|
363 | 405 | if (b - a < 0) |
---|
.. | .. |
---|
397 | 439 | @Override |
---|
398 | 440 | public void mouseWheelMoved(MouseWheelEvent e) |
---|
399 | 441 | { |
---|
400 | | - //bar.setValue(bar.getValue() + e.getWheelRotation() * 10); |
---|
401 | | - visuals.scale *= Math.exp(e.getWheelRotation()/10.0); |
---|
402 | | - visuals.scale = visuals.layout(); |
---|
403 | | - //System.out.println(visuals.scale); |
---|
404 | | - timelinePanel.drawVisualization(); |
---|
405 | | - scroller.calibrate(); |
---|
| 442 | + if (e.isMetaDown()) |
---|
| 443 | + { |
---|
| 444 | + visuals.scale *= Math.exp(e.getWheelRotation()/10.0); |
---|
| 445 | + visuals.scale = visuals.layout(); |
---|
| 446 | + //System.out.println(visuals.scale); |
---|
| 447 | + timelinePanel.drawVisualization(); |
---|
| 448 | + scroller.calibrate(); |
---|
| 449 | + } |
---|
| 450 | + else |
---|
| 451 | + { |
---|
| 452 | + bar.setValue(bar.getValue() + e.getWheelRotation() * 40); |
---|
| 453 | + } |
---|
406 | 454 | repaint(); |
---|
407 | 455 | } |
---|
408 | 456 | }); |
---|