Skip to content

Commit

Permalink
Move to SWTChart 1.0
Browse files Browse the repository at this point in the history
Fix some generification warnings while at it.
  • Loading branch information
akurtakov committed Dec 19, 2024
1 parent 0f40e0b commit f711b05
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2009, 2018 STMicroelectronics and others.
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -33,7 +33,7 @@

/**
* A utility class that handles the charts creation (pie chart and bar chart)
*
*
*/
public final class ChartFactory {

Expand Down Expand Up @@ -118,13 +118,12 @@ public static InteractiveChart producePieChart(Object[] objects, ISTDataViewersF

public static InteractiveChart produceBarChart(Object[] objects, final ISTDataViewersField nameField,
List<IChartField> valFields, String title, boolean horizontal) {
ChartView view;
try {
final Color WHITE = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WHITE);
final Color BLACK = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_BLACK);
final Color GRAD = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);

view = (ChartView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
ChartView view = (ChartView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.showView(ChartView.VIEW_ID, String.valueOf(ChartView.getSecId()), IWorkbenchPage.VIEW_ACTIVATE);
InteractiveChart chart = new InteractiveChart(view.getParent(), SWT.NONE);

Expand Down Expand Up @@ -167,7 +166,7 @@ public static InteractiveChart produceBarChart(Object[] objects, final ISTDataVi

// data
for (IChartField field : valFields) {
final IBarSeries bs = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR,
final IBarSeries<?> bs = (IBarSeries<?>) chart.getSeriesSet().createSeries(SeriesType.BAR,
field.getColumnHeaderText());
bs.setBarColor(new Color(Display.getDefault(), getRC(), getRC(), getRC()));
double[] doubleValues = new double[objects.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Bundle-Version: 3.0.0.qualifier
Bundle-Vendor: %bundleProvider
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.swtchart
org.eclipse.swtchart;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.linuxtools.dataviewers.piechart, org.eclipse.linuxtools.internal.dataviewers.piechart;x-internal:=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public void setCustomColors(Color[] customColors) {
*/
public void addPieChartSeries(String[] labels, double[][] val) {
setSeriesNames(val[0].length);
for (ISeries s : this.getSeriesSet().getSeries()) {
for (ISeries<?> s : this.getSeriesSet().getSeries()) {
this.getSeriesSet().deleteSeries(s.getId());
}

int size = Math.min(labels.length, val.length);
for (int i = 0; i < size; i++) {
IBarSeries s = (IBarSeries) this.getSeriesSet().createSeries(ISeries.SeriesType.BAR, labels[i]);
IBarSeries<?> s = (IBarSeries<?>) this.getSeriesSet().createSeries(ISeries.SeriesType.BAR, labels[i]);
double[] d = new double[val[i].length];
for (int j = 0; j < val[i].length; j++) {
d[j] = val[i][j];
Expand Down Expand Up @@ -158,7 +158,7 @@ public int getSliceIndexFromPosition(int pieIndex, int x, int y) {
*/
public double getSlicePercent(int pieIndex, int sliceIndex) {
double max = 0;
ISeries[] series = getSeriesSet().getSeries();
ISeries<?>[] series = getSeriesSet().getSeries();
for (int i = 0; i < series.length; i++) {
max += series[i].getXSeries()[pieIndex];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private void drawPieChart(PaintEvent e, int chartnum, Rectangle bounds) {
pieSliceAngles[chartnum][i - 1] = 90 - initialAngle;
}

gc.setBackground(((IBarSeries) chart.getSeriesSet().getSeries()[i]).getBarColor());
gc.setBackground(((IBarSeries<?>) chart.getSeriesSet().getSeries()[i]).getBarColor());

if (i == (nelemSeries - 1)) {
sweepAngle = 360 - incrementAngle;
Expand Down Expand Up @@ -200,7 +200,7 @@ private void drawPieChart(PaintEvent e, int chartnum, Rectangle bounds) {
}

private void getPieSeriesArray() {
ISeries series[] = this.chart.getSeriesSet().getSeries();
ISeries<?> series[] = this.chart.getSeriesSet().getSeries();
if (series == null || series.length == 0) {
seriesValues = new double[0][0];
seriesNames = new String[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.swtchart.feature.feature.group" version="0.0.0"/>
<unit id="org.eclipse.swtchart.feature.source.feature.group" version="0.0.0"/>
<repository location="https://download.eclipse.org/swtchart/releases/0.14.0/repository"/>
<repository location="https://download.eclipse.org/swtchart/releases/1.0.0/repository"/>
</location>
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="error" type="Maven">
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Require-Bundle: org.eclipse.linuxtools.systemtap.graphing.core,
org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.forms,
org.eclipse.swtchart,
org.eclipse.swtchart;bundle-version="1.0.0",
org.eclipse.linuxtools.dataviewers.piechart,
org.eclipse.linuxtools.dataviewers.charts
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected double getChartMarginYU() {
* @param i The index of the series to create.
* @return The newly created series.
*/
protected abstract ISeries createChartISeries(int i);
protected abstract ISeries<?> createChartISeries(int i);

@Override
protected void updateProperties(PropertyChangeEvent event) {
Expand Down Expand Up @@ -265,8 +265,8 @@ protected void buildXSeries() {
// Now create dense arrays of x/y values that exclude null values,
// and plot those values to the chart.

ISeries allSeries[] = chart.getSeriesSet().getSeries();
ISeries series = null;
ISeries<?> allSeries[] = chart.getSeriesSet().getSeries();
ISeries<?> series = null;
for (int i = 0; i < leny; i++) {
if (i >= allSeries.length) {
series = createChartISeries(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public AreaChartBuilder(Composite parent, int style, String title,IAdapter adapt
}

@Override
protected ISeries createChartISeries(int i) {
ILineSeries series = (ILineSeries) super.createChartISeries(i);
protected ISeries<?> createChartISeries(int i) {
ILineSeries<?> series = (ILineSeries<?>) super.createChartISeries(i);
series.enableArea(true);
return series;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void hideBars() {
Range rangeX = xAxis.getRange();
double bottomY = getAxisSet().getYAxis(0).getRange().lower;
double nonNegBottomY = Math.max(0, bottomY);
ISeries[] allSeries = getSeriesSet().getSeries();
ISeries<?>[] allSeries = getSeriesSet().getSeries();
actualYSeries = new double[allSeries.length][];

for (int i = 0, n = allSeries.length; i < n; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ protected void createChart() {
}

@Override
protected ISeries createChartISeries(int i) {
IBarSeries series = (IBarSeries)chart.getSeriesSet().
createSeries(SeriesType.BAR, adapter.getLabels()[i+1]);
protected ISeries<?> createChartISeries(int i) {
IBarSeries<?> series = (IBarSeries<?>) chart.getSeriesSet()
.createSeries(SeriesType.BAR, adapter.getLabels()[i + 1]);
series.setBarColor(COLORS[i % COLORS.length]);
return series;
}
Expand Down Expand Up @@ -104,9 +104,9 @@ protected void buildXSeries() {
String[] valxTrim = new String[lenTrim];
System.arraycopy(valx, 0, valxTrim, 0, lenTrim);

ISeries allSeries[] = chart.getSeriesSet().getSeries();
ISeries<?> allSeries[] = chart.getSeriesSet().getSeries();
for (int i = 0; i < leny; i++) {
ISeries series;
ISeries<?> series;
if (i >= allSeries.length) {
series = createChartISeries(i);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public LineChartBuilder(Composite parent, int style, String title, IAdapter adap
}

@Override
protected ISeries createChartISeries(int i) {
ILineSeries series = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE,
protected ISeries<?> createChartISeries(int i) {
ILineSeries<?> series = (ILineSeries<?>) chart.getSeriesSet().createSeries(SeriesType.LINE,
adapter.getLabels()[i + 1]);
series.setSymbolColor(COLORS[i % COLORS.length]);
series.setLineColor(COLORS[i % COLORS.length]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public ScatterChartBuilder(Composite parent, int style, String title,IAdapter ad
}

@Override
protected ISeries createChartISeries(int i) {
ILineSeries series = (ILineSeries)super.createChartISeries(i);
protected ISeries<?> createChartISeries(int i) {
ILineSeries<?> series = (ILineSeries<?>) super.createChartISeries(i);
series.setSymbolColor(COLORS[i % COLORS.length]);
series.setLineStyle(LineStyle.NONE);
return series;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public BarChartMouseMoveListener(BarChart chart, Control parent) {
@Override
public void mouseMove(MouseEvent e) {
super.mouseMove(e);
ISeries[] allSeries = chart.getSeriesSet().getSeries();
ISeries<?>[] allSeries = chart.getSeriesSet().getSeries();
if (allSeries.length == 0) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public void mouseMove(MouseEvent e) {
super.mouseMove(e);
double closestDistance = DIST_TOLERANCE;
int closestIndex = -1;
ISeries closestSeries = null;
ISeries<?> closestSeries = null;
Point closestPoint = null;
for (ISeries series : chart.getSeriesSet().getSeries()) {
for (ISeries<?> series : chart.getSeriesSet().getSeries()) {
for (int i = 0; i < series.getXSeries().length; i++) {
Point dataPoint = series.getPixelCoordinates(i);
if (dataPoint.x >= 0 && dataPoint.y >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public PieChartMouseMoveListener(PieChart chart, Composite parent) {
@Override
public void mouseMove(MouseEvent e) {
super.mouseMove(e);
ISeries[] allSeries = chart.getSeriesSet().getSeries();
ISeries<?>[] allSeries = chart.getSeriesSet().getSeries();
int numPies = allSeries.length > 0 ? allSeries[0].getXSeries().length : 0;
int pieIndex = 0, sliceIndex = -1;
for (; pieIndex < numPies; pieIndex++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public GraphDiscreteXControl(GraphComposite comp, int style) {
}

private int getNumItems() {
ISeries[] series = builder.getChart().getSeriesSet().getSeries();
ISeries<?>[] series = builder.getChart().getSeriesSet().getSeries();
return series.length > 0 ? series[0].getXSeries().length : 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ private static class ChartHasUpdated extends DefaultCondition {
*/
public ChartHasUpdated(Chart chart, int expectedCount) {
this.chart = chart;
ISeries[] seriesSet = chart.getSeriesSet().getSeries();
ISeries<?>[] seriesSet = chart.getSeriesSet().getSeries();
this.oldCount = seriesSet.length > 0 ? seriesSet[0].getXSeries().length : 0;
this.expectedCount = expectedCount;
}
@Override
public boolean test() {
ISeries[] seriesSet = chart.getSeriesSet().getSeries();
ISeries<?>[] seriesSet = chart.getSeriesSet().getSeries();
int newCount = seriesSet.length > 0 ? seriesSet[0].getXSeries().length : 0;
return expectedCount < 0 ? newCount > oldCount : newCount == expectedCount;
}
Expand Down Expand Up @@ -858,7 +858,7 @@ public void testGraphContents() {
graphEditorA.bot().cTabItem(graphTitle1).activate();
Matcher<AbstractChartBuilder> matcher = widgetOfType(AbstractChartBuilder.class);
AbstractChartBuilder cb = bot.widget(matcher);
ISeries[] series = cb.getChart().getSeriesSet().getSeries();
ISeries<?>[] series = cb.getChart().getSeriesSet().getSeries();
assertEquals(2, series.length);
assertEquals(10, series[0].getXSeries().length);
assertEquals(10, series[1].getXSeries().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void testChartCallback() throws Exception {
.getActivePage().getActiveEditor();
assertTrue(part instanceof ChartEditor);
Chart control = ((ChartEditor) part).getControl();
ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().getSeries(
ILineSeries<?> lsTotal = (ILineSeries<?>) control.getSeriesSet().getSeries(
Messages.getString("HeapChart.Total_Heap")); //$NON-NLS-1$
Point p1 = lsTotal.getPixelCoordinates(4);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.linuxtools.internal.valgrind.massif.MassifPlugin
Bundle-Vendor: %Bundle-Vendor.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.swtchart.extensions
org.eclipse.swtchart.extensions;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ public void createPartControl(Composite parent) {
control.getLegend().setPosition(SWT.BOTTOM);

// data
final ILineSeries lsUseful = (ILineSeries) control.getSeriesSet().
final ILineSeries<?> lsUseful = (ILineSeries<?>) control.getSeriesSet().
createSeries(SeriesType.LINE, Messages.getString("HeapChart.Useful_Heap")); //$NON-NLS-1$;
lsUseful.setXSeries(heapChart.time);
lsUseful.setYSeries(heapChart.dataUseful);
lsUseful.setSymbolType(PlotSymbolType.DIAMOND);
lsUseful.setSymbolColor(RED);
lsUseful.setLineColor(RED);

final ILineSeries lsExtra = (ILineSeries) control.getSeriesSet().
final ILineSeries<?> lsExtra = (ILineSeries<?>) control.getSeriesSet().
createSeries(SeriesType.LINE, Messages.getString("HeapChart.Extra_Heap")); //$NON-NLS-1$;
lsExtra.setXSeries(heapChart.time);
lsExtra.setYSeries(heapChart.dataExtra);
Expand All @@ -149,7 +149,8 @@ public void createPartControl(Composite parent) {
lsExtra.setLineColor(ORANGE);

if (heapChart.dataStacks != null){
final ILineSeries lsStack = (ILineSeries) control.getSeriesSet().
final ILineSeries<?> lsStack = (ILineSeries<?>) control.getSeriesSet()
.
createSeries(SeriesType.LINE, Messages.getString("HeapChart.Stacks")); //$NON-NLS-1$;
lsStack.setXSeries(heapChart.time);
lsStack.setYSeries(heapChart.dataStacks);
Expand All @@ -158,7 +159,8 @@ public void createPartControl(Composite parent) {
lsStack.setLineColor(DARK_BLUE);
}

final ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().
final ILineSeries<?> lsTotal = (ILineSeries<?>) control.getSeriesSet()
.
createSeries(SeriesType.LINE, Messages.getString("HeapChart.Total_Heap")); //$NON-NLS-1$;
lsTotal.setXSeries(heapChart.time);
lsTotal.setYSeries(heapChart.dataTotal);
Expand Down

0 comments on commit f711b05

Please sign in to comment.