/**********************************************************************
- * Copyright (c) 2013, 2014 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2013, 2015 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.tracecompass.tmf.core.signal.TmfRangeSynchSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.tracecompass.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.ui.viewers.TmfTimeViewer;
import org.swtchart.Chart;
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- /**
- * The offset to apply to any x position. This offset ensures better
- * precision when converting long to double and back.
- */
- private long fTimeOffset;
/** The SWT Chart reference */
private Chart fSwtChart;
/** The mouse selection provider */
private TmfBaseProvider fToolTipProvider;
/** The middle mouse drag provider */
private TmfBaseProvider fMouseDragProvider;
+ /**
+ * Whether or not to send time alignment signals. This should be set to true
+ * for viewers that are part of an aligned view.
+ */
+ private boolean fSendTimeAlignSignals = false;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
// Getter/Setters
// ------------------------------------------------------------------------
- /**
- * Sets the time offset to apply.
- * @see ITmfChartTimeProvider#getTimeOffset()
- *
- * @param timeOffset
- * The time offset to apply
- */
- protected void setTimeOffset(long timeOffset) {
- fTimeOffset = timeOffset;
- }
/**
* Sets the SWT Chart reference
@Override
public long getTimeOffset() {
- return fTimeOffset;
+ return getWindowStartTime() - 1;
}
// ------------------------------------------------------------------------
* Signal handler for handling of the time synch signal.
*
* @param signal
- * The time synch signal {@link TmfTimeSynchSignal}
+ * The time synch signal {@link TmfSelectionRangeUpdatedSignal}
*/
@Override
@TmfSignalHandler
- public void selectionRangeUpdated(TmfTimeSynchSignal signal) {
+ public void selectionRangeUpdated(TmfSelectionRangeUpdatedSignal signal) {
super.selectionRangeUpdated(signal);
if ((signal.getSource() != this) && (getTrace() != null)) {
if (fMouseSelectionProvider != null) {
}
/**
- * Signal handler for handling of the time range synch signal.
+ * Signal handler for handling of the window range signal.
*
* @param signal
- * The time range synch signal {@link TmfRangeSynchSignal}
+ * The {@link TmfWindowRangeUpdatedSignal}
*/
@Override
@TmfSignalHandler
- public void timeRangeUpdated(TmfRangeSynchSignal signal) {
- super.timeRangeUpdated(signal);
+ public void windowRangeUpdated(TmfWindowRangeUpdatedSignal signal) {
+ super.windowRangeUpdated(signal);
updateContent();
}
return display;
}
+ /**
+ * Get the offset of the point area, relative to the XY chart viewer
+ * control. We consider the point area to be from where the first point
+ * could be drawn to where the last point could be drawn.
+ *
+ * @return the offset in pixels
+ *
+ * @since 1.0
+ */
+ public int getPointAreaOffset() {
+
+ int pixelCoordinate = 0;
+ IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes();
+ ISeries[] series = fSwtChart.getSeriesSet().getSeries();
+ if ((xAxes.length > 0) && (series.length > 0) &&
+ (series[0].getXSeries() != null) && (series[0].getXSeries().length > 0)) {
+ IAxis axis = xAxes[0];
+ // All series have the same X series
+ double[] xSeries = series[0].getXSeries();
+ pixelCoordinate = axis.getPixelCoordinate(xSeries[0]);
+ }
+ return getSwtChart().toControl(getSwtChart().getPlotArea().toDisplay(pixelCoordinate, 0)).x;
+ }
+
+ /**
+ * Get the width of the point area. We consider the point area to be from
+ * where the first point could be drawn to where the last point could be
+ * drawn. The point area differs from the plot area because there might be a
+ * gap between where the plot area start and where the fist point is drawn.
+ * This also matches the width that the use can select.
+ *
+ * @return the width in pixels
+ *
+ * @since 1.0
+ */
+ public int getPointAreaWidth() {
+ IAxis[] xAxes = getSwtChart().getAxisSet().getXAxes();
+ ISeries[] series = fSwtChart.getSeriesSet().getSeries();
+ if ((xAxes.length > 0) && (series.length > 0) &&
+ (series[0].getXSeries() != null) && (series[0].getXSeries().length > 0)) {
+ IAxis axis = xAxes[0];
+ // All series have the same X series
+ double[] xSeries = series[0].getXSeries();
+ int x1 = getPointAreaOffset();
+ int x2 = axis.getPixelCoordinate(xSeries[xSeries.length - 1]);
+ x2 = getSwtChart().toControl(getSwtChart().getPlotArea().toDisplay(x2, 0)).x;
+ int width = x2 - x1;
+ return width;
+ }
+
+ return getSwtChart().getPlotArea().getSize().x;
+ }
+
+ /**
+ * Sets whether or not to send time alignment signals. This should be set to
+ * true for viewers that are part of an aligned view.
+ *
+ * @param sendTimeAlignSignals
+ * whether or not to send time alignment signals
+ * @since 1.0
+ */
+ public void setSendTimeAlignSignals(boolean sendTimeAlignSignals) {
+ fSendTimeAlignSignals = sendTimeAlignSignals;
+ }
+
+ /**
+ * Returns whether or not to send time alignment signals.
+ *
+ * @return whether or not to send time alignment signals.
+ * @since 1.0
+ */
+ public boolean isSendTimeAlignSignals() {
+ return fSendTimeAlignSignals;
+ }
}