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
38 | SWT
.DOUBLE_BUFFERED
);
39 addMouseListener(this);
40 addMouseMoveListener(this);
43 private static final long SEC_IN_NS
= 1000000000;
44 private static final long MIN_IN_NS
= 60 * SEC_IN_NS
;
45 private static final long HOUR_IN_NS
= 60 * MIN_IN_NS
;
46 private static final long DAY_IN_NS
= 24 * HOUR_IN_NS
;
47 private static final long MONTH_IN_NS
= 31 * DAY_IN_NS
; // upper limit
48 private static final long YEAR_IN_NS
= 366 * DAY_IN_NS
; // upper limit
50 private static final double LOG10_1
= Math
.log10(1);
51 private static final double LOG10_2
= Math
.log10(2);
52 private static final double LOG10_3
= Math
.log10(3);
53 private static final double LOG10_5
= Math
.log10(5);
55 private static final Calendar GREGORIAN_CALENDAR
= GregorianCalendar
.getInstance();
57 private ITimeDataProvider _timeProvider
;
58 private int _dragState
= 0;
59 private int _dragX0
= 0;
60 private int _dragX
= 0;
61 private long _time0bak
;
62 private long _time1bak
;
63 private boolean _isInUpdate
;
64 private Rectangle _rect0
= new Rectangle(0, 0, 0, 0);
67 public void setTimeProvider(ITimeDataProvider timeProvider
) {
68 _timeProvider
= timeProvider
;
71 private long _timeDelta
;
74 public Point
computeSize(int wHint
, int hHint
, boolean changed
) {
75 return super.computeSize(wHint
, _height
, changed
);
78 public void setHeight(int height
) {
79 this._height
= height
;
82 private void calcTimeDelta(int width
, double pixelsPerNanoSec
) {
83 double minDelta
= (double) ((pixelsPerNanoSec
== 0) ? YEAR_IN_NS
: width
/ pixelsPerNanoSec
);
85 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
86 if (minDelta
> 6 * MONTH_IN_NS
) {
88 } else if (minDelta
> 3 * MONTH_IN_NS
) {
89 unit
= 6 * MONTH_IN_NS
;
90 } else if (minDelta
> 10 * DAY_IN_NS
) {
92 } else if (minDelta
> 12 * HOUR_IN_NS
) {
94 } else if (minDelta
> 3 * HOUR_IN_NS
) {
95 unit
= 6 * HOUR_IN_NS
;
96 } else if (minDelta
> 30 * MIN_IN_NS
) {
98 } else if (minDelta
> 10 * MIN_IN_NS
) {
99 unit
= 15 * MIN_IN_NS
;
100 } else if (minDelta
> 30 * SEC_IN_NS
) {
102 } else if (minDelta
> 20 * SEC_IN_NS
) {
103 unit
= 30 * SEC_IN_NS
;
104 } else if (minDelta
<= 1) {
109 double log
= Math
.log10((double) minDelta
/ unit
);
110 long pow10
= (long) log
;
111 double remainder
= log
- pow10
;
112 if (remainder
< LOG10_1
) {
113 _timeDelta
= (long) Math
.pow(10, pow10
) * unit
;
114 } else if (remainder
< LOG10_2
) {
115 _timeDelta
= 2 * (long) Math
.pow(10, pow10
) * unit
;
116 } else if (remainder
< LOG10_3
&& unit
>= HOUR_IN_NS
&& unit
< YEAR_IN_NS
) {
117 _timeDelta
= 3 * (long) Math
.pow(10, pow10
) * unit
;
118 } else if (remainder
< LOG10_5
) {
119 _timeDelta
= 5 * (long) Math
.pow(10, pow10
) * unit
;
121 _timeDelta
= 10 * (long) Math
.pow(10, pow10
) * unit
;
125 private static TimeDraw TIMEDRAW_NANOSEC
= new TimeDrawNanosec();
126 private static TimeDraw TIMEDRAW_MICROSEC
= new TimeDrawMicrosec();
127 private static TimeDraw TIMEDRAW_MILLISEC
= new TimeDrawMillisec();
128 private static TimeDraw TIMEDRAW_SEC
= new TimeDrawSec();
129 private static TimeDraw TIMEDRAW_ABS_NANOSEC
= new TimeDrawAbsNanoSec();
130 private static TimeDraw TIMEDRAW_ABS_MICROSEC
= new TimeDrawAbsMicroSec();
131 private static TimeDraw TIMEDRAW_ABS_MILLISEC
= new TimeDrawAbsMillisec();
132 private static TimeDraw TIMEDRAW_ABS_SEC
= new TimeDrawAbsSec();
133 private static TimeDraw TIMEDRAW_ABS_MIN
= new TimeDrawAbsMin();
134 private static TimeDraw TIMEDRAW_ABS_HRS
= new TimeDrawAbsHrs();
135 private static TimeDraw TIMEDRAW_ABS_DAY
= new TimeDrawAbsDay();
136 private static TimeDraw TIMEDRAW_ABS_MONTH
= new TimeDrawAbsMonth();
137 private static TimeDraw TIMEDRAW_ABS_YEAR
= new TimeDrawAbsYear();
139 TimeDraw
getTimeDraw(long timeDelta
) {
141 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
142 if (timeDelta
>= YEAR_IN_NS
)
143 timeDraw
= TIMEDRAW_ABS_YEAR
;
144 else if (timeDelta
>= MONTH_IN_NS
)
145 timeDraw
= TIMEDRAW_ABS_MONTH
;
146 else if (timeDelta
>= DAY_IN_NS
)
147 timeDraw
= TIMEDRAW_ABS_DAY
;
148 else if (timeDelta
>= HOUR_IN_NS
)
149 timeDraw
= TIMEDRAW_ABS_HRS
;
150 else if (timeDelta
>= MIN_IN_NS
)
151 timeDraw
= TIMEDRAW_ABS_MIN
;
152 else if (timeDelta
>= SEC_IN_NS
)
153 timeDraw
= TIMEDRAW_ABS_SEC
;
154 else if (timeDelta
>= 1000000)
155 timeDraw
= TIMEDRAW_ABS_MILLISEC
;
156 else if (timeDelta
>= 1000)
157 timeDraw
= TIMEDRAW_ABS_MICROSEC
;
159 timeDraw
= TIMEDRAW_ABS_NANOSEC
;
162 if (timeDelta
>= 1000000000)
163 timeDraw
= TIMEDRAW_SEC
;
164 else if (timeDelta
>= 1000000)
165 timeDraw
= TIMEDRAW_MILLISEC
;
166 else if (timeDelta
>= 1000)
167 timeDraw
= TIMEDRAW_MICROSEC
;
169 timeDraw
= TIMEDRAW_NANOSEC
;
174 void paint(Rectangle rect
, PaintEvent e
) {
176 if (_isInUpdate
|| null == _timeProvider
)
180 gc
.fillRectangle(rect
);
182 long time0
= _timeProvider
.getTime0();
183 long time1
= _timeProvider
.getTime1();
184 long selectedTime
= _timeProvider
.getSelectedTime();
185 int leftSpace
= _timeProvider
.getNameSpace();
186 int timeSpace
= _timeProvider
.getTimeSpace();
188 gc
.setBackground(_colors
.getColor(TimeGraphColorScheme
.TOOL_BACKGROUND
));
189 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.TOOL_FOREGROUND
));
190 Utils
.init(_rect0
, rect
);
192 // draw top left area
193 _rect0
.width
= leftSpace
;
196 Rectangle absHeaderRect
= new Rectangle(_rect0
.x
, _rect0
.y
, _rect0
.width
, _rect0
.height
);
200 // prepare and draw right rect of the timescale
201 _rect0
.x
+= leftSpace
;
202 _rect0
.width
= rect
.width
- leftSpace
;
204 // draw bottom border and erase all other area
205 gc
.drawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
206 rect
.y
+ rect
.height
- 1);
208 gc
.fillRectangle(_rect0
);
210 if (time1
<= time0
|| timeSpace
< 2) {
214 int numDigits
= calculateDigits(time0
, time1
);
216 int labelWidth
= gc
.getCharWidth('0') * numDigits
;
217 double pixelsPerNanoSec
= (timeSpace
<= RIGHT_MARGIN
) ?
0 :
218 (double) (timeSpace
- RIGHT_MARGIN
) / (time1
- time0
);
219 calcTimeDelta(labelWidth
, pixelsPerNanoSec
);
221 TimeDraw timeDraw
= getTimeDraw(_timeDelta
);
223 // draw zoom rectangle
224 if (3 == _dragState
&& null != _timeProvider
) {
225 if (_dragX0
< _dragX
) {
226 gc
.drawRectangle(leftSpace
+ _dragX0
, rect
.y
, _dragX
- _dragX0
- 1, rect
.height
- 8);
227 } else if (_dragX0
> _dragX
) {
228 gc
.drawRectangle(leftSpace
+ _dragX
, rect
.y
, _dragX0
- _dragX
- 1, rect
.height
- 8);
232 if (_rect0
.isEmpty())
235 // draw selected time
236 int x
= _rect0
.x
+ (int) ((double)(selectedTime
- time0
) * pixelsPerNanoSec
);
237 if (x
>= _rect0
.x
&& x
< _rect0
.x
+ _rect0
.width
) {
238 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.SELECTED_TIME
));
239 gc
.drawLine(x
, _rect0
.y
+ _rect0
.height
- 6, x
, _rect0
.y
241 gc
.setForeground(_colors
.getColor(TimeGraphColorScheme
.TOOL_FOREGROUND
));
244 // draw time scale ticks
246 _rect0
.height
= rect
.height
- 4;
247 _rect0
.width
= labelWidth
;
250 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
251 time
= floorToCalendar(time0
, _timeDelta
);
253 time
= (long) (Math
.ceil((double) time0
/ _timeDelta
) * _timeDelta
);
256 // long t = (long) (time * 1000000000);
257 int y
= _rect0
.y
+ _rect0
.height
;
259 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
260 timeDraw
.drawAbsHeader(gc
, time
, absHeaderRect
);
264 x
= rect
.x
+ leftSpace
+ (int) (Math
.floor((time
- time0
) * pixelsPerNanoSec
));
265 gc
.drawLine(x
, y
, x
, y
+ 4);
266 if (x
>= rect
.x
+ leftSpace
+ rect
.width
- _rect0
.width
) {
269 if (x
>= rect
.x
+ leftSpace
) {
271 if (x
+ _rect0
.width
<= rect
.x
+ rect
.width
)
272 timeDraw
.draw(gc
, time
, _rect0
);
274 if (pixelsPerNanoSec
== 0 || time
> Long
.MAX_VALUE
- _timeDelta
|| _timeDelta
== 0) {
278 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
279 if (_timeDelta
>= YEAR_IN_NS
) {
280 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
281 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
282 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
283 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
284 } else if (_timeDelta
>= MONTH_IN_NS
) {
285 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
286 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
287 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
293 private long floorToCalendar(long time
, long timeDelta
) {
294 if (_timeDelta
>= YEAR_IN_NS
) {
295 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
296 int year
= GREGORIAN_CALENDAR
.get(Calendar
.YEAR
);
297 int yearDelta
= (int) (timeDelta
/ YEAR_IN_NS
);
298 year
= (year
/ yearDelta
) * yearDelta
;
299 GREGORIAN_CALENDAR
.set(Calendar
.YEAR
, year
);
300 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
301 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
302 GREGORIAN_CALENDAR
.set(Calendar
.HOUR_OF_DAY
, 0);
303 GREGORIAN_CALENDAR
.set(Calendar
.MINUTE
, 0);
304 GREGORIAN_CALENDAR
.set(Calendar
.SECOND
, 0);
305 GREGORIAN_CALENDAR
.set(Calendar
.MILLISECOND
, 0);
306 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
307 } else if (_timeDelta
>= MONTH_IN_NS
) {
308 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
309 int month
= GREGORIAN_CALENDAR
.get(Calendar
.MONTH
);
310 int monthDelta
= (int) (timeDelta
/ MONTH_IN_NS
);
311 month
= (month
/ monthDelta
) * monthDelta
;
312 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, month
);
313 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
314 GREGORIAN_CALENDAR
.set(Calendar
.HOUR_OF_DAY
, 0);
315 GREGORIAN_CALENDAR
.set(Calendar
.MINUTE
, 0);
316 GREGORIAN_CALENDAR
.set(Calendar
.SECOND
, 0);
317 GREGORIAN_CALENDAR
.set(Calendar
.MILLISECOND
, 0);
318 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
320 time
= (time
/ timeDelta
) * timeDelta
;
325 private int calculateDigits(long time0
, long time1
) {
327 long timeRange
= time1
- time0
;
329 if (_timeProvider
.isCalendarFormat()) {
330 // Calculate the number of digits to represent the minutes provided
334 if (timeRange
< 10000) {
335 // HH:11:222:333:444__
337 } else if (timeRange
< 10000000) {
342 // Calculate the number of digits to represent the minutes provided
343 long min
= (long) ((time1
* 1E-9) / 60); // to sec then to minutes
344 String strMinutes
= String
.valueOf(min
);
346 if (strMinutes
!= null) {
347 numDigits
+= strMinutes
.length();
351 if (timeRange
< 10000) {
354 } else if (timeRange
< 10000000) {
364 public void mouseDown(MouseEvent e
) {
365 getParent().setFocus();
366 if (_dragState
== 0 && null != _timeProvider
) {
367 int x
= e
.x
- _timeProvider
.getNameSpace();
368 if (1 == e
.button
&& x
> 0) {
371 } else if (3 == e
.button
) {
376 } else if (x
> getSize().x
- _timeProvider
.getNameSpace()) {
377 x
= getSize().x
- _timeProvider
.getNameSpace();
379 _dragX
= _dragX0
= x
;
380 _time0bak
= _timeProvider
.getTime0();
381 _time1bak
= _timeProvider
.getTime1();
386 public void mouseUp(MouseEvent e
) {
387 if (e
.button
== 1 && _dragState
== 1) {
391 // Notify time provider to check the need for listener notification
392 if (_dragX
!= _dragX0
&& _timeProvider
.getTime0() != _timeProvider
.getTime1()) {
393 _timeProvider
.setStartFinishTimeNotify(_timeProvider
.getTime0(), _timeProvider
.getTime1());
395 } else if (e
.button
== 3 && _dragState
== 3 && null != _timeProvider
) {
397 if (_dragX0
== _dragX
|| _timeProvider
.getTime0() == _timeProvider
.getTime1()) {
400 int timeSpace
= _timeProvider
.getTimeSpace();
401 int leftSpace
= _timeProvider
.getNameSpace();
402 int x
= e
.x
- leftSpace
;
405 if (_dragX0
> _dragX
) { // drag right to left
409 long time0
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ timeSpace
));
410 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX
/ timeSpace
));
412 _timeProvider
.setStartFinishTimeNotify(time0
, time1
);
413 _time0bak
= _timeProvider
.getTime0();
414 _time1bak
= _timeProvider
.getTime1();
420 public void mouseMove(MouseEvent e
) {
421 if (_dragX0
< 0 || _dragState
== 0 || _timeProvider
== null) {
424 Point size
= getSize();
425 int leftSpace
= _timeProvider
.getNameSpace();
426 int timeSpace
= _timeProvider
.getTimeSpace();
427 int x
= e
.x
- leftSpace
;
428 if (1 == _dragState
) {
429 if (x
> 0 && size
.x
> leftSpace
&& _dragX
!= x
) {
431 if (_timeProvider
.getTime0() == _timeProvider
.getTime1()) {
434 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ _dragX
));
435 _timeProvider
.setStartFinishTime(_time0bak
, time1
);
437 } else if (3 == _dragState
) {
440 } else if (x
> timeSpace
) {
450 public void mouseDoubleClick(MouseEvent e
) {
451 if (null != _timeProvider
&& _timeProvider
.getTime0() != _timeProvider
.getTime1()) {
452 _timeProvider
.resetStartFinishTime();
453 _time0bak
= _timeProvider
.getTime0();
454 _time1bak
= _timeProvider
.getTime1();
459 abstract class TimeDraw
{
460 static String S
= ":" ; //$NON-NLS-1$
461 static String S0
= ":0" ; //$NON-NLS-1$
462 static String S00
= ":00"; //$NON-NLS-1$
463 protected static final SimpleDateFormat stimeformat
= new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
464 protected static final SimpleDateFormat stimeformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
465 protected static final SimpleDateFormat sminformat
= new SimpleDateFormat("HH:mm"); //$NON-NLS-1$
466 protected static final SimpleDateFormat sminformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
467 protected static final SimpleDateFormat shrsformat
= new SimpleDateFormat("MMM dd HH:mm"); //$NON-NLS-1$
468 protected static final SimpleDateFormat shrsformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
469 protected static final SimpleDateFormat sdayformat
= new SimpleDateFormat("MMM dd"); //$NON-NLS-1$
470 protected static final SimpleDateFormat sdayformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
471 protected static final SimpleDateFormat smonthformat
= new SimpleDateFormat("yyyy MMM"); //$NON-NLS-1$
472 protected static final SimpleDateFormat syearformat
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
474 static String
pad(long n
) {
483 public abstract void draw(GC gc
, long time
, Rectangle rect
);
485 public void drawAbsHeader(GC gc
, long time
, Rectangle absHeaderRect
) {
486 // Override to draw absolute time header
487 // This is for the time information not shown in the draw of each tick
490 public abstract String
hint();
493 class TimeDrawSec
extends TimeDraw
{
494 static String _hint
= "sec"; //$NON-NLS-1$
497 public void draw(GC gc
, long time
, Rectangle rect
) {
499 Utils
.drawText(gc
, time
+ "", rect
, true); //$NON-NLS-1$
503 public String
hint() {
508 class TimeDrawMillisec
extends TimeDraw
{
509 static String _hint
= "s:ms"; //$NON-NLS-1$
512 public void draw(GC gc
, long time
, Rectangle rect
) {
514 long ms
= time
% 1000;
516 Utils
.drawText(gc
, time
+ pad(ms
), rect
, true);
520 public String
hint() {
525 class TimeDrawMicrosec
extends TimeDraw
{
526 static String _hint
= "s:ms:mcs"; //$NON-NLS-1$
529 public void draw(GC gc
, long time
, Rectangle rect
) {
531 long mcs
= time
% 1000;
533 long ms
= time
% 1000;
535 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
), rect
, true);
539 public String
hint() {
544 class TimeDrawNanosec
extends TimeDraw
{
545 static String _hint
= "s:ms:mcs:ns"; //$NON-NLS-1$
548 public void draw(GC gc
, long time
, Rectangle rect
) {
549 long ns
= time
% 1000;
551 long mcs
= time
% 1000;
553 long ms
= time
% 1000;
555 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
) + pad(ns
), rect
, true);
559 public String
hint() {
564 class TimeDrawAbsYear
extends TimeDraw
{
565 static String _hint
= "YYYY"; //$NON-NLS-1$
568 public void draw(GC gc
, long time
, Rectangle rect
) {
569 String stime
= syearformat
.format(new Date((long) (time
/ 1000000)));
570 Utils
.drawText(gc
, stime
, rect
, true);
574 public String
hint() {
579 class TimeDrawAbsMonth
extends TimeDraw
{
580 static String _hint
= "YYYY Mmm"; //$NON-NLS-1$
583 public void draw(GC gc
, long time
, Rectangle rect
) {
584 String stime
= smonthformat
.format(new Date((long) (time
/ 1000000)));
585 Utils
.drawText(gc
, stime
, rect
, true);
589 public String
hint() {
594 class TimeDrawAbsDay
extends TimeDraw
{
595 static String _hint
= "Mmm dd"; //$NON-NLS-1$
598 public void draw(GC gc
, long time
, Rectangle rect
) {
599 String stime
= sdayformat
.format(new Date((long) (time
/ 1000000)));
600 Utils
.drawText(gc
, stime
, rect
, true);
604 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
605 String header
= sdayformatheader
.format(new Date((long) (time
/ 1000000)));
606 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
607 if (headerwidth
<= rect
.width
) {
608 rect
.x
+= (rect
.width
- headerwidth
);
609 Utils
.drawText(gc
, header
, rect
, true);
614 public String
hint() {
619 class TimeDrawAbsHrs
extends TimeDraw
{
620 static String _hint
= "Mmm dd HH:mm"; //$NON-NLS-1$
623 public void draw(GC gc
, long time
, Rectangle rect
) {
624 String stime
= shrsformat
.format(new Date((long) (time
/ 1000000)));
625 Utils
.drawText(gc
, stime
, rect
, true);
629 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
630 String header
= shrsformatheader
.format(new Date((long) (time
/ 1000000)));
631 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
632 if (headerwidth
<= rect
.width
) {
633 rect
.x
+= (rect
.width
- headerwidth
);
634 Utils
.drawText(gc
, header
, rect
, true);
639 public String
hint() {
644 class TimeDrawAbsMin
extends TimeDraw
{
645 static String _hint
= "HH:mm"; //$NON-NLS-1$
648 public void draw(GC gc
, long time
, Rectangle rect
) {
649 String stime
= sminformat
.format(new Date((long) (time
/ 1000000)));
650 Utils
.drawText(gc
, stime
, rect
, true);
654 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
655 String header
= sminformatheader
.format(new Date((long) (time
/ 1000000)));
656 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
657 if (headerwidth
<= rect
.width
) {
658 rect
.x
+= (rect
.width
- headerwidth
);
659 Utils
.drawText(gc
, header
, rect
, true);
665 public String
hint() {
670 class TimeDrawAbsSec
extends TimeDraw
{
671 static String _hint
= "HH:mm:ss"; //$NON-NLS-1$
674 public void draw(GC gc
, long time
, Rectangle rect
) {
675 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
676 Utils
.drawText(gc
, stime
, rect
, true);
680 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
681 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
682 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
683 if (headerwidth
<= rect
.width
) {
684 rect
.x
+= (rect
.width
- headerwidth
);
685 Utils
.drawText(gc
, header
, rect
, true);
690 public String
hint() {
695 class TimeDrawAbsMillisec
extends TimeDraw
{
696 static String _hint
= "HH:ss:ms"; //$NON-NLS-1$
699 public void draw(GC gc
, long time
, Rectangle rect
) {
700 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
701 String ns
= Utils
.formatNs(time
, Resolution
.MILLISEC
);
703 Utils
.drawText(gc
, stime
+ "." + ns
, rect
, true); //$NON-NLS-1$
707 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
708 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
709 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
710 if (headerwidth
<= rect
.width
) {
711 rect
.x
+= (rect
.width
- headerwidth
);
712 Utils
.drawText(gc
, header
, rect
, true);
717 public String
hint() {
722 class TimeDrawAbsMicroSec
extends TimeDraw
{
723 static String _hint
= "HH:ss:ms:mcs"; //$NON-NLS-1$
726 public void draw(GC gc
, long time
, Rectangle rect
) {
727 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
728 String micr
= Utils
.formatNs(time
, Resolution
.MICROSEC
);
729 Utils
.drawText(gc
, stime
+ "." + micr
, rect
, true); //$NON-NLS-1$
733 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
734 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
735 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
736 if (headerwidth
<= rect
.width
) {
737 rect
.x
+= (rect
.width
- headerwidth
);
738 Utils
.drawText(gc
, header
, rect
, true);
743 public String
hint() {
748 class TimeDrawAbsNanoSec
extends TimeDraw
{
749 static String _hint
= "HH:ss:ms:mcs:ns"; //$NON-NLS-1$
752 public void draw(GC gc
, long time
, Rectangle rect
) {
753 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
754 String ns
= Utils
.formatNs(time
, Resolution
.NANOSEC
);
755 Utils
.drawText(gc
, stime
+ "." + ns
, rect
, true); //$NON-NLS-1$
759 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
760 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
761 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
762 if (headerwidth
<= rect
.width
) {
763 rect
.x
+= (rect
.width
- headerwidth
);
764 Utils
.drawText(gc
, header
, rect
, true);
769 public String
hint() {