From 611518a0ff65fd05e517d44adbcec639570b86eb Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Thu, 21 Feb 2019 23:44:07 -0500 Subject: [PATCH] Yellow theme. --- timeflow/views/TimelineView.java | 109 ++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 80 insertions(+), 29 deletions(-) diff --git a/timeflow/views/TimelineView.java b/timeflow/views/TimelineView.java index 778ece2..983c2b6 100755 --- a/timeflow/views/TimelineView.java +++ b/timeflow/views/TimelineView.java @@ -1,21 +1,25 @@ package timeflow.views; import timeflow.app.ui.ComponentCluster; -import timeflow.data.db.*; +import timeflow.app.ui.EditRecordPanel; +import timeflow.data.db.DBUtils; import timeflow.data.time.*; import timeflow.model.*; -import timeflow.views.CalendarView.CalendarPanel; -import timeflow.views.CalendarView.ScrollingCalendar; -import timeflow.vis.*; + +//import timeflow.views.CalendarView.CalendarPanel; +//import timeflow.views.CalendarView.ScrollingCalendar; +import timeflow.vis.Mouseover; +import timeflow.vis.TimeScale; +import timeflow.vis.VisualAct; import timeflow.vis.timeline.*; import java.awt.*; import java.awt.event.*; -import java.awt.image.*; +//import java.awt.image.*; import javax.swing.*; -import java.util.*; +import java.util.ArrayList; public class TimelineView extends AbstractView { @@ -34,9 +38,10 @@ return controls; } - public TimelineView(TFModel model) + public TimelineView(TimeflowModel model) { super(model); + visuals = new TimelineVisuals(model); grid = new AxisRenderer(visuals); timeline = new TimelineRenderer(visuals); @@ -52,27 +57,39 @@ TimelineSlider slider = new TimelineSlider(visuals, 24 * 60 * 60 * 1000L, new Runnable() { - @Override public void run() { redraw(); } }); + bottom.add(slider, BorderLayout.CENTER); controls = new JPanel(); - controls.setBackground(Color.white); + controls.setBackground(Color.red); controls.setLayout(new BorderLayout());//new GridLayout(2,1)); // top part of grid: zoom buttons. ComponentCluster buttons = new ComponentCluster("Zoom"); - ImageIcon zoomOutIcon = new ImageIcon("images/zoom_out.gif"); - JButton zoomOut = new JButton(zoomOutIcon); + + //ImageIcon zoomOutIcon = new ImageIcon("images/zoom_out.gif"); + JButton zoomIn = new JButton("In 1/2X"); + buttons.addContent(zoomIn); + zoomIn.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + Interval zoom = visuals.getViewInterval().subinterval(0.333, 0.667).intersection(visuals.getGlobalInterval()); + moveTime(zoom); + } + }); + + JButton zoomOut = new JButton("Out 2X"); buttons.addContent(zoomOut); zoomOut.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent e) { @@ -82,7 +99,7 @@ }); ImageIcon zoomOut100Icon = new ImageIcon("images/zoom_out_100.gif"); - JButton zoomOutAll = new JButton(zoomOut100Icon); + JButton zoomOutAll = new JButton("Fit 100%"); buttons.addContent(zoomOutAll); zoomOutAll.addActionListener(new ActionListener() { @@ -109,7 +126,7 @@ moveTime(visuals.getFitToVisibleRange()); }}); */ - controls.add(buttons, BorderLayout.NORTH); + controls.add(buttons, BorderLayout.SOUTH); // ok, now do second part of grid: layout style buttons. ComponentCluster layoutPanel = new ComponentCluster("Layout"); @@ -137,7 +154,7 @@ graph.addActionListener(new LayoutSetter(TimelineVisuals.Layout.GRAPH)); layoutGroup.add(graph); - controls.add(layoutPanel, BorderLayout.CENTER); + //controls.add(layoutPanel, BorderLayout.CENTER); } class LayoutSetter implements ActionListener @@ -221,17 +238,27 @@ public void run() { - int n = 15; + int n = 8; for (int i = 0; i < n; i++) { - long start = ((n - i) * i1.start + i * i2.start) / n; - long end = ((n - i) * i1.end + i * i2.end) / n; + final long start = ((n - i) * i1.start + i * i2.start) / n; + final long end = ((n - i) * i1.end + i * i2.end) / n; try { - visuals.setTimeBounds(start, end); - redraw(); +// visuals.setTimeBounds(start, end); +// redraw(); + SwingUtilities.invokeAndWait(new Runnable() + { + + @Override + public void run() + { + visuals.setTimeBounds(start, end); + redraw(); + } + }); - sleep(20); + //sleep(20); } catch (Exception e) { } @@ -301,7 +328,7 @@ class TimelinePanel extends AbstractVisualizationView { - public TimelinePanel(TFModel model) + public TimelinePanel(TimeflowModel model) { super(model); @@ -312,7 +339,20 @@ { if (e.getClickCount() == 2) { - moveTime(visuals.getViewInterval().subinterval(.333, .667)); + Point p = new Point(e.getX(), e.getY()); + Mouseover o = find(p); + //moveTime(visuals.getViewInterval().subinterval(.333, .667)); + boolean onAct = o != null && o.thing instanceof VisualAct; + if (onAct) + { + VisualAct v = (VisualAct) o.thing; + selectedAct = v.getAct(); + EditRecordPanel.edit(getModel(), selectedAct); + } else + { + selectedTime = getTime(p); + EditRecordPanel.add(getModel(), selectedTime); + } } } @@ -358,6 +398,11 @@ int a = firstMouse.x; int b = mouse.x; + if (a == b) + { + return; + } + long start = visuals.getTimeScale().toTime(a); long end = visuals.getTimeScale().toTime(b); if (b - a < 0) @@ -397,12 +442,18 @@ @Override public void mouseWheelMoved(MouseWheelEvent e) { - //bar.setValue(bar.getValue() + e.getWheelRotation() * 10); - visuals.scale *= Math.exp(e.getWheelRotation()/10.0); - visuals.scale = visuals.layout(); - //System.out.println(visuals.scale); - timelinePanel.drawVisualization(); - scroller.calibrate(); + if (e.isMetaDown()) + { + visuals.scale *= Math.exp(e.getWheelRotation()/10.0); + visuals.scale = visuals.layout(); + //System.out.println(visuals.scale); + timelinePanel.drawVisualization(); + scroller.calibrate(); + } + else + { + bar.setValue(bar.getValue() + e.getWheelRotation() * 40); + } repaint(); } }); -- Gitblit v1.6.2