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
.tmf
.core
.timestamp
.ITmfTimestamp
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
19 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.xycharts
.ITmfChartTimeProvider
;
20 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.xycharts
.TmfClosestDataPointTooltipProvider
;
21 import org
.swtchart
.ISeries
;
24 * Tooltip provider for durations scatter charts. It displays the y value of
25 * position x as well as it highlights the closest data point.
27 * @author Bernd Hufmann
29 public class SegmentStoreScatterGraphTooltipProvider
extends TmfClosestDataPointTooltipProvider
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * Constructor for the segment store scatter chart tooltip provider.
37 * @param tmfChartViewer
38 * - the parent chart viewer
40 public SegmentStoreScatterGraphTooltipProvider(ITmfChartTimeProvider tmfChartViewer
) {
41 super(tmfChartViewer
);
45 // ------------------------------------------------------------------------
46 // TmfClosestDataPointTooltipProvider
47 // ------------------------------------------------------------------------
49 protected @Nullable String
createToolTipText(Parameter param
) {
50 ISeries
[] series
= getChart().getSeriesSet().getSeries();
51 int seriesIndex
= param
.getSeriesIndex();
52 int dataIndex
= param
.getDataIndex();
53 if ((series
!= null) && (seriesIndex
< series
.length
)) {
54 ISeries serie
= series
[seriesIndex
];
55 double[] xS
= serie
.getXSeries();
56 double[] yS
= serie
.getYSeries();
57 if ((xS
!= null) && (yS
!= null) && (dataIndex
< xS
.length
) && (dataIndex
< yS
.length
)) {
58 StringBuffer buffer
= new StringBuffer();
59 buffer
.append(checkNotNull(Messages
.SegmentStoreScatterGraphViewer_xAxis
)).append('=');
60 buffer
.append(new TmfTimestamp((long) xS
[dataIndex
] + getChartViewer().getTimeOffset(), ITmfTimestamp
.NANOSECOND_SCALE
).toString());
62 buffer
.append(Messages
.SegmentStoreScatterGraphViewer_yAxis
).append('=');
63 buffer
.append((long) yS
[dataIndex
]);
64 return buffer
.toString();