Skip to content

Commit c39f91e

Browse files
author
duy.tran.yb
committed
Optimize
1 parent cf91de6 commit c39f91e

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/linechart/TmfCommonXLineChartTooltipProvider.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@
2323
import org.eclipse.swt.graphics.Point;
2424
import org.eclipse.swt.graphics.RGBA;
2525
import org.eclipse.swt.widgets.Control;
26-
import org.eclipse.tracecompass.internal.tmf.ui.Messages;
2726
import org.eclipse.tracecompass.tmf.core.presentation.RGBAColor;
28-
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
29-
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
3027
import org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler;
3128
import org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler.ToolTipString;
3229
import org.eclipse.tracecompass.tmf.ui.viewers.xychart.IAxis;
3330
import org.eclipse.tracecompass.tmf.ui.viewers.xychart.ITmfChartTimeProvider;
3431
import org.eclipse.tracecompass.tmf.ui.viewers.xychart.IXYSeries;
3532
import org.eclipse.tracecompass.tmf.ui.viewers.xychart.TmfBaseProvider;
33+
import org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer;
3634

3735
/**
3836
* Displays a tooltip on line charts. For each series, it shows the y value at
@@ -81,10 +79,7 @@ protected int getHoveredIndex(List<IXYSeries> series, double xCoordinate) {
8179
return -1;
8280
}
8381
double[] xSeries = series.get(0).getXSeries();
84-
if (xSeries == null) {
85-
return -1;
86-
}
87-
if (xSeries.length == 0) {
82+
if ((xSeries == null) || (xSeries.length == 0)) {
8883
return -1;
8984
}
9085
int index = Arrays.binarySearch(xSeries, xCoordinate);
@@ -101,12 +96,7 @@ protected void addAdditionalTooltipItems(double xCoordinate, String seriesKey) {
10196
// Default: no-op
10297
}
10398

104-
protected void addSeriesTooltipItem(
105-
IXYSeries series,
106-
String key,
107-
int index,
108-
Format format) {
109-
99+
protected void addSeriesTooltipItem(IXYSeries series, String key, int index, Format format) {
110100
double[] ySeries = series.getYSeries();
111101
if (ySeries == null || index < 0 || index >= ySeries.length) {
112102
return;
@@ -121,16 +111,13 @@ protected void addSeriesTooltipItem(
121111
}
122112
}
123113

124-
protected String formatSeriesLabel(
125-
IXYSeries series,
126-
String key) {
127-
114+
protected String formatSeriesLabel(IXYSeries series, String key) {
128115
String label = (key == null) ? "" : key; //$NON-NLS-1$
129116
Color color = series.getColor();
130117
if (color != null) {
131118
RGBA rgba = color.getRGBA();
132119
RGBAColor rgbaColor = new RGBAColor(rgba.rgb.red, rgba.rgb.green, rgba.rgb.blue, rgba.alpha);
133-
label = String.format(HTML_COLOR_TOOLTIP, rgbaColor, label);
120+
label = String.format(TmfCommonXLineChartTooltipProvider.HTML_COLOR_TOOLTIP, rgbaColor, label);
134121
}
135122
return label;
136123
}

0 commit comments

Comments
 (0)