1 /*****************************************************************************
2 * Copyright (c) 2007, 2008 Intel Corporation, 2010, 2012 Ericsson.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Intel Corporation - Initial API and implementation
10 * Ruslan A. Scherbakov, Intel - Initial API and implementation
11 * Alvaro Sanchez-Leon - Updated for TMF
12 * Patrick Tasse - Refactoring
14 *****************************************************************************/
16 package org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
;
18 import java
.text
.SimpleDateFormat
;
19 import java
.util
.Calendar
;
20 import java
.util
.Date
;
21 import java
.util
.GregorianCalendar
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.Resolution
;
24 import org
.eclipse
.swt
.SWT
;
25 import org
.eclipse
.swt
.events
.MouseEvent
;
26 import org
.eclipse
.swt
.events
.MouseListener
;
27 import org
.eclipse
.swt
.events
.MouseMoveListener
;
28 import org
.eclipse
.swt
.events
.PaintEvent
;
29 import org
.eclipse
.swt
.graphics
.GC
;
30 import org
.eclipse
.swt
.graphics
.Point
;
31 import org
.eclipse
.swt
.graphics
.Rectangle
;
32 import org
.eclipse
.swt
.widgets
.Composite
;
34 public class TimeGraphScale
extends TimeGraphBaseControl
implements MouseListener
,
37 public TimeGraphScale(Composite parent
, TimeGraphColorScheme colors
) {
38 super(parent
, colors
, SWT
.NO_BACKGROUND
| SWT
.NO_FOCUS
39 | SWT
.DOUBLE_BUFFERED
);
40 addMouseListener(this);
41 addMouseMoveListener(this);
44 private static final long SEC_IN_NS
= 1000000000;
45 private static final long MIN_IN_NS
= 60 * SEC_IN_NS
;
46 private static final long HOUR_IN_NS
= 60 * MIN_IN_NS
;
47 private static final long DAY_IN_NS
= 24 * HOUR_IN_NS
;
48 private static final long MONTH_IN_NS
= 31 * DAY_IN_NS
; // upper limit
49 private static final long YEAR_IN_NS
= 366 * DAY_IN_NS
; // upper limit
51 private static final double LOG10_1
= Math
.log10(1);
52 private static final double LOG10_2
= Math
.log10(2);
53 private static final double LOG10_3
= Math
.log10(3);
54 private static final double LOG10_5
= Math
.log10(5);
56 private static final Calendar GREGORIAN_CALENDAR
= GregorianCalendar
.getInstance();
58 private ITimeDataProvider _timeProvider
;
59 private int _dragState
= 0;
60 private int _dragX0
= 0;
61 private int _dragX
= 0;
62 private long _time0bak
;
63 private long _time1bak
;
64 private boolean _isInUpdate
;
65 private Rectangle _rect0
= new Rectangle(0, 0, 0, 0);
68 public void setTimeProvider(ITimeDataProvider timeProvider
) {
69 _timeProvider
= timeProvider
;
72 private long _timeDelta
;
75 public Point
computeSize(int wHint
, int hHint
, boolean changed
) {
76 return super.computeSize(wHint
, _height
, changed
);
79 public void setHeight(int height
) {
80 this._height
= height
;
83 private void calcTimeDelta(int width
, double pixelsPerNanoSec
) {
84 double minDelta
= (double) ((pixelsPerNanoSec
== 0) ? YEAR_IN_NS
: width
/ pixelsPerNanoSec
);
86 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
87 if (minDelta
> 6 * MONTH_IN_NS
) {
89 } else if (minDelta
> 3 * MONTH_IN_NS
) {
90 unit
= 6 * MONTH_IN_NS
;
91 } else if (minDelta
> 10 * DAY_IN_NS
) {
93 } else if (minDelta
> 12 * HOUR_IN_NS
) {
95 } else if (minDelta
> 3 * HOUR_IN_NS
) {
96 unit
= 6 * HOUR_IN_NS
;
97 } else if (minDelta
> 30 * MIN_IN_NS
) {
99 } else if (minDelta
> 10 * MIN_IN_NS
) {
100 unit
= 15 * MIN_IN_NS
;
101 } else if (minDelta
> 30 * SEC_IN_NS
) {
103 } else if (minDelta
> 20 * SEC_IN_NS
) {
104 unit
= 30 * SEC_IN_NS
;
105 } else if (minDelta
<= 1) {
110 double log
= Math
.log10((double) minDelta
/ unit
);
111 long pow10
= (long) log
;
112 double remainder
= log
- pow10
;
113 if (remainder
< LOG10_1
) {
114 _timeDelta
= (long) Math
.pow(10, pow10
) * unit
;
115 } else if (remainder
< LOG10_2
) {
116 _timeDelta
= 2 * (long) Math
.pow(10, pow10
) * unit
;
117 } else if (remainder
< LOG10_3
&& unit
>= HOUR_IN_NS
&& unit
< YEAR_IN_NS
) {
118 _timeDelta
= 3 * (long) Math
.pow(10, pow10
) * unit
;
119 } else if (remainder
< LOG10_5
) {
120 _timeDelta
= 5 * (long) Math
.pow(10, pow10
) * unit
;
122 _timeDelta
= 10 * (long) Math
.pow(10, pow10
) * unit
;
126 private static TimeDraw TIMEDRAW_NANOSEC
= new TimeDrawNanosec();
127 private static TimeDraw TIMEDRAW_MICROSEC
= new TimeDrawMicrosec();
128 private static TimeDraw TIMEDRAW_MILLISEC
= new TimeDrawMillisec();
129 private static TimeDraw TIMEDRAW_SEC
= new TimeDrawSec();
130 private static TimeDraw TIMEDRAW_ABS_NANOSEC
= new TimeDrawAbsNanoSec();
131 private static TimeDraw TIMEDRAW_ABS_MICROSEC
= new TimeDrawAbsMicroSec();
132 private static TimeDraw TIMEDRAW_ABS_MILLISEC
= new TimeDrawAbsMillisec();
133 private static TimeDraw TIMEDRAW_ABS_SEC
= new TimeDrawAbsSec();
134 private static TimeDraw TIMEDRAW_ABS_MIN
= new TimeDrawAbsMin();
135 private static TimeDraw TIMEDRAW_ABS_HRS
= new TimeDrawAbsHrs();
136 private static TimeDraw TIMEDRAW_ABS_DAY
= new TimeDrawAbsDay();
137 private static TimeDraw TIMEDRAW_ABS_MONTH
= new TimeDrawAbsMonth();
138 private static TimeDraw TIMEDRAW_ABS_YEAR
= new TimeDrawAbsYear();
140 TimeDraw
getTimeDraw(long timeDelta
) {
142 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
143 if (timeDelta
>= YEAR_IN_NS
)
144 timeDraw
= TIMEDRAW_ABS_YEAR
;
145 else if (timeDelta
>= MONTH_IN_NS
)
146 timeDraw
= TIMEDRAW_ABS_MONTH
;
147 else if (timeDelta
>= DAY_IN_NS
)
148 timeDraw
= TIMEDRAW_ABS_DAY
;
149 else if (timeDelta
>= HOUR_IN_NS
)
150 timeDraw
= TIMEDRAW_ABS_HRS
;
151 else if (timeDelta
>= MIN_IN_NS
)
152 timeDraw
= TIMEDRAW_ABS_MIN
;
153 else if (timeDelta
>= SEC_IN_NS
)
154 timeDraw
= TIMEDRAW_ABS_SEC
;
155 else if (timeDelta
>= 1000000)
156 timeDraw
= TIMEDRAW_ABS_MILLISEC
;
157 else if (timeDelta
>= 1000)
158 timeDraw
= TIMEDRAW_ABS_MICROSEC
;
160 timeDraw
= TIMEDRAW_ABS_NANOSEC
;
163 if (timeDelta
>= 1000000000)
164 timeDraw
= TIMEDRAW_SEC
;
165 else if (timeDelta
>= 1000000)
166 timeDraw
= TIMEDRAW_MILLISEC
;
167 else if (timeDelta
>= 1000)
168 timeDraw
= TIMEDRAW_MICROSEC
;
170 timeDraw
= TIMEDRAW_NANOSEC
;
175 void paint(Rectangle rect
, PaintEvent e
) {
177 if (_isInUpdate
|| null == _timeProvider
)
181 gc
.fillRectangle(rect
);
183 long time0
= _timeProvider
.getTime0();
184 long time1
= _timeProvider
.getTime1();
185 long selectedTime
= _timeProvider
.getSelectedTime();
186 int leftSpace
= _timeProvider
.getNameSpace();
187 int timeSpace
= _timeProvider
.getTimeSpace();
189 gc
.setBackground(_colors
.getColor(TimeGraphColorScheme
.TOOL_BACKGROUND
));
190 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.TOOL_FOREGROUND
));
191 Utils
.init(_rect0
, rect
);
193 // draw top left area
194 _rect0
.width
= leftSpace
;
197 Rectangle absHeaderRect
= new Rectangle(_rect0
.x
, _rect0
.y
, _rect0
.width
, _rect0
.height
);
201 // prepare and draw right rect of the timescale
202 _rect0
.x
+= leftSpace
;
203 _rect0
.width
= rect
.width
- leftSpace
;
205 // draw bottom border and erase all other area
206 gc
.drawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
207 rect
.y
+ rect
.height
- 1);
209 gc
.fillRectangle(_rect0
);
211 if (time1
<= time0
|| timeSpace
< 2) {
215 int numDigits
= calculateDigits(time0
, time1
);
217 int labelWidth
= gc
.getCharWidth('0') * numDigits
;
218 double pixelsPerNanoSec
= (timeSpace
<= RIGHT_MARGIN
) ?
0 :
219 (double) (timeSpace
- RIGHT_MARGIN
) / (time1
- time0
);
220 calcTimeDelta(labelWidth
, pixelsPerNanoSec
);
222 TimeDraw timeDraw
= getTimeDraw(_timeDelta
);
224 // draw zoom rectangle
225 if (3 == _dragState
&& null != _timeProvider
) {
226 if (_dragX0
< _dragX
) {
227 gc
.drawRectangle(leftSpace
+ _dragX0
, rect
.y
, _dragX
- _dragX0
- 1, rect
.height
- 8);
228 } else if (_dragX0
> _dragX
) {
229 gc
.drawRectangle(leftSpace
+ _dragX
, rect
.y
, _dragX0
- _dragX
- 1, rect
.height
- 8);
233 if (_rect0
.isEmpty())
236 // draw selected time
237 int x
= _rect0
.x
+ (int) ((double)(selectedTime
- time0
) * pixelsPerNanoSec
);
238 if (x
>= _rect0
.x
&& x
< _rect0
.x
+ _rect0
.width
) {
239 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.SELECTED_TIME
));
240 gc
.drawLine(x
, _rect0
.y
+ _rect0
.height
- 6, x
, _rect0
.y
242 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.TOOL_FOREGROUND
));
245 // draw time scale ticks
247 _rect0
.height
= rect
.height
- 4;
248 _rect0
.width
= labelWidth
;
251 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
252 time
= floorToCalendar(time0
, _timeDelta
);
254 time
= (long) (Math
.ceil((double) time0
/ _timeDelta
) * _timeDelta
);
257 // long t = (long) (time * 1000000000);
258 int y
= _rect0
.y
+ _rect0
.height
;
260 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
261 timeDraw
.drawAbsHeader(gc
, time
, absHeaderRect
);
265 x
= rect
.x
+ leftSpace
+ (int) (Math
.floor((time
- time0
) * pixelsPerNanoSec
));
266 gc
.drawLine(x
, y
, x
, y
+ 4);
267 if (x
>= rect
.x
+ leftSpace
+ rect
.width
- _rect0
.width
) {
270 if (x
>= rect
.x
+ leftSpace
) {
272 if (x
+ _rect0
.width
<= rect
.x
+ rect
.width
)
273 timeDraw
.draw(gc
, time
, _rect0
);
275 if (pixelsPerNanoSec
== 0 || time
> Long
.MAX_VALUE
- _timeDelta
|| _timeDelta
== 0) {
279 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
280 if (_timeDelta
>= YEAR_IN_NS
) {
281 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
282 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
283 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
284 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
285 } else if (_timeDelta
>= MONTH_IN_NS
) {
286 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
287 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
288 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
294 private long floorToCalendar(long time
, long timeDelta
) {
295 if (_timeDelta
>= YEAR_IN_NS
) {
296 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
297 int year
= GREGORIAN_CALENDAR
.get(Calendar
.YEAR
);
298 int yearDelta
= (int) (timeDelta
/ YEAR_IN_NS
);
299 year
= (year
/ yearDelta
) * yearDelta
;
300 GREGORIAN_CALENDAR
.set(Calendar
.YEAR
, year
);
301 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
302 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
303 GREGORIAN_CALENDAR
.set(Calendar
.HOUR_OF_DAY
, 0);
304 GREGORIAN_CALENDAR
.set(Calendar
.MINUTE
, 0);
305 GREGORIAN_CALENDAR
.set(Calendar
.SECOND
, 0);
306 GREGORIAN_CALENDAR
.set(Calendar
.MILLISECOND
, 0);
307 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
308 } else if (_timeDelta
>= MONTH_IN_NS
) {
309 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
310 int month
= GREGORIAN_CALENDAR
.get(Calendar
.MONTH
);
311 int monthDelta
= (int) (timeDelta
/ MONTH_IN_NS
);
312 month
= (month
/ monthDelta
) * monthDelta
;
313 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, month
);
314 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
315 GREGORIAN_CALENDAR
.set(Calendar
.HOUR_OF_DAY
, 0);
316 GREGORIAN_CALENDAR
.set(Calendar
.MINUTE
, 0);
317 GREGORIAN_CALENDAR
.set(Calendar
.SECOND
, 0);
318 GREGORIAN_CALENDAR
.set(Calendar
.MILLISECOND
, 0);
319 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
321 time
= (time
/ timeDelta
) * timeDelta
;
326 private int calculateDigits(long time0
, long time1
) {
328 long timeRange
= time1
- time0
;
330 if (_timeProvider
.isCalendarFormat()) {
331 // Calculate the number of digits to represent the minutes provided
335 if (timeRange
< 10000) {
336 // HH:11:222:333:444__
338 } else if (timeRange
< 10000000) {
343 // Calculate the number of digits to represent the minutes provided
344 long min
= (long) ((time1
* 1E-9) / 60); // to sec then to minutes
345 String strMinutes
= String
.valueOf(min
);
347 if (strMinutes
!= null) {
348 numDigits
+= strMinutes
.length();
352 if (timeRange
< 10000) {
355 } else if (timeRange
< 10000000) {
361 // Trace.debug("timeRange: " + timeRange + " numDigits: " + numDigits);
366 public void mouseDown(MouseEvent e
) {
367 if (_dragState
== 0 && null != _timeProvider
) {
371 } else if (3 == e
.button
) {
374 int x
= e
.x
- _timeProvider
.getNameSpace();
377 } else if (x
> getSize().x
- _timeProvider
.getNameSpace()) {
378 x
= getSize().x
- _timeProvider
.getNameSpace();
380 _dragX
= _dragX0
= x
;
381 _time0bak
= _timeProvider
.getTime0();
382 _time1bak
= _timeProvider
.getTime1();
387 public void mouseUp(MouseEvent e
) {
388 if (e
.button
== 1 && _dragState
== 1) {
392 // Notify time provider to check the need for listener notification
393 if (_dragX
!= _dragX0
) {
394 _timeProvider
.setStartFinishTimeNotify(_timeProvider
.getTime0(), _timeProvider
.getTime1());
396 } else if (e
.button
== 3 && _dragState
== 3 && null != _timeProvider
) {
398 if (_dragX0
== _dragX
) {
401 int timeSpace
= _timeProvider
.getTimeSpace();
402 int leftSpace
= _timeProvider
.getNameSpace();
403 int x
= e
.x
- leftSpace
;
406 if (_dragX0
> _dragX
) { // drag right to left
410 long time0
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ timeSpace
));
411 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX
/ timeSpace
));
413 _timeProvider
.setStartFinishTimeNotify(time0
, time1
);
414 _time0bak
= _timeProvider
.getTime0();
415 _time1bak
= _timeProvider
.getTime1();
421 public void mouseMove(MouseEvent e
) {
422 if (_dragX0
< 0 || _dragState
== 0 || _timeProvider
== null) {
425 Point size
= getSize();
426 int leftSpace
= _timeProvider
.getNameSpace();
427 int timeSpace
= _timeProvider
.getTimeSpace();
428 int x
= e
.x
- leftSpace
;
429 if (1 == _dragState
) {
430 if (x
> 0 && size
.x
> leftSpace
&& _dragX
!= x
) {
432 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ _dragX
));
433 _timeProvider
.setStartFinishTime(_time0bak
, time1
);
435 } else if (3 == _dragState
) {
438 } else if (x
> timeSpace
) {
448 public void mouseDoubleClick(MouseEvent e
) {
449 if (null != _timeProvider
) {
450 _timeProvider
.resetStartFinishTime();
451 _time0bak
= _timeProvider
.getTime0();
452 _time1bak
= _timeProvider
.getTime1();
457 abstract class TimeDraw
{
458 static String S
= ":" ; //$NON-NLS-1$
459 static String S0
= ":0" ; //$NON-NLS-1$
460 static String S00
= ":00"; //$NON-NLS-1$
461 protected static final SimpleDateFormat stimeformat
= new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
462 protected static final SimpleDateFormat stimeformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
463 protected static final SimpleDateFormat sminformat
= new SimpleDateFormat("HH:mm"); //$NON-NLS-1$
464 protected static final SimpleDateFormat sminformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
465 protected static final SimpleDateFormat shrsformat
= new SimpleDateFormat("MMM dd HH:mm"); //$NON-NLS-1$
466 protected static final SimpleDateFormat shrsformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
467 protected static final SimpleDateFormat sdayformat
= new SimpleDateFormat("MMM dd"); //$NON-NLS-1$
468 protected static final SimpleDateFormat sdayformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
469 protected static final SimpleDateFormat smonthformat
= new SimpleDateFormat("yyyy MMM"); //$NON-NLS-1$
470 protected static final SimpleDateFormat syearformat
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
472 static String
pad(long n
) {
481 public abstract void draw(GC gc
, long time
, Rectangle rect
);
483 public void drawAbsHeader(GC gc
, long time
, Rectangle absHeaderRect
) {
484 // Override to draw absolute time header
485 // This is for the time information not shown in the draw of each tick
488 public abstract String
hint();
491 class TimeDrawSec
extends TimeDraw
{
492 static String _hint
= "sec"; //$NON-NLS-1$
495 public void draw(GC gc
, long time
, Rectangle rect
) {
497 Utils
.drawText(gc
, time
+ "", rect
, true); //$NON-NLS-1$
501 public String
hint() {
506 class TimeDrawMillisec
extends TimeDraw
{
507 static String _hint
= "s:ms"; //$NON-NLS-1$
510 public void draw(GC gc
, long time
, Rectangle rect
) {
512 long ms
= time
% 1000;
514 Utils
.drawText(gc
, time
+ pad(ms
), rect
, true);
518 public String
hint() {
523 class TimeDrawMicrosec
extends TimeDraw
{
524 static String _hint
= "s:ms:mcs"; //$NON-NLS-1$
527 public void draw(GC gc
, long time
, Rectangle rect
) {
529 long mcs
= time
% 1000;
531 long ms
= time
% 1000;
533 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
), rect
, true);
537 public String
hint() {
542 class TimeDrawNanosec
extends TimeDraw
{
543 static String _hint
= "s:ms:mcs:ns"; //$NON-NLS-1$
546 public void draw(GC gc
, long time
, Rectangle rect
) {
547 long ns
= time
% 1000;
549 long mcs
= time
% 1000;
551 long ms
= time
% 1000;
553 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
) + pad(ns
), rect
, true);
557 public String
hint() {
562 class TimeDrawAbsYear
extends TimeDraw
{
563 static String _hint
= "YYYY"; //$NON-NLS-1$
566 public void draw(GC gc
, long time
, Rectangle rect
) {
567 String stime
= syearformat
.format(new Date((long) (time
/ 1000000)));
568 Utils
.drawText(gc
, stime
, rect
, true);
572 public String
hint() {
577 class TimeDrawAbsMonth
extends TimeDraw
{
578 static String _hint
= "YYYY Mmm"; //$NON-NLS-1$
581 public void draw(GC gc
, long time
, Rectangle rect
) {
582 String stime
= smonthformat
.format(new Date((long) (time
/ 1000000)));
583 Utils
.drawText(gc
, stime
, rect
, true);
587 public String
hint() {
592 class TimeDrawAbsDay
extends TimeDraw
{
593 static String _hint
= "Mmm dd"; //$NON-NLS-1$
596 public void draw(GC gc
, long time
, Rectangle rect
) {
597 String stime
= sdayformat
.format(new Date((long) (time
/ 1000000)));
598 Utils
.drawText(gc
, stime
, rect
, true);
602 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
603 String header
= sdayformatheader
.format(new Date((long) (time
/ 1000000)));
604 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
605 if (headerwidth
<= rect
.width
) {
606 rect
.x
+= (rect
.width
- headerwidth
);
607 Utils
.drawText(gc
, header
, rect
, true);
612 public String
hint() {
617 class TimeDrawAbsHrs
extends TimeDraw
{
618 static String _hint
= "Mmm dd HH:mm"; //$NON-NLS-1$
621 public void draw(GC gc
, long time
, Rectangle rect
) {
622 String stime
= shrsformat
.format(new Date((long) (time
/ 1000000)));
623 Utils
.drawText(gc
, stime
, rect
, true);
627 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
628 String header
= shrsformatheader
.format(new Date((long) (time
/ 1000000)));
629 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
630 if (headerwidth
<= rect
.width
) {
631 rect
.x
+= (rect
.width
- headerwidth
);
632 Utils
.drawText(gc
, header
, rect
, true);
637 public String
hint() {
642 class TimeDrawAbsMin
extends TimeDraw
{
643 static String _hint
= "HH:mm"; //$NON-NLS-1$
646 public void draw(GC gc
, long time
, Rectangle rect
) {
647 String stime
= sminformat
.format(new Date((long) (time
/ 1000000)));
648 Utils
.drawText(gc
, stime
, rect
, true);
652 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
653 String header
= sminformatheader
.format(new Date((long) (time
/ 1000000)));
654 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
655 if (headerwidth
<= rect
.width
) {
656 rect
.x
+= (rect
.width
- headerwidth
);
657 Utils
.drawText(gc
, header
, rect
, true);
663 public String
hint() {
668 class TimeDrawAbsSec
extends TimeDraw
{
669 static String _hint
= "HH:mm:ss"; //$NON-NLS-1$
672 public void draw(GC gc
, long time
, Rectangle rect
) {
673 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
674 Utils
.drawText(gc
, stime
, rect
, true);
678 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
679 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
680 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
681 if (headerwidth
<= rect
.width
) {
682 rect
.x
+= (rect
.width
- headerwidth
);
683 Utils
.drawText(gc
, header
, rect
, true);
688 public String
hint() {
693 class TimeDrawAbsMillisec
extends TimeDraw
{
694 static String _hint
= "HH:ss:ms"; //$NON-NLS-1$
697 public void draw(GC gc
, long time
, Rectangle rect
) {
698 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
699 String ns
= Utils
.formatNs(time
, Resolution
.MILLISEC
);
701 Utils
.drawText(gc
, stime
+ " " + ns
, rect
, true); //$NON-NLS-1$
705 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
706 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
707 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
708 if (headerwidth
<= rect
.width
) {
709 rect
.x
+= (rect
.width
- headerwidth
);
710 Utils
.drawText(gc
, header
, rect
, true);
715 public String
hint() {
720 class TimeDrawAbsMicroSec
extends TimeDraw
{
721 static String _hint
= "HH:ss:ms:mcs"; //$NON-NLS-1$
724 public void draw(GC gc
, long time
, Rectangle rect
) {
725 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
726 String micr
= Utils
.formatNs(time
, Resolution
.MICROSEC
);
727 Utils
.drawText(gc
, stime
+ " " + micr
, rect
, true); //$NON-NLS-1$
731 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
732 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
733 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
734 if (headerwidth
<= rect
.width
) {
735 rect
.x
+= (rect
.width
- headerwidth
);
736 Utils
.drawText(gc
, header
, rect
, true);
741 public String
hint() {
746 class TimeDrawAbsNanoSec
extends TimeDraw
{
747 static String _hint
= "HH:ss:ms:mcs:ns"; //$NON-NLS-1$
750 public void draw(GC gc
, long time
, Rectangle rect
) {
751 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
752 String ns
= Utils
.formatNs(time
, Resolution
.NANOSEC
);
753 Utils
.drawText(gc
, stime
+ " " + ns
, rect
, true); //$NON-NLS-1$
757 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
758 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
759 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
760 if (headerwidth
<= rect
.width
) {
761 rect
.x
+= (rect
.width
- headerwidth
);
762 Utils
.drawText(gc
, header
, rect
, true);
767 public String
hint() {