Skip to content

Commit 0f9c58b

Browse files
committed
Amend eclipse#306 - Box Plot Demo
Removed unused import
1 parent ede8d24 commit 0f9c58b

File tree

1 file changed

+25
-26
lines changed
  • org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/marker

1 file changed

+25
-26
lines changed

org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/marker/BoxPlotMarker.java

+25-26
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212
*******************************************************************************/
1313
package org.eclipse.swtchart.extensions.marker;
1414

15-
import java.math.BigDecimal;
1615
import java.util.Arrays;
1716

1817
import org.eclipse.swt.SWT;
1918
import org.eclipse.swt.events.PaintEvent;
2019
import org.eclipse.swt.graphics.GC;
2120
import org.eclipse.swt.graphics.Rectangle;
2221
import org.eclipse.swt.widgets.Display;
22+
import org.eclipse.swtchart.IAxis;
2323
import org.eclipse.swtchart.ISeries;
2424
import org.eclipse.swtchart.ISeriesSet;
2525
import org.eclipse.swtchart.extensions.core.BaseChart;
26-
import org.eclipse.swtchart.IAxis;
2726

2827
public class BoxPlotMarker extends AbstractBaseChartPaintListener implements IBaseChartPaintListener {
2928

@@ -35,6 +34,7 @@ public BoxPlotMarker(BaseChart baseChart) {
3534
@SuppressWarnings("unused")
3635
@Override
3736
public void paintControl(PaintEvent e) {
37+
3838
BaseChart baseChart = getBaseChart();
3939
ISeriesSet seriesSet = baseChart.getSeriesSet();
4040
GC gc = e.gc;
@@ -52,64 +52,63 @@ public void paintControl(PaintEvent e) {
5252
int xMax = 0;
5353
int yMin = 0;
5454
int yMax = 0;
55-
for (; index < xData.length; index++) {
55+
for(; index < xData.length; index++) {
5656
int x = xAxis.getPixelCoordinate(xData[index], xLower, xUpper);
5757
int y = yAxis.getPixelCoordinate(yData[index], yLower, yUpper);
58-
if (0 == index) {
59-
xMin = x;
60-
xMax = x;
61-
yMin = y;
62-
yMax = y;
58+
if(0 == index) {
59+
xMin = x;
60+
xMax = x;
61+
yMin = y;
62+
yMax = y;
6363
} else {
64-
if (x > xMax) {
64+
if(x > xMax) {
6565
xMax = x;
6666
}
67-
if (x < xMin) {
67+
if(x < xMin) {
6868
xMin = x;
6969
}
70-
if (y > yMax) {
70+
if(y > yMax) {
7171
yMax = y;
7272
}
73-
if (y < yMin) {
73+
if(y < yMin) {
7474
yMin = y;
7575
}
76-
}
76+
}
7777
}
7878
Arrays.sort(yData);
79-
double q1= getValue(0.25, yData);
80-
double q2= getValue(0.50, yData);
81-
double q3= getValue(0.75, yData);
79+
double q1 = getValue(0.25, yData);
80+
double q2 = getValue(0.50, yData);
81+
double q3 = getValue(0.75, yData);
8282
int q1Y = yAxis.getPixelCoordinate(q1, yLower, yUpper);
8383
int q2Y = yAxis.getPixelCoordinate(q2, yLower, yUpper);
8484
int q3Y = yAxis.getPixelCoordinate(q3, yLower, yUpper);
85-
86-
Rectangle rectangle = new Rectangle(xMin, q1Y, xMax-xMin, q3Y-q1Y);
85+
Rectangle rectangle = new Rectangle(xMin, q1Y, xMax - xMin, q3Y - q1Y);
8786
gc.setLineStyle(SWT.LINE_SOLID);
8887
gc.setLineWidth(2);
8988
gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_YELLOW));
9089
gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
9190
gc.setAlpha(100);
92-
gc.fillRectangle(xMin, q1Y, xMax-xMin, q3Y-q1Y);
93-
gc.drawRectangle(xMin, q1Y, xMax-xMin, q3Y-q1Y);
91+
gc.fillRectangle(xMin, q1Y, xMax - xMin, q3Y - q1Y);
92+
gc.drawRectangle(xMin, q1Y, xMax - xMin, q3Y - q1Y);
9493
gc.drawLine(xMin, yMin, xMax, yMin);
9594
gc.drawLine(xMin, yMax, xMax, yMax);
9695
gc.drawLine(xMin + (xMax - xMin) / 2, yMin, xMin + (xMax - xMin) / 2, q3Y);
9796
gc.drawLine(xMin + (xMax - xMin) / 2, yMax, xMin + (xMax - xMin) / 2, q1Y);
98-
gc.drawLine(xMin , q2Y, xMax, q2Y);
97+
gc.drawLine(xMin, q2Y, xMax, q2Y);
9998
}
100-
10199
}
102-
103-
100+
104101
public int getIndex(double rate, int size) {
102+
105103
/**
106104
* This index is just an approximation and I will modify it.
107105
*/
108-
int index = (int)(rate * (size +1));
106+
int index = (int)(rate * (size + 1));
109107
return index;
110108
}
111-
109+
112110
public double getValue(double rate, double[] data) {
111+
113112
int size = data.length;
114113
int index = getIndex(rate, size);
115114
return data[index - 1];

0 commit comments

Comments
 (0)