From 1c4b6afea329b4abe67007e1af002e1810a92641 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Mon, 19 Oct 2009 17:36:28 +0000 Subject: [PATCH] minor feature: show mouse drag distance (in time) from mouse press --- tools/cooja/java/se/sics/cooja/plugins/TimeLine.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java index 092fe41d4..8944c3c47 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java +++ b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: TimeLine.java,v 1.13 2009/09/17 13:20:48 fros4943 Exp $ + * $Id: TimeLine.java,v 1.14 2009/10/19 17:36:28 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -878,6 +878,7 @@ public class TimeLine extends VisPlugin { class Timeline extends JComponent { private int mousePixelPositionX = -1; private int mousePixelPositionY = -1; + private int mouseDownPixelPositionX = -1; public Timeline() { setLayout(null); @@ -944,6 +945,7 @@ public class TimeLine extends VisPlugin { public void mousePressed(MouseEvent e) { if (e.getPoint().getY() < FIRST_MOTE_PIXEL_OFFSET) { mousePixelPositionX = e.getX(); + mouseDownPixelPositionX = e.getX(); mousePixelPositionY = e.getY(); repaint(); } @@ -1090,10 +1092,14 @@ public class TimeLine extends VisPlugin { private void drawMouseTime(Graphics g, long start, long end) { if (mousePixelPositionX >= 0) { - String str = "Time (ms): " + ((double)mousePixelPositionX*currentPixelDivisor/Simulation.MILLISECOND); + String str = + "Time (ms): " + + ((double)mousePixelPositionX*currentPixelDivisor/Simulation.MILLISECOND) + + " (" + Math.abs(((double)(mouseDownPixelPositionX - mousePixelPositionX)*currentPixelDivisor/Simulation.MILLISECOND)) + ")"; + int h = g.getFontMetrics().getHeight(); int w = g.getFontMetrics().stringWidth(str) + 6; - int y=mousePixelPositionY end/currentPixelDivisor?w:0; /* Don't write outside visible area */ /* Line */