analysis: Move timing analysis ui classes in own java packages
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.timing.ui / src / org / eclipse / tracecompass / internal / analysis / timing / ui / views / segmentstore / scatter / SegmentStoreScatterGraphTooltipProvider.java
1 /**********************************************************************
2 * Copyright (c) 2015, 2016 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.scatter;
13
14 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
15
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.scatter.Messages;
18 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
19 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
20 import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider;
21 import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfClosestDataPointTooltipProvider;
22 import org.swtchart.ISeries;
23
24 /**
25 * Tooltip provider for durations scatter charts. It displays the y value of
26 * position x as well as it highlights the closest data point.
27 *
28 * @author Bernd Hufmann
29 */
30 public class SegmentStoreScatterGraphTooltipProvider extends TmfClosestDataPointTooltipProvider{
31
32 // ------------------------------------------------------------------------
33 // Constructors
34 // ------------------------------------------------------------------------
35 /**
36 * Constructor for the segment store scatter chart tooltip provider.
37 *
38 * @param tmfChartViewer
39 * - the parent chart viewer
40 */
41 public SegmentStoreScatterGraphTooltipProvider(ITmfChartTimeProvider tmfChartViewer) {
42 super(tmfChartViewer);
43 register();
44 }
45
46 // ------------------------------------------------------------------------
47 // TmfClosestDataPointTooltipProvider
48 // ------------------------------------------------------------------------
49 @Override
50 protected @Nullable String createToolTipText(Parameter param) {
51 ISeries[] series = getChart().getSeriesSet().getSeries();
52 int seriesIndex = param.getSeriesIndex();
53 int dataIndex = param.getDataIndex();
54 if ((series != null) && (seriesIndex < series.length)) {
55 ISeries serie = series[seriesIndex];
56 double[] xS = serie.getXSeries();
57 double[] yS = serie.getYSeries();
58 if ((xS != null) && (yS != null) && (dataIndex < xS.length) && (dataIndex < yS.length)) {
59 StringBuffer buffer = new StringBuffer();
60 buffer.append(checkNotNull(Messages.SegmentStoreScatterGraphViewer_xAxis)).append('=');
61 buffer.append(new TmfTimestamp((long) xS[dataIndex] + getChartViewer().getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString());
62 buffer.append('\n');
63 buffer.append(Messages.SegmentStoreScatterGraphViewer_yAxis).append('=');
64 buffer.append((long) yS[dataIndex]);
65 return buffer.toString();
66 }
67 }
68 return null;
69 }
70
71 }
This page took 0.033627 seconds and 5 git commands to generate.