minor feature: show mouse drag distance (in time) from mouse press
This commit is contained in:
parent
9d7275db7e
commit
1c4b6afea3
1 changed files with 9 additions and 3 deletions
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -878,6 +878,7 @@ public class TimeLine extends VisPlugin {
|
||||||
class Timeline extends JComponent {
|
class Timeline extends JComponent {
|
||||||
private int mousePixelPositionX = -1;
|
private int mousePixelPositionX = -1;
|
||||||
private int mousePixelPositionY = -1;
|
private int mousePixelPositionY = -1;
|
||||||
|
private int mouseDownPixelPositionX = -1;
|
||||||
|
|
||||||
public Timeline() {
|
public Timeline() {
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
|
@ -944,6 +945,7 @@ public class TimeLine extends VisPlugin {
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
if (e.getPoint().getY() < FIRST_MOTE_PIXEL_OFFSET) {
|
if (e.getPoint().getY() < FIRST_MOTE_PIXEL_OFFSET) {
|
||||||
mousePixelPositionX = e.getX();
|
mousePixelPositionX = e.getX();
|
||||||
|
mouseDownPixelPositionX = e.getX();
|
||||||
mousePixelPositionY = e.getY();
|
mousePixelPositionY = e.getY();
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
@ -1090,10 +1092,14 @@ public class TimeLine extends VisPlugin {
|
||||||
|
|
||||||
private void drawMouseTime(Graphics g, long start, long end) {
|
private void drawMouseTime(Graphics g, long start, long end) {
|
||||||
if (mousePixelPositionX >= 0) {
|
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 h = g.getFontMetrics().getHeight();
|
||||||
int w = g.getFontMetrics().stringWidth(str) + 6;
|
int w = g.getFontMetrics().stringWidth(str) + 6;
|
||||||
int y=mousePixelPositionY<getHeight()/2?0:getHeight()-h;
|
int y= mousePixelPositionY<getHeight()/2?0:getHeight()-h;
|
||||||
int delta = mousePixelPositionX + w > end/currentPixelDivisor?w:0; /* Don't write outside visible area */
|
int delta = mousePixelPositionX + w > end/currentPixelDivisor?w:0; /* Don't write outside visible area */
|
||||||
|
|
||||||
/* Line */
|
/* Line */
|
||||||
|
|
Loading…
Add table
Reference in a new issue