1 /**********************************************************************
2 * Copyright (c) 2015, 2016 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.tracecompass
.internal
.analysis
.timing
.ui
.views
.segmentstore
.scatter
;
14 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
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
;
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.
28 * @author Bernd Hufmann
30 public class SegmentStoreScatterGraphTooltipProvider
extends TmfClosestDataPointTooltipProvider
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 * Constructor for the segment store scatter chart tooltip provider.
38 * @param tmfChartViewer
39 * - the parent chart viewer
41 public SegmentStoreScatterGraphTooltipProvider(ITmfChartTimeProvider tmfChartViewer
) {
42 super(tmfChartViewer
);
46 // ------------------------------------------------------------------------
47 // TmfClosestDataPointTooltipProvider
48 // ------------------------------------------------------------------------
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());
63 buffer
.append(Messages
.SegmentStoreScatterGraphViewer_yAxis
).append('=');
64 buffer
.append((long) yS
[dataIndex
]);
65 return buffer
.toString();