1 /*****************************************************************************
2 * Copyright (c) 2007, 2008, 2010 Intel Corporation and others.
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 Sanchex-Leon - Udpated for TMF
13 * $Id: TimeScaleCtrl.java,v 1.5 2008/06/16 21:04:49 jkubasta Exp $
14 *****************************************************************************/
16 package org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.widgets
;
18 import java
.text
.SimpleDateFormat
;
19 import java
.util
.Calendar
;
20 import java
.util
.Date
;
21 import java
.util
.GregorianCalendar
;
22 import java
.util
.TimeZone
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.internal
.Messages
;
25 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.timeAnalysis
.widgets
.Utils
.Resolution
;
26 import org
.eclipse
.swt
.SWT
;
27 import org
.eclipse
.swt
.events
.MouseEvent
;
28 import org
.eclipse
.swt
.events
.MouseListener
;
29 import org
.eclipse
.swt
.events
.MouseMoveListener
;
30 import org
.eclipse
.swt
.events
.PaintEvent
;
31 import org
.eclipse
.swt
.graphics
.GC
;
32 import org
.eclipse
.swt
.graphics
.Point
;
33 import org
.eclipse
.swt
.graphics
.Rectangle
;
34 import org
.eclipse
.swt
.widgets
.Composite
;
36 public class TimeScaleCtrl
extends TraceCtrl
implements MouseListener
,
39 public TimeScaleCtrl(Composite parent
, TraceColorScheme colors
) {
40 super(parent
, colors
, SWT
.NO_BACKGROUND
| SWT
.NO_FOCUS
41 | SWT
.DOUBLE_BUFFERED
);
42 addMouseListener(this);
43 addMouseMoveListener(this);
46 private static final long SEC_IN_NS
= 1000000000;
47 private static final long MIN_IN_NS
= 60 * SEC_IN_NS
;
48 private static final long HOUR_IN_NS
= 60 * MIN_IN_NS
;
49 private static final long DAY_IN_NS
= 24 * HOUR_IN_NS
;
50 private static final long MONTH_IN_NS
= 31 * DAY_IN_NS
; // upper limit
51 private static final long YEAR_IN_NS
= 366 * DAY_IN_NS
; // upper limit
53 private static final double LOG10_1
= Math
.log10(1);
54 private static final double LOG10_2
= Math
.log10(2);
55 private static final double LOG10_3
= Math
.log10(3);
56 private static final double LOG10_5
= Math
.log10(5);
58 private static final Calendar GREGORIAN_CALENDAR
= GregorianCalendar
.getInstance(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
60 private ITimeDataProvider _timeProvider
;
61 private int _dragState
= 0;
62 private int _dragX0
= 0;
63 private int _dragX
= 0;
64 private long _time0bak
;
65 private long _time1bak
;
66 private boolean _isInUpdate
;
67 private Rectangle _rect0
= new Rectangle(0, 0, 0, 0);
70 public void setTimeProvider(ITimeDataProvider timeProvider
) {
71 _timeProvider
= timeProvider
;
74 private long _timeDelta
;
77 public Point
computeSize(int wHint
, int hHint
, boolean changed
) {
78 return super.computeSize(wHint
, _height
, changed
);
81 public void setHeight(int height
) {
82 this._height
= height
;
85 private void calcTimeDelta(int width
, double pixelsPerNanoSec
) {
86 double minDelta
= (double) ((pixelsPerNanoSec
== 0) ? YEAR_IN_NS
: width
/ pixelsPerNanoSec
);
88 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
89 if (minDelta
> 6 * MONTH_IN_NS
) {
91 } else if (minDelta
> 3 * MONTH_IN_NS
) {
92 unit
= 6 * MONTH_IN_NS
;
93 } else if (minDelta
> 10 * DAY_IN_NS
) {
95 } else if (minDelta
> 12 * HOUR_IN_NS
) {
97 } else if (minDelta
> 3 * HOUR_IN_NS
) {
98 unit
= 6 * HOUR_IN_NS
;
99 } else if (minDelta
> 30 * MIN_IN_NS
) {
101 } else if (minDelta
> 10 * MIN_IN_NS
) {
102 unit
= 15 * MIN_IN_NS
;
103 } else if (minDelta
> 30 * SEC_IN_NS
) {
105 } else if (minDelta
> 20 * SEC_IN_NS
) {
106 unit
= 30 * SEC_IN_NS
;
107 } else if (minDelta
<= 1) {
112 double log
= Math
.log10((double) minDelta
/ unit
);
113 long pow10
= (long) log
;
114 double remainder
= log
- pow10
;
115 if (remainder
< LOG10_1
) {
116 _timeDelta
= (long) Math
.pow(10, pow10
) * unit
;
117 } else if (remainder
< LOG10_2
) {
118 _timeDelta
= 2 * (long) Math
.pow(10, pow10
) * unit
;
119 } else if (remainder
< LOG10_3
&& unit
>= HOUR_IN_NS
&& unit
< YEAR_IN_NS
) {
120 _timeDelta
= 3 * (long) Math
.pow(10, pow10
) * unit
;
121 } else if (remainder
< LOG10_5
) {
122 _timeDelta
= 5 * (long) Math
.pow(10, pow10
) * unit
;
124 _timeDelta
= 10 * (long) Math
.pow(10, pow10
) * unit
;
128 private static TimeDraw TIMEDRAW_NANOSEC
= new TimeDrawNanosec();
129 private static TimeDraw TIMEDRAW_MICROSEC
= new TimeDrawMicrosec();
130 private static TimeDraw TIMEDRAW_MILLISEC
= new TimeDrawMillisec();
131 private static TimeDraw TIMEDRAW_SEC
= new TimeDrawSec();
132 private static TimeDraw TIMEDRAW_ABS_NANOSEC
= new TimeDrawAbsNanoSec();
133 private static TimeDraw TIMEDRAW_ABS_MICROSEC
= new TimeDrawAbsMicroSec();
134 private static TimeDraw TIMEDRAW_ABS_MILLISEC
= new TimeDrawAbsMillisec();
135 private static TimeDraw TIMEDRAW_ABS_SEC
= new TimeDrawAbsSec();
136 private static TimeDraw TIMEDRAW_ABS_MIN
= new TimeDrawAbsMin();
137 private static TimeDraw TIMEDRAW_ABS_HRS
= new TimeDrawAbsHrs();
138 private static TimeDraw TIMEDRAW_ABS_DAY
= new TimeDrawAbsDay();
139 private static TimeDraw TIMEDRAW_ABS_MONTH
= new TimeDrawAbsMonth();
140 private static TimeDraw TIMEDRAW_ABS_YEAR
= new TimeDrawAbsYear();
142 TimeDraw
getTimeDraw(long timeDelta
) {
144 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
145 if (timeDelta
>= YEAR_IN_NS
)
146 timeDraw
= TIMEDRAW_ABS_YEAR
;
147 else if (timeDelta
>= MONTH_IN_NS
)
148 timeDraw
= TIMEDRAW_ABS_MONTH
;
149 else if (timeDelta
>= DAY_IN_NS
)
150 timeDraw
= TIMEDRAW_ABS_DAY
;
151 else if (timeDelta
>= HOUR_IN_NS
)
152 timeDraw
= TIMEDRAW_ABS_HRS
;
153 else if (timeDelta
>= MIN_IN_NS
)
154 timeDraw
= TIMEDRAW_ABS_MIN
;
155 else if (timeDelta
>= SEC_IN_NS
)
156 timeDraw
= TIMEDRAW_ABS_SEC
;
157 else if (timeDelta
>= 1000000)
158 timeDraw
= TIMEDRAW_ABS_MILLISEC
;
159 else if (timeDelta
>= 1000)
160 timeDraw
= TIMEDRAW_ABS_MICROSEC
;
162 timeDraw
= TIMEDRAW_ABS_NANOSEC
;
165 if (timeDelta
>= 1000000000)
166 timeDraw
= TIMEDRAW_SEC
;
167 else if (timeDelta
>= 1000000)
168 timeDraw
= TIMEDRAW_MILLISEC
;
169 else if (timeDelta
>= 1000)
170 timeDraw
= TIMEDRAW_MICROSEC
;
172 timeDraw
= TIMEDRAW_NANOSEC
;
177 void paint(Rectangle rect
, PaintEvent e
) {
179 if (_isInUpdate
|| null == _timeProvider
)
183 gc
.fillRectangle(rect
);
185 if (null == _timeProvider
) {
189 long time0
= _timeProvider
.getTime0();
190 long time1
= _timeProvider
.getTime1();
191 long selectedTime
= _timeProvider
.getSelectedTime();
192 int leftSpace
= _timeProvider
.getNameSpace();
193 int timeSpace
= _timeProvider
.getTimeSpace();
195 gc
.setBackground(_colors
.getColor(TraceColorScheme
.TOOL_BACKGROUND
));
196 gc
.setForeground(_colors
.getColor(TraceColorScheme
.TOOL_FOREGROUND
));
197 Utils
.init(_rect0
, rect
);
199 // draw top left area
200 _rect0
.width
= leftSpace
;
203 if (_rect0
.width
> 0) {
204 Utils
.drawText(gc
, Messages
.TimeScaleCtrl_Timescale
+ ":", _rect0
, true); //$NON-NLS-1$
206 int messageWidth
= gc
.stringExtent(Messages
.TimeScaleCtrl_Timescale
+ ":").x
+ 4; //$NON-NLS-1$
207 Rectangle absHeaderRect
= new Rectangle(_rect0
.x
+ messageWidth
, _rect0
.y
, _rect0
.width
- messageWidth
, _rect0
.height
);
211 // prepare and draw right rect of the timescale
212 _rect0
.x
+= leftSpace
;
213 _rect0
.width
= rect
.width
- leftSpace
;
215 // draw bottom border and erase all other area
216 gc
.drawLine(rect
.x
, rect
.y
+ rect
.height
- 1, rect
.x
+ rect
.width
- 1,
217 rect
.y
+ rect
.height
- 1);
219 gc
.fillRectangle(_rect0
);
221 if (time1
<= time0
|| timeSpace
< 2) {
225 int numDigits
= calculateDigits(time0
, time1
);
227 int labelWidth
= gc
.getCharWidth('0') * numDigits
;
228 double pixelsPerNanoSec
= (timeSpace
<= RIGHT_MARGIN
) ?
0 :
229 (double) (timeSpace
- RIGHT_MARGIN
) / (time1
- time0
);
230 calcTimeDelta(labelWidth
, pixelsPerNanoSec
);
232 TimeDraw timeDraw
= getTimeDraw(_timeDelta
);
234 // draw zoom rectangle
235 if (3 == _dragState
&& null != _timeProvider
) {
236 if (_dragX0
< _dragX
) {
237 gc
.drawRectangle(leftSpace
+ _dragX0
, rect
.y
, _dragX
- _dragX0
- 1, rect
.height
- 8);
238 } else if (_dragX0
> _dragX
) {
239 gc
.drawRectangle(leftSpace
+ _dragX
, rect
.y
, _dragX0
- _dragX
- 1, rect
.height
- 8);
243 if (_rect0
.isEmpty())
246 // draw selected time
247 int x
= _rect0
.x
+ (int) ((double)(selectedTime
- time0
) * pixelsPerNanoSec
);
248 if (x
>= _rect0
.x
&& x
< _rect0
.x
+ _rect0
.width
) {
249 gc
.setForeground(_colors
.getColor(TraceColorScheme
.SELECTED_TIME
));
250 gc
.drawLine(x
, _rect0
.y
+ _rect0
.height
- 6, x
, _rect0
.y
253 .setForeground(_colors
254 .getColor(TraceColorScheme
.TOOL_FOREGROUND
));
257 // draw time scale ticks
259 _rect0
.height
= rect
.height
- 4;
260 _rect0
.width
= labelWidth
;
263 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
264 time
= floorToCalendar(time0
, _timeDelta
);
266 time
= (long) (Math
.ceil((double) time0
/ _timeDelta
) * _timeDelta
);
269 // long t = (long) (time * 1000000000);
270 int y
= _rect0
.y
+ _rect0
.height
;
272 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
273 timeDraw
.drawAbsHeader(gc
, time
, absHeaderRect
);
277 x
= rect
.x
+ leftSpace
+ (int) (Math
.floor((time
- time0
) * pixelsPerNanoSec
));
278 if (x
>= rect
.x
+ leftSpace
+ rect
.width
- _rect0
.width
) {
281 if (x
>= rect
.x
+ leftSpace
) {
282 gc
.drawLine(x
, y
, x
, y
+ 4);
284 if (x
+ _rect0
.width
<= rect
.x
+ rect
.width
)
285 timeDraw
.draw(gc
, time
, _rect0
);
287 if (pixelsPerNanoSec
== 0 || time
> Long
.MAX_VALUE
- _timeDelta
) {
291 if (_timeProvider
!= null && _timeProvider
.isCalendarFormat()) {
292 if (_timeDelta
>= YEAR_IN_NS
) {
293 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
294 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
295 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
296 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
297 } else if (_timeDelta
>= MONTH_IN_NS
) {
298 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
299 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
300 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
306 private long floorToCalendar(long time
, long timeDelta
) {
307 if (_timeDelta
>= YEAR_IN_NS
) {
308 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
309 int year
= GREGORIAN_CALENDAR
.get(Calendar
.YEAR
);
310 int yearDelta
= (int) (timeDelta
/ YEAR_IN_NS
);
311 year
= (year
/ yearDelta
) * yearDelta
;
312 GREGORIAN_CALENDAR
.set(Calendar
.YEAR
, year
);
313 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, 0); // January 1st of year
314 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1);
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;
320 } else if (_timeDelta
>= MONTH_IN_NS
) {
321 GREGORIAN_CALENDAR
.setTime(new Date(time
/ 1000000));
322 int month
= GREGORIAN_CALENDAR
.get(Calendar
.MONTH
);
323 int monthDelta
= (int) (timeDelta
/ MONTH_IN_NS
);
324 month
= (month
/ monthDelta
) * monthDelta
;
325 GREGORIAN_CALENDAR
.set(Calendar
.MONTH
, month
);
326 GREGORIAN_CALENDAR
.set(Calendar
.DAY_OF_MONTH
, 1); // 1st of month
327 GREGORIAN_CALENDAR
.set(Calendar
.HOUR_OF_DAY
, 0);
328 GREGORIAN_CALENDAR
.set(Calendar
.MINUTE
, 0);
329 GREGORIAN_CALENDAR
.set(Calendar
.SECOND
, 0);
330 GREGORIAN_CALENDAR
.set(Calendar
.MILLISECOND
, 0);
331 time
= GREGORIAN_CALENDAR
.getTimeInMillis() * 1000000;
333 time
= (time
/ timeDelta
) * timeDelta
;
338 private int calculateDigits(long time0
, long time1
) {
340 long timeRange
= time1
- time0
;
342 if (_timeProvider
.isCalendarFormat()) {
343 // Calculate the number of digits to represent the minutes provided
347 if (timeRange
< 10000) {
348 // HH:11:222:333:444__
350 } else if (timeRange
< 10000000) {
355 // Calculate the number of digits to represent the minutes provided
356 long min
= (long) ((time1
* 1E-9) / 60); // to sec then to minutes
357 String strMinutes
= String
.valueOf(min
);
359 if (strMinutes
!= null) {
360 numDigits
+= strMinutes
.length();
364 if (timeRange
< 10000) {
367 } else if (timeRange
< 10000000) {
373 // Trace.debug("timeRange: " + timeRange + " numDigits: " + numDigits);
378 public void mouseDown(MouseEvent e
) {
379 if (_dragState
== 0 && null != _timeProvider
) {
383 } else if (3 == e
.button
) {
386 int x
= e
.x
- _timeProvider
.getNameSpace();
389 } else if (x
> getSize().x
- _timeProvider
.getNameSpace()) {
390 x
= getSize().x
- _timeProvider
.getNameSpace();
392 _dragX
= _dragX0
= x
;
393 _time0bak
= _timeProvider
.getTime0();
394 _time1bak
= _timeProvider
.getTime1();
399 public void mouseUp(MouseEvent e
) {
400 if (e
.button
== 1 && _dragState
== 1) {
404 // Notify time provider to check the need for listener notification
405 if (_dragX
!= _dragX0
) {
406 _timeProvider
.setStartFinishTimeNotify(_timeProvider
.getTime0(), _timeProvider
.getTime1());
408 } else if (e
.button
== 3 && _dragState
== 3 && null != _timeProvider
) {
410 if (_dragX0
== _dragX
) {
413 int timeSpace
= _timeProvider
.getTimeSpace();
414 int leftSpace
= _timeProvider
.getNameSpace();
415 int x
= e
.x
- leftSpace
;
418 if (_dragX0
> _dragX
) { // drag right to left
422 long time0
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ timeSpace
));
423 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX
/ timeSpace
));
425 _timeProvider
.setStartFinishTimeNotify(time0
, time1
);
426 _time0bak
= _timeProvider
.getTime0();
427 _time1bak
= _timeProvider
.getTime1();
433 public void mouseMove(MouseEvent e
) {
434 if (_dragX0
< 0 || _dragState
== 0) {
437 Point size
= getSize();
438 int leftSpace
= _timeProvider
.getNameSpace();
439 int timeSpace
= _timeProvider
.getTimeSpace();
440 int x
= e
.x
- leftSpace
;
441 if (1 == _dragState
&& null != _timeProvider
) {
442 if (x
> 0 && size
.x
> leftSpace
&& _dragX
!= x
) {
444 long time1
= _time0bak
+ (long) ((_time1bak
- _time0bak
) * ((double) _dragX0
/ _dragX
));
445 _timeProvider
.setStartFinishTime(_time0bak
, time1
);
447 } else if (3 == _dragState
&& null != _timeProvider
) {
450 } else if (x
> timeSpace
) {
460 public void mouseDoubleClick(MouseEvent e
) {
461 if (null != _timeProvider
) {
462 _timeProvider
.resetStartFinishTime();
463 _time0bak
= _timeProvider
.getTime0();
464 _time1bak
= _timeProvider
.getTime1();
469 abstract class TimeDraw
{
470 static String S
= ":" ; //$NON-NLS-1$
471 static String S0
= ":0" ; //$NON-NLS-1$
472 static String S00
= ":00"; //$NON-NLS-1$
473 protected static final SimpleDateFormat stimeformat
= new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
474 protected static final SimpleDateFormat stimeformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
475 protected static final SimpleDateFormat sminformat
= new SimpleDateFormat("HH:mm"); //$NON-NLS-1$
476 protected static final SimpleDateFormat sminformatheader
= new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$
477 protected static final SimpleDateFormat shrsformat
= new SimpleDateFormat("MMM dd HH:mm"); //$NON-NLS-1$
478 protected static final SimpleDateFormat shrsformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
479 protected static final SimpleDateFormat sdayformat
= new SimpleDateFormat("MMM dd"); //$NON-NLS-1$
480 protected static final SimpleDateFormat sdayformatheader
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
481 protected static final SimpleDateFormat smonthformat
= new SimpleDateFormat("yyyy MMM"); //$NON-NLS-1$
482 protected static final SimpleDateFormat syearformat
= new SimpleDateFormat("yyyy"); //$NON-NLS-1$
484 stimeformat
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
485 stimeformatheader
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
486 sminformat
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
487 sminformatheader
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
488 shrsformat
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
489 shrsformatheader
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
490 sdayformat
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
491 sdayformatheader
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
492 smonthformat
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
493 syearformat
.setTimeZone(TimeZone
.getTimeZone("GMT")); //$NON-NLS-1$
496 static String
pad(long n
) {
505 public abstract void draw(GC gc
, long time
, Rectangle rect
);
507 public void drawAbsHeader(GC gc
, long time
, Rectangle absHeaderRect
) {
508 // Override to draw absolute time header
509 // This is for the time information not shown in the draw of each tick
512 public abstract String
hint();
515 class TimeDrawSec
extends TimeDraw
{
516 static String _hint
= "sec"; //$NON-NLS-1$
519 public void draw(GC gc
, long time
, Rectangle rect
) {
521 Utils
.drawText(gc
, time
+ "", rect
, true); //$NON-NLS-1$
525 public String
hint() {
530 class TimeDrawMillisec
extends TimeDraw
{
531 static String _hint
= "s:ms"; //$NON-NLS-1$
534 public void draw(GC gc
, long time
, Rectangle rect
) {
536 long ms
= time
% 1000;
538 Utils
.drawText(gc
, time
+ pad(ms
), rect
, true);
542 public String
hint() {
547 class TimeDrawMicrosec
extends TimeDraw
{
548 static String _hint
= "s:ms:mcs"; //$NON-NLS-1$
551 public void draw(GC gc
, long time
, Rectangle rect
) {
553 long mcs
= time
% 1000;
555 long ms
= time
% 1000;
557 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
), rect
, true);
561 public String
hint() {
566 class TimeDrawNanosec
extends TimeDraw
{
567 static String _hint
= "s:ms:mcs:ns"; //$NON-NLS-1$
570 public void draw(GC gc
, long time
, Rectangle rect
) {
571 long ns
= time
% 1000;
573 long mcs
= time
% 1000;
575 long ms
= time
% 1000;
577 Utils
.drawText(gc
, time
+ pad(ms
) + pad(mcs
) + pad(ns
), rect
, true);
581 public String
hint() {
586 class TimeDrawAbsYear
extends TimeDraw
{
587 static String _hint
= "YYYY"; //$NON-NLS-1$
590 public void draw(GC gc
, long time
, Rectangle rect
) {
591 String stime
= syearformat
.format(new Date((long) (time
/ 1000000)));
592 Utils
.drawText(gc
, stime
, rect
, true);
596 public String
hint() {
601 class TimeDrawAbsMonth
extends TimeDraw
{
602 static String _hint
= "YYYY Mmm"; //$NON-NLS-1$
605 public void draw(GC gc
, long time
, Rectangle rect
) {
606 String stime
= smonthformat
.format(new Date((long) (time
/ 1000000)));
607 Utils
.drawText(gc
, stime
, rect
, true);
611 public String
hint() {
616 class TimeDrawAbsDay
extends TimeDraw
{
617 static String _hint
= "Mmm dd"; //$NON-NLS-1$
620 public void draw(GC gc
, long time
, Rectangle rect
) {
621 String stime
= sdayformat
.format(new Date((long) (time
/ 1000000)));
622 Utils
.drawText(gc
, stime
, rect
, true);
626 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
627 String header
= sdayformatheader
.format(new Date((long) (time
/ 1000000)));
628 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
629 if (headerwidth
<= rect
.width
) {
630 rect
.x
+= (rect
.width
- headerwidth
);
631 Utils
.drawText(gc
, header
, rect
, true);
636 public String
hint() {
641 class TimeDrawAbsHrs
extends TimeDraw
{
642 static String _hint
= "Mmm dd HH:mm"; //$NON-NLS-1$
645 public void draw(GC gc
, long time
, Rectangle rect
) {
646 String stime
= shrsformat
.format(new Date((long) (time
/ 1000000)));
647 Utils
.drawText(gc
, stime
, rect
, true);
651 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
652 String header
= shrsformatheader
.format(new Date((long) (time
/ 1000000)));
653 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
654 if (headerwidth
<= rect
.width
) {
655 rect
.x
+= (rect
.width
- headerwidth
);
656 Utils
.drawText(gc
, header
, rect
, true);
661 public String
hint() {
666 class TimeDrawAbsMin
extends TimeDraw
{
667 static String _hint
= "HH:mm"; //$NON-NLS-1$
670 public void draw(GC gc
, long time
, Rectangle rect
) {
671 String stime
= sminformat
.format(new Date((long) (time
/ 1000000)));
672 Utils
.drawText(gc
, stime
, rect
, true);
676 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
677 String header
= sminformatheader
.format(new Date((long) (time
/ 1000000)));
678 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
679 if (headerwidth
<= rect
.width
) {
680 rect
.x
+= (rect
.width
- headerwidth
);
681 Utils
.drawText(gc
, header
, rect
, true);
687 public String
hint() {
692 class TimeDrawAbsSec
extends TimeDraw
{
693 static String _hint
= "HH:mm:ss"; //$NON-NLS-1$
696 public void draw(GC gc
, long time
, Rectangle rect
) {
697 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
698 Utils
.drawText(gc
, stime
, rect
, true);
702 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
703 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
704 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
705 if (headerwidth
<= rect
.width
) {
706 rect
.x
+= (rect
.width
- headerwidth
);
707 Utils
.drawText(gc
, header
, rect
, true);
712 public String
hint() {
717 class TimeDrawAbsMillisec
extends TimeDraw
{
718 static String _hint
= "HH:ss:ms"; //$NON-NLS-1$
721 public void draw(GC gc
, long time
, Rectangle rect
) {
722 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
723 String ns
= Utils
.formatNs(time
, Resolution
.MILLISEC
);
725 Utils
.drawText(gc
, stime
+ " " + ns
, rect
, true); //$NON-NLS-1$
729 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
730 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
731 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
732 if (headerwidth
<= rect
.width
) {
733 rect
.x
+= (rect
.width
- headerwidth
);
734 Utils
.drawText(gc
, header
, rect
, true);
739 public String
hint() {
744 class TimeDrawAbsMicroSec
extends TimeDraw
{
745 static String _hint
= "HH:ss:ms:mcs"; //$NON-NLS-1$
748 public void draw(GC gc
, long time
, Rectangle rect
) {
749 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
750 String micr
= Utils
.formatNs(time
, Resolution
.MICROSEC
);
751 Utils
.drawText(gc
, stime
+ " " + micr
, rect
, true); //$NON-NLS-1$
755 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
756 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
757 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
758 if (headerwidth
<= rect
.width
) {
759 rect
.x
+= (rect
.width
- headerwidth
);
760 Utils
.drawText(gc
, header
, rect
, true);
765 public String
hint() {
770 class TimeDrawAbsNanoSec
extends TimeDraw
{
771 static String _hint
= "HH:ss:ms:mcs:ns"; //$NON-NLS-1$
774 public void draw(GC gc
, long time
, Rectangle rect
) {
775 String stime
= stimeformat
.format(new Date((long) (time
/ 1000000)));
776 String ns
= Utils
.formatNs(time
, Resolution
.NANOSEC
);
777 Utils
.drawText(gc
, stime
+ " " + ns
, rect
, true); //$NON-NLS-1$
781 public void drawAbsHeader(GC gc
, long time
, Rectangle rect
) {
782 String header
= stimeformatheader
.format(new Date((long) (time
/ 1000000)));
783 int headerwidth
= gc
.stringExtent(header
).x
+ 4;
784 if (headerwidth
<= rect
.width
) {
785 rect
.x
+= (rect
.width
- headerwidth
);
786 Utils
.drawText(gc
, header
, rect
, true);
791 public String
hint() {