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
, MouseMoveListener
{
36 public TimeGraphScale(Composite parent
, TimeGraphColorScheme colors
) {
37 super(parent
, colors
, SWT
.NO_BACKGROUND
| SWT
.NO_FOCUS
| SWT
.DOUBLE_BUFFERED
);
38 addMouseListener(this);
39 addMouseMoveListener(this);
42 private static final long SEC_IN_NS
= 1000000000;
43 private static final long MIN_IN_NS
= 60 * SEC_IN_NS
;
44 private static final long HOUR_IN_NS
= 60 * MIN_IN_NS
;
45 private static final long DAY_IN_NS
= 24 * HOUR_IN_NS
;
46 private static final long MONTH_IN_NS
= 31 * DAY_IN_NS
; // upper limit
47 private static final long YEAR_IN_NS
= 366 * DAY_IN_NS
; // upper limit
49 private static final double LOG10_1
= Math
.log10(1);
50 private static final double LOG10_2
= Math
.log10(2);
51 private static final double LOG10_3
= Math
.log10(3);
52 private static final double LOG10_5
= Math
.log10(5);
54 private static final Calendar GREGORIAN_CALENDAR
= GregorianCalendar
.getInstance();
56 private ITimeDataProvider _timeProvider
;
57 private int _dragState
= 0;
58 private int _dragX0
= 0;
59 private int _dragX
= 0;
60 private long _time0bak
;
61 private long _time1bak
;
62 private boolean _isInUpdate
;
63 private Rectangle _rect0
= new Rectangle(0, 0, 0, 0);
66 public void setTimeProvider(ITimeDataProvider timeProvider
) {
67 _timeProvider
= timeProvider
;
70 private long _timeDelta
;
73 public Point
computeSize(int wHint
, int hHint
, boolean changed
) {
74 return super.computeSize(wHint
, _height
, changed
);
77 public void setHeight(int height
) {
78 this._height
= height
;
81 private void calcTimeDelta(int width
, double pixelsPerNanoSec
) {
82 double minDelta
= (double) ((pixelsPerNanoSec
== 0) ? YEAR_IN_NS
: width
/ pixelsPerNanoSec
);
84 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
85 if (minDelta
> 6 * MONTH_IN_NS
) {
87 } else if (minDelta
> 3 * MONTH_IN_NS
) {
88 unit
= 6 * MONTH_IN_NS
;
89 } else if (minDelta
> 10 * DAY_IN_NS
) {
91 } else if (minDelta
> 12 * HOUR_IN_NS
) {
93 } else if (minDelta
> 3 * HOUR_IN_NS
) {
94 unit
= 6 * HOUR_IN_NS
;
95 } else if (minDelta
> 30 * MIN_IN_NS
) {
97 } else if (minDelta
> 10 * MIN_IN_NS
) {
98 unit
= 15 * MIN_IN_NS
;
99 } else if (minDelta
> 30 * SEC_IN_NS
) {
101 } else if (minDelta
> 20 * SEC_IN_NS
) {
102 unit
= 30 * SEC_IN_NS
;
103 } else if (minDelta
<= 1) {
108 double log
= Math
.log10((double) minDelta
/ unit
);
109 long pow10
= (long) log
;
110 double remainder
= log
- pow10
;
111 if (remainder
< LOG10_1
) {
112 _timeDelta
= (long) Math
.pow(10, pow10
) * unit
;
113 } else if (remainder
< LOG10_2
) {
114 _timeDelta
= 2 * (long) Math
.pow(10, pow10
) * unit
;
115 } else if (remainder
< LOG10_3
&& unit
>= HOUR_IN_NS
&& unit
< YEAR_IN_NS
) {
116 _timeDelta
= 3 * (long) Math
.pow(10, pow10
) * unit
;
117 } else if (remainder
< LOG10_5
) {
118 _timeDelta
= 5 * (long) Math
.pow(10, pow10
) * unit
;
120 _timeDelta
= 10 * (long) Math
.pow(10, pow10
) * unit
;
124 private static TimeDraw TIMEDRAW_NANOSEC
= new TimeDrawNanosec();
125 private static TimeDraw TIMEDRAW_MICROSEC
= new TimeDrawMicrosec();
126 private static TimeDraw TIMEDRAW_MILLISEC
= new TimeDrawMillisec();
127 private static TimeDraw TIMEDRAW_SEC
= new TimeDrawSec();
128 private static TimeDraw TIMEDRAW_ABS_NANOSEC
= new TimeDrawAbsNanoSec();
129 private static TimeDraw TIMEDRAW_ABS_MICROSEC
= new TimeDrawAbsMicroSec();
130 private static TimeDraw TIMEDRAW_ABS_MILLISEC
= new TimeDrawAbsMillisec();
131 private static TimeDraw TIMEDRAW_ABS_SEC
= new TimeDrawAbsSec();
132 private static TimeDraw TIMEDRAW_ABS_MIN
= new TimeDrawAbsMin();
133 private static TimeDraw TIMEDRAW_ABS_HRS
= new TimeDrawAbsHrs();
134 private static TimeDraw TIMEDRAW_ABS_DAY
= new TimeDrawAbsDay();
135 private static TimeDraw TIMEDRAW_ABS_MONTH
= new TimeDrawAbsMonth();
136 private static TimeDraw TIMEDRAW_ABS_YEAR
= new TimeDrawAbsYear();
138 TimeDraw
getTimeDraw(long timeDelta
) {
140 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
141 if (timeDelta
>= YEAR_IN_NS
)
142 timeDraw
= TIMEDRAW_ABS_YEAR
;
143 else if (timeDelta
>= MONTH_IN_NS
)
144 timeDraw
= TIMEDRAW_ABS_MONTH
;
145 else if (timeDelta
>= DAY_IN_NS
)
146 timeDraw
= TIMEDRAW_ABS_DAY
;
147 else if (timeDelta
>= HOUR_IN_NS
)
148 timeDraw
= TIMEDRAW_ABS_HRS
;
149 else if (timeDelta
>= MIN_IN_NS
)
150 timeDraw
= TIMEDRAW_ABS_MIN
;
151 else if (timeDelta
>= SEC_IN_NS
)
152 timeDraw
= TIMEDRAW_ABS_SEC
;
153 else if (timeDelta
>= 1000000)
154 timeDraw
= TIMEDRAW_ABS_MILLISEC
;
155 else if (timeDelta
>= 1000)
156 timeDraw
= TIMEDRAW_ABS_MICROSEC
;
158 timeDraw
= TIMEDRAW_ABS_NANOSEC
;
161 if (timeDelta
>= 1000000000)
162 timeDraw
= TIMEDRAW_SEC
;
163 else if (timeDelta
>= 1000000)
164 timeDraw
= TIMEDRAW_MILLISEC
;
165 else if (timeDelta
>= 1000)
166 timeDraw
= TIMEDRAW_MICROSEC
;
168 timeDraw
= TIMEDRAW_NANOSEC
;
173 void paint(Rectangle rect
, PaintEvent e
) {
175 if (_isInUpdate
|| null == _timeProvider
)
179 gc
.fillRectangle(rect
);
181 long time0
= _timeProvider
.getTime0();
182 long time1
= _timeProvider
.getTime1();
183 long selectedTime
= _timeProvider
.getSelectedTime();
184 int leftSpace
= _timeProvider
.getNameSpace();
185 int timeSpace
= _timeProvider
.getTimeSpace();
187 gc
.setBackground(_colors
.getColor(TimeGraphColorScheme
.TOOL_BACKGROUND
));
188 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.TOOL_FOREGROUND
));
189 Utils
.init(_rect0
, rect
);
191 // draw top left area
192 _rect0
.width
= leftSpace
;
195 Rectangle absHeaderRect
= new Rectangle(_rect0
.x
, _rect0
.y
, _rect0
.width
, _rect0
.height
);
199 // prepare and draw right rect of the timescale
200 _rect0
.x
+= leftSpace
;
201 _rect0
.width
= rect
.width
- leftSpace
;
203 // draw bottom border and erase all other area
204 gc
.drawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
205 rect
.y
+ rect
.height
- 1);
207 gc
.fillRectangle(_rect0
);
209 if (time1
<= time0
|| timeSpace
< 2) {
213 int numDigits
= calculateDigits(time0
, time1
);
215 int labelWidth
= gc
.getCharWidth('0') * numDigits
;
216 double pixelsPerNanoSec
= (timeSpace
<= RIGHT_MARGIN
) ?
0 :
217 (double) (timeSpace
- RIGHT_MARGIN
) / (time1
- time0
);
218 calcTimeDelta(labelWidth
, pixelsPerNanoSec
);
220 TimeDraw timeDraw
= getTimeDraw(_timeDelta
);
222 // draw zoom rectangle
223 if (3 == _dragState
&& null != _timeProvider
) {
224 if (_dragX0
< _dragX
) {
225 gc
.drawRectangle(leftSpace
+ _dragX0
, rect
.y
, _dragX
- _dragX0
- 1, rect
.height
- 8);
226 } else if (_dragX0
> _dragX
) {
227 gc
.drawRectangle(leftSpace
+ _dragX
, rect
.y
, _dragX0
- _dragX
- 1, rect
.height
- 8);
231 if (_rect0
.isEmpty())
234 // draw selected time
235 int x
= _rect0
.x
+ (int) ((double)(selectedTime
- time0
) * pixelsPerNanoSec
);
236 if (x
>= _rect0
.x
&& x
< _rect0
.x
+ _rect0
.width
) {
237 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.SELECTED_TIME
));
238 gc
.drawLine(x
, _rect0
.y
+ _rect0
.height
- 6, x
, _rect0
.y
240 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.TOOL_FOREGROUND
));
243 // draw time scale ticks
245 _rect0
.height
= rect
.height
- 4;
246 _rect0
.width
= labelWidth
;
249 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
250 time
= floorToCalendar(time0
, _timeDelta
);
252 time
= (long) (Math
.ceil((double) time0
/ _timeDelta
) * _timeDelta
);
255 // long t = (long) (time * 1000000000);
256 int y
= _rect0
.y
+ _rect0
.height
;
258 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
259 timeDraw
.drawAbsHeader(gc
, time
, absHeaderRect
);
263 x
= rect
.x
+ leftSpace
+ (int) (Math
.floor((time
- time0
) * pixelsPerNanoSec
));
264 gc
.drawLine(x
, y
, x
, y
+ 4);
265 if (x
>= rect
.x
+ leftSpace
+ rect
.width
- _rect0
.width
) {
268 if (x
>= rect
.x
+ leftSpace
) {
270 if (x
+ _rect0
.width
<= rect
.x
+ rect
.width
)
271 timeDraw
.draw(gc
, time
, _rect0
);
273 if (pixelsPerNanoSec
== 0 || time
> Long
.MAX_VALUE
- _timeDelta
|| _timeDelta
== 0) {
277 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
278 if (_timeDelta
>= YEAR_IN_NS
) {
279 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
280 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
281 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
282 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
283 } else if (_timeDelta
>= MONTH_IN_NS
) {
284 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
285 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
286 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
292 private long floorToCalendar(long time
, long timeDelta
) {
293 if (_timeDelta
>= YEAR_IN_NS
) {
294 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
295 int year
= GREGORIAN_CALENDAR
.get(Calendar
.YEAR
);
296 int yearDelta
= (int) (timeDelta
/ YEAR_IN_NS
);
297 year
= (year
/ yearDelta
) * yearDelta
;
298 GREGORIAN_CALENDAR
.set(Calendar
.YEAR
, year
);
299 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
300 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
301 GREGORIAN_CALENDAR
.set(Calendar
.HOUR_OF_DAY
, 0);
302 GREGORIAN_CALENDAR
.set(Calendar
.MINUTE
, 0);
303 GREGORIAN_CALENDAR
.set(Calendar
.SECOND
, 0);
304 GREGORIAN_CALENDAR
.set(Calendar
.MILLISECOND
, 0);
305 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
306 } else if (_timeDelta
>= MONTH_IN_NS
) {
307 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
308 int month
= GREGORIAN_CALENDAR
.get(Calendar
.MONTH
);
309 int monthDelta
= (int) (timeDelta
/ MONTH_IN_NS
);
310 month
= (month
/ monthDelta
) * monthDelta
;
311 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, month
);
312 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
313 GREGORIAN_CALENDAR
.set(Calendar
.HOUR_OF_DAY
, 0);
314 GREGORIAN_CALENDAR
.set(Calendar
.MINUTE
, 0);
315 GREGORIAN_CALENDAR
.set(Calendar
.SECOND
, 0);
316 GREGORIAN_CALENDAR
.set(Calendar
.MILLISECOND
, 0);
317 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
319 time
= (time
/ timeDelta
) * timeDelta
;
324 private int calculateDigits(long time0
, long time1
) {
326 long timeRange
= time1
- time0
;
328 if (_timeProvider
.isCalendarFormat()) {
329 // Calculate the number of digits to represent the minutes provided
333 if (timeRange
< 10000) {
334 // HH:11:222:333:444__
336 } else if (timeRange
< 10000000) {
341 // Calculate the number of digits to represent the minutes provided
342 long min
= (long) ((time1
* 1E-9) / 60); // to sec then to minutes
343 String strMinutes
= String
.valueOf(min
);
345 if (strMinutes
!= null) {
346 numDigits
+= strMinutes
.length();
350 if (timeRange
< 10000) {
353 } else if (timeRange
< 10000000) {
363 public void mouseDown(MouseEvent e
) {
364 getParent().setFocus();
365 if (_dragState
== 0 && null != _timeProvider
) {
366 int x
= e
.x
- _timeProvider
.getNameSpace();
367 if (1 == e
.button
&& x
> 0) {
370 } else if (3 == e
.button
) {
375 } else if (x
> getSize().x
- _timeProvider
.getNameSpace()) {
376 x
= getSize().x
- _timeProvider
.getNameSpace();
378 _dragX
= _dragX0
= x
;
379 _time0bak
= _timeProvider
.getTime0();
380 _time1bak
= _timeProvider
.getTime1();
385 public void mouseUp(MouseEvent e
) {
386 if (e
.button
== 1 && _dragState
== 1) {
390 // Notify time provider to check the need for listener notification
391 if (_dragX
!= _dragX0
&& _timeProvider
.getTime0() != _timeProvider
.getTime1()) {
392 _timeProvider
.setStartFinishTimeNotify(_timeProvider
.getTime0(), _timeProvider
.getTime1());
394 } else if (e
.button
== 3 && _dragState
== 3 && null != _timeProvider
) {
396 if (_dragX0
== _dragX
|| _timeProvider
.getTime0() == _timeProvider
.getTime1()) {
399 int timeSpace
= _timeProvider
.getTimeSpace();
400 int leftSpace
= _timeProvider
.getNameSpace();
401 int x
= Math
.max(0, e
.x
- leftSpace
);
404 if (_dragX0
> _dragX
) { // drag right to left
408 long time0
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ timeSpace
));
409 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX
/ timeSpace
));
411 _timeProvider
.setStartFinishTimeNotify(time0
, time1
);
412 _time0bak
= _timeProvider
.getTime0();
413 _time1bak
= _timeProvider
.getTime1();
419 public void mouseMove(MouseEvent e
) {
420 if (_dragX0
< 0 || _dragState
== 0 || _timeProvider
== null) {
423 Point size
= getSize();
424 int leftSpace
= _timeProvider
.getNameSpace();
425 int timeSpace
= _timeProvider
.getTimeSpace();
426 int x
= e
.x
- leftSpace
;
427 if (1 == _dragState
) {
428 if (x
> 0 && size
.x
> leftSpace
&& _dragX
!= x
) {
430 if (_timeProvider
.getTime0() == _timeProvider
.getTime1()) {
433 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ _dragX
));
434 _timeProvider
.setStartFinishTime(_time0bak
, time1
);
436 } else if (3 == _dragState
) {
439 } else if (x
> timeSpace
) {
449 public void mouseDoubleClick(MouseEvent e
) {
450 if (null != _timeProvider
&& _timeProvider
.getTime0() != _timeProvider
.getTime1()) {
451 _timeProvider
.resetStartFinishTime();
452 _time0bak
= _timeProvider
.getTime0();
453 _time1bak
= _timeProvider
.getTime1();
458 abstract class TimeDraw
{
459 static String S
= ":" ; //$NON-NLS-1$
460 static String S0
= ":0" ; //$NON-NLS-1$
461 static String S00
= ":00"; //$NON-NLS-1$
462 protected static final SimpleDateFormat stimeformat
= new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
463 protected static final SimpleDateFormat stimeformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
464 protected static final SimpleDateFormat sminformat
= new SimpleDateFormat("HH:mm"); //$NON-NLS-1$
465 protected static final SimpleDateFormat sminformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
466 protected static final SimpleDateFormat shrsformat
= new SimpleDateFormat("MMM dd HH:mm"); //$NON-NLS-1$
467 protected static final SimpleDateFormat shrsformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
468 protected static final SimpleDateFormat sdayformat
= new SimpleDateFormat("MMM dd"); //$NON-NLS-1$
469 protected static final SimpleDateFormat sdayformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
470 protected static final SimpleDateFormat smonthformat
= new SimpleDateFormat("yyyy MMM"); //$NON-NLS-1$
471 protected static final SimpleDateFormat syearformat
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
473 static String
pad(long n
) {
482 public abstract void draw(GC gc
, long time
, Rectangle rect
);
484 public void drawAbsHeader(GC gc
, long time
, Rectangle absHeaderRect
) {
485 // Override to draw absolute time header
486 // This is for the time information not shown in the draw of each tick
489 public abstract String
hint();
492 class TimeDrawSec
extends TimeDraw
{
493 static String _hint
= "sec"; //$NON-NLS-1$
496 public void draw(GC gc
, long time
, Rectangle rect
) {
498 Utils
.drawText(gc
, time
+ "", rect
, true); //$NON-NLS-1$
502 public String
hint() {
507 class TimeDrawMillisec
extends TimeDraw
{
508 static String _hint
= "s:ms"; //$NON-NLS-1$
511 public void draw(GC gc
, long time
, Rectangle rect
) {
513 long ms
= time
% 1000;
515 Utils
.drawText(gc
, time
+ pad(ms
), rect
, true);
519 public String
hint() {
524 class TimeDrawMicrosec
extends TimeDraw
{
525 static String _hint
= "s:ms:mcs"; //$NON-NLS-1$
528 public void draw(GC gc
, long time
, Rectangle rect
) {
530 long mcs
= time
% 1000;
532 long ms
= time
% 1000;
534 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
), rect
, true);
538 public String
hint() {
543 class TimeDrawNanosec
extends TimeDraw
{
544 static String _hint
= "s:ms:mcs:ns"; //$NON-NLS-1$
547 public void draw(GC gc
, long time
, Rectangle rect
) {
548 long ns
= time
% 1000;
550 long mcs
= time
% 1000;
552 long ms
= time
% 1000;
554 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
) + pad(ns
), rect
, true);
558 public String
hint() {
563 class TimeDrawAbsYear
extends TimeDraw
{
564 static String _hint
= "YYYY"; //$NON-NLS-1$
567 public void draw(GC gc
, long time
, Rectangle rect
) {
568 String stime
= syearformat
.format(new Date((long) (time
/ 1000000)));
569 Utils
.drawText(gc
, stime
, rect
, true);
573 public String
hint() {
578 class TimeDrawAbsMonth
extends TimeDraw
{
579 static String _hint
= "YYYY Mmm"; //$NON-NLS-1$
582 public void draw(GC gc
, long time
, Rectangle rect
) {
583 String stime
= smonthformat
.format(new Date((long) (time
/ 1000000)));
584 Utils
.drawText(gc
, stime
, rect
, true);
588 public String
hint() {
593 class TimeDrawAbsDay
extends TimeDraw
{
594 static String _hint
= "Mmm dd"; //$NON-NLS-1$
597 public void draw(GC gc
, long time
, Rectangle rect
) {
598 String stime
= sdayformat
.format(new Date((long) (time
/ 1000000)));
599 Utils
.drawText(gc
, stime
, rect
, true);
603 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
604 String header
= sdayformatheader
.format(new Date((long) (time
/ 1000000)));
605 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
606 if (headerwidth
<= rect
.width
) {
607 rect
.x
+= (rect
.width
- headerwidth
);
608 Utils
.drawText(gc
, header
, rect
, true);
613 public String
hint() {
618 class TimeDrawAbsHrs
extends TimeDraw
{
619 static String _hint
= "Mmm dd HH:mm"; //$NON-NLS-1$
622 public void draw(GC gc
, long time
, Rectangle rect
) {
623 String stime
= shrsformat
.format(new Date((long) (time
/ 1000000)));
624 Utils
.drawText(gc
, stime
, rect
, true);
628 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
629 String header
= shrsformatheader
.format(new Date((long) (time
/ 1000000)));
630 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
631 if (headerwidth
<= rect
.width
) {
632 rect
.x
+= (rect
.width
- headerwidth
);
633 Utils
.drawText(gc
, header
, rect
, true);
638 public String
hint() {
643 class TimeDrawAbsMin
extends TimeDraw
{
644 static String _hint
= "HH:mm"; //$NON-NLS-1$
647 public void draw(GC gc
, long time
, Rectangle rect
) {
648 String stime
= sminformat
.format(new Date((long) (time
/ 1000000)));
649 Utils
.drawText(gc
, stime
, rect
, true);
653 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
654 String header
= sminformatheader
.format(new Date((long) (time
/ 1000000)));
655 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
656 if (headerwidth
<= rect
.width
) {
657 rect
.x
+= (rect
.width
- headerwidth
);
658 Utils
.drawText(gc
, header
, rect
, true);
664 public String
hint() {
669 class TimeDrawAbsSec
extends TimeDraw
{
670 static String _hint
= "HH:mm:ss"; //$NON-NLS-1$
673 public void draw(GC gc
, long time
, Rectangle rect
) {
674 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
675 Utils
.drawText(gc
, stime
, rect
, true);
679 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
680 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
681 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
682 if (headerwidth
<= rect
.width
) {
683 rect
.x
+= (rect
.width
- headerwidth
);
684 Utils
.drawText(gc
, header
, rect
, true);
689 public String
hint() {
694 class TimeDrawAbsMillisec
extends TimeDraw
{
695 static String _hint
= "HH:ss:ms"; //$NON-NLS-1$
698 public void draw(GC gc
, long time
, Rectangle rect
) {
699 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
700 String ns
= Utils
.formatNs(time
, Resolution
.MILLISEC
);
702 Utils
.drawText(gc
, stime
+ "." + ns
, rect
, true); //$NON-NLS-1$
706 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
707 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
708 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
709 if (headerwidth
<= rect
.width
) {
710 rect
.x
+= (rect
.width
- headerwidth
);
711 Utils
.drawText(gc
, header
, rect
, true);
716 public String
hint() {
721 class TimeDrawAbsMicroSec
extends TimeDraw
{
722 static String _hint
= "HH:ss:ms:mcs"; //$NON-NLS-1$
725 public void draw(GC gc
, long time
, Rectangle rect
) {
726 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
727 String micr
= Utils
.formatNs(time
, Resolution
.MICROSEC
);
728 Utils
.drawText(gc
, stime
+ "." + micr
, rect
, true); //$NON-NLS-1$
732 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
733 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
734 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
735 if (headerwidth
<= rect
.width
) {
736 rect
.x
+= (rect
.width
- headerwidth
);
737 Utils
.drawText(gc
, header
, rect
, true);
742 public String
hint() {
747 class TimeDrawAbsNanoSec
extends TimeDraw
{
748 static String _hint
= "HH:ss:ms:mcs:ns"; //$NON-NLS-1$
751 public void draw(GC gc
, long time
, Rectangle rect
) {
752 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
753 String ns
= Utils
.formatNs(time
, Resolution
.NANOSEC
);
754 Utils
.drawText(gc
, stime
+ "." + ns
, rect
, true); //$NON-NLS-1$
758 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
759 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
760 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
761 if (headerwidth
<= rect
.width
) {
762 rect
.x
+= (rect
.width
- headerwidth
);
763 Utils
.drawText(gc
, header
, rect
, true);
768 public String
hint() {