/*****************************************************************************
- * Copyright (c) 2007, 2015 Intel Corporation, Ericsson
+ * Copyright (c) 2007, 2016 Intel Corporation, Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimePreferences;
-import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
private boolean fIsInUpdate;
private int fHeight;
private List<Integer> fTickList = new ArrayList<>();
- private List<IMarkerEvent> fMarkers = null;
- private boolean fMarkersVisible = true;
/**
* Standard constructor
addMouseListener(this);
addMouseMoveListener(this);
TimeDraw.updateTimeZone();
- }
-
- @Override
- public void dispose() {
- TmfSignalManager.deregister(this);
- super.dispose();
+ addDisposeListener((e) -> {
+ TmfSignalManager.deregister(TimeGraphScale.this);
+ });
}
/**
return fTickList;
}
- /**
- * Set the markers list.
- *
- * @param markers
- * The markers list, or null
- * @since 2.0
- */
- public void setMarkers(List<IMarkerEvent> markers) {
- fMarkers = markers;
- }
-
- /**
- * Set the markers visibility. The default is true.
- *
- * @param visible
- * true to show the markers, false otherwise
- * @since 2.0
- */
- public void setMarkersVisible(boolean visible) {
- fMarkersVisible = visible;
- }
-
private long calcTimeDelta(int width, double pixelsPerNanoSec) {
long timeDelta;
double minDelta = (pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec;
}
}
fTickList = tickList;
-
- // draw marker labels
- if (fMarkersVisible && fMarkers != null) {
- for (IMarkerEvent marker : fMarkers) {
- String label = marker.getLabel();
- if (label != null && marker.getEntry() == null) {
- int x = rect.x + leftSpace + (int) (Math.floor((marker.getTime() - time0) * pixelsPerNanoSec));
- y = rect.y + rect.height - gc.stringExtent(label).y + 1;
- gc.setForeground(marker.getColor());
- Utils.drawText(gc, label, x, y, true);
- }
- }
- }
}
private static void drawRangeDecorators(Rectangle rect, GC gc, int x1, int x2) {
*/
public void drawAbsHeader(GC gc, long nanosec, Rectangle absHeaderRect) {
}
+
+ protected void drawAbsHeader(GC gc, long nanosec, Rectangle rect, SimpleDateFormat dateFormat) {
+ String header;
+ synchronized (dateFormat) {
+ header = dateFormat.format(new Date(nanosec / MILLISEC_IN_NS));
+ }
+ int headerwidth = gc.stringExtent(header).x + 4;
+ if (headerwidth <= rect.width) {
+ rect.x += (rect.width - headerwidth);
+ Utils.drawText(gc, header, rect, true);
+ }
+ }
}
class TimeDrawSec extends TimeDraw {
@Override
public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
- String header;
- synchronized (DAY_FORMAT_HEADER) {
- header = DAY_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
- }
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
+ drawAbsHeader(gc, nanosec, rect, DAY_FORMAT_HEADER);
}
}
@Override
public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
- String header;
- synchronized (HOURS_FORMAT_HEADER) {
- header = HOURS_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
- }
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
+ drawAbsHeader(gc, nanosec, rect, HOURS_FORMAT_HEADER);
}
}
@Override
public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
- String header;
- synchronized (MIN_FORMAT_HEADER) {
- header = MIN_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
- }
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
+ drawAbsHeader(gc, nanosec, rect, MIN_FORMAT_HEADER);
}
}
@Override
public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
- String header;
- synchronized (SEC_FORMAT_HEADER) {
- header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
- }
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
+ drawAbsHeader(gc, nanosec, rect, SEC_FORMAT_HEADER);
}
}
@Override
public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
- String header;
- synchronized (SEC_FORMAT_HEADER) {
- header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
- }
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
+ drawAbsHeader(gc, nanosec, rect, SEC_FORMAT_HEADER);
}
}
@Override
public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
- String header;
- synchronized (SEC_FORMAT_HEADER) {
- header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
- }
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
+ drawAbsHeader(gc, nanosec, rect, SEC_FORMAT_HEADER);
}
}
@Override
public void drawAbsHeader(GC gc, long nanosec, Rectangle rect) {
- String header;
- synchronized (SEC_FORMAT_HEADER) {
- header = SEC_FORMAT_HEADER.format(new Date(nanosec / MILLISEC_IN_NS));
- }
- int headerwidth = gc.stringExtent(header).x + 4;
- if (headerwidth <= rect.width) {
- rect.x += (rect.width - headerwidth);
- Utils.drawText(gc, header, rect, true);
- }
+ drawAbsHeader(gc, nanosec, rect, SEC_FORMAT_HEADER);
}
}
String stime = Utils.formatTime(time, TimeFormat.CYCLES, Resolution.SECONDS);
return Utils.drawText(gc, stime, rect, true);
}
-}
+}
\ No newline at end of file