Skip to content
Snippets Groups Projects
Commit 61a1278c authored by Tim Molter's avatar Tim Molter
Browse files

cleaned up Series

parent 75abc405
No related branches found
No related tags found
No related merge requests found
...@@ -114,8 +114,8 @@ public class AxisPair implements ChartPart { ...@@ -114,8 +114,8 @@ public class AxisPair implements ChartPart {
seriesMap.put(seriesCount++, series); seriesMap.put(seriesCount++, series);
// add min/max to axis // add min/max to axis
xAxis.addMinMax(series.xMin, series.xMax); xAxis.addMinMax(series.getxMin(), series.getxMax());
yAxis.addMinMax(series.yMin, series.yMax); yAxis.addMinMax(series.getyMin(), series.getyMax());
return series; return series;
} }
......
...@@ -62,7 +62,7 @@ public class Legend implements ChartPart { ...@@ -62,7 +62,7 @@ public class Legend implements ChartPart {
for (Integer seriesId : seriesMap.keySet()) { for (Integer seriesId : seriesMap.keySet()) {
Series series = seriesMap.get(seriesId); Series series = seriesMap.get(seriesId);
TextLayout textLayout = new TextLayout(series.name, chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false)); TextLayout textLayout = new TextLayout(series.getName(), chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false));
Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0); Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
// System.out.println(rectangle); // System.out.println(rectangle);
if (rectangle.getWidth() > legendTextContentMaxWidth) { if (rectangle.getWidth() > legendTextContentMaxWidth) {
...@@ -98,20 +98,20 @@ public class Legend implements ChartPart { ...@@ -98,20 +98,20 @@ public class Legend implements ChartPart {
for (Integer seriesId : seriesMap.keySet()) { for (Integer seriesId : seriesMap.keySet()) {
Series series = seriesMap.get(seriesId); Series series = seriesMap.get(seriesId);
// paint line // paint line
if (series.stroke != null) { if (series.getStroke() != null) {
g.setColor(series.strokeColor); g.setColor(series.getStrokeColor());
g.setStroke(series.stroke); g.setStroke(series.getStroke());
g.drawLine(startx, starty - Marker.Y_OFFSET, (int) (startx + Marker.SIZE * 3.0), starty - Marker.Y_OFFSET); g.drawLine(startx, starty - Marker.Y_OFFSET, (int) (startx + Marker.SIZE * 3.0), starty - Marker.Y_OFFSET);
} }
// paint marker // paint marker
if (series.marker != null) { if (series.getMarker() != null) {
g.setColor(series.markerColor); g.setColor(series.getMarkerColor());
series.marker.paint(g, (int) (startx + (Marker.SIZE * 1.5)), starty - Marker.Y_OFFSET); series.getMarker().paint(g, (int) (startx + (Marker.SIZE * 1.5)), starty - Marker.Y_OFFSET);
} }
// paint series name // paint series name
g.setColor(chart.getStyleManager().getChartFontColor()); g.setColor(chart.getStyleManager().getChartFontColor());
TextLayout layout = new TextLayout(series.name, chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false)); TextLayout layout = new TextLayout(series.getName(), chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false));
layout.draw(g, (float) (startx + Marker.SIZE + (Marker.SIZE * 1.5) + chart.getStyleManager().getLegendPadding()), (starty + Marker.SIZE)); layout.draw(g, (float) (startx + Marker.SIZE + (Marker.SIZE * 1.5) + chart.getStyleManager().getLegendPadding()), (starty + Marker.SIZE));
starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getLegendPadding(); starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getLegendPadding();
} }
......
...@@ -77,13 +77,13 @@ public class PlotContent implements ChartPart { ...@@ -77,13 +77,13 @@ public class PlotContent implements ChartPart {
int yTopMargin = AxisPair.getTickStartOffset((int) bounds.getHeight(), yTickSpace); int yTopMargin = AxisPair.getTickStartOffset((int) bounds.getHeight(), yTickSpace);
// data points // data points
Collection<?> xData = series.xData; Collection<?> xData = series.getxData();
BigDecimal xMin = getChart().getAxisPair().getxAxis().getMin(); BigDecimal xMin = getChart().getAxisPair().getxAxis().getMin();
BigDecimal xMax = getChart().getAxisPair().getxAxis().getMax(); BigDecimal xMax = getChart().getAxisPair().getxAxis().getMax();
Collection<Number> yData = series.yData; Collection<Number> yData = series.getyData();
BigDecimal yMin = getChart().getAxisPair().getyAxis().getMin(); BigDecimal yMin = getChart().getAxisPair().getyAxis().getMin();
BigDecimal yMax = getChart().getAxisPair().getyAxis().getMax(); BigDecimal yMax = getChart().getAxisPair().getyAxis().getMax();
Collection<Number> errorBars = series.errorBars; Collection<Number> errorBars = series.getErrorBars();
int previousX = Integer.MIN_VALUE; int previousX = Integer.MIN_VALUE;
int previousY = Integer.MIN_VALUE; int previousY = Integer.MIN_VALUE;
...@@ -133,10 +133,10 @@ public class PlotContent implements ChartPart { ...@@ -133,10 +133,10 @@ public class PlotContent implements ChartPart {
// System.out.println(yTransform); // System.out.println(yTransform);
// paint line // paint line
if (series.stroke != null && !isScatterChart) { if (series.getStroke() != null && !isScatterChart) {
if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) { if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) {
g.setColor(series.strokeColor); g.setColor(series.getStrokeColor());
g.setStroke(series.stroke); g.setStroke(series.getStroke());
g.drawLine(previousX, previousY, xOffset, yOffset); g.drawLine(previousX, previousY, xOffset, yOffset);
} }
previousX = xOffset; previousX = xOffset;
...@@ -144,9 +144,9 @@ public class PlotContent implements ChartPart { ...@@ -144,9 +144,9 @@ public class PlotContent implements ChartPart {
} }
// paint marker // paint marker
if (series.marker != null) { if (series.getMarker() != null) {
g.setColor(series.markerColor); g.setColor(series.getMarkerColor());
series.marker.paint(g, xOffset, yOffset); series.getMarker().paint(g, xOffset, yOffset);
} }
// paint errorbar // paint errorbar
......
...@@ -32,37 +32,37 @@ import com.xeiam.xchart.internal.markers.Marker; ...@@ -32,37 +32,37 @@ import com.xeiam.xchart.internal.markers.Marker;
*/ */
public class Series { public class Series {
public String name = ""; private String name = "";
public Collection<?> xData; private Collection<?> xData;
public Collection<Number> yData; private Collection<Number> yData;
public Collection<Number> errorBars; private Collection<Number> errorBars;
/** the minimum value of axis range */ /** the minimum value of axis range */
public BigDecimal xMin; private BigDecimal xMin;
/** the maximum value of axis range */ /** the maximum value of axis range */
public BigDecimal xMax; private BigDecimal xMax;
/** the minimum value of axis range */ /** the minimum value of axis range */
public BigDecimal yMin; private BigDecimal yMin;
/** the maximum value of axis range */ /** the maximum value of axis range */
public BigDecimal yMax; private BigDecimal yMax;
/** Line Style */ /** Line Style */
public BasicStroke stroke; private BasicStroke stroke;
/** Line Color */ /** Line Color */
public Color strokeColor; private Color strokeColor;
/** Marker Style */ /** Marker Style */
public Marker marker; private Marker marker;
/** Marker Color */ /** Marker Color */
public Color markerColor; private Color markerColor;
/** /**
* Constructor * Constructor
...@@ -234,4 +234,63 @@ public class Series { ...@@ -234,4 +234,63 @@ public class Series {
this.markerColor = color; this.markerColor = color;
} }
public Collection<?> getxData() {
return xData;
}
public Collection<Number> getyData() {
return yData;
}
public Collection<Number> getErrorBars() {
return errorBars;
}
public BigDecimal getxMin() {
return xMin;
}
public BigDecimal getxMax() {
return xMax;
}
public BigDecimal getyMin() {
return yMin;
}
public BigDecimal getyMax() {
return yMax;
}
public BasicStroke getStroke() {
return stroke;
}
public Marker getMarker() {
return marker;
}
public Color getStrokeColor() {
return strokeColor;
}
public Color getMarkerColor() {
return markerColor;
}
public String getName() {
return name;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment