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

cleaned up Series

parent 75abc405
Branches
No related tags found
No related merge requests found
......@@ -105,17 +105,17 @@ public class AxisPair implements ChartPart {
// Sanity check
if (xData != null && xData.size() != yData.size()) {
throw new IllegalArgumentException("X and Y-Axis sizes are not the same!!! ");
throw new IllegalArgumentException("X and Y-Axis sizes are not the same!!!");
}
if (errorBars != null && errorBars.size() != yData.size()) {
throw new IllegalArgumentException("errorbars and Y-Axis sizes are not the same!!! ");
throw new IllegalArgumentException("errorbars and Y-Axis sizes are not the same!!!");
}
seriesMap.put(seriesCount++, series);
// add min/max to axis
xAxis.addMinMax(series.xMin, series.xMax);
yAxis.addMinMax(series.yMin, series.yMax);
xAxis.addMinMax(series.getxMin(), series.getxMax());
yAxis.addMinMax(series.getyMin(), series.getyMax());
return series;
}
......
......@@ -62,7 +62,7 @@ public class Legend implements ChartPart {
for (Integer seriesId : seriesMap.keySet()) {
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);
// System.out.println(rectangle);
if (rectangle.getWidth() > legendTextContentMaxWidth) {
......@@ -98,20 +98,20 @@ public class Legend implements ChartPart {
for (Integer seriesId : seriesMap.keySet()) {
Series series = seriesMap.get(seriesId);
// paint line
if (series.stroke != null) {
g.setColor(series.strokeColor);
g.setStroke(series.stroke);
if (series.getStroke() != null) {
g.setColor(series.getStrokeColor());
g.setStroke(series.getStroke());
g.drawLine(startx, starty - Marker.Y_OFFSET, (int) (startx + Marker.SIZE * 3.0), starty - Marker.Y_OFFSET);
}
// paint marker
if (series.marker != null) {
g.setColor(series.markerColor);
series.marker.paint(g, (int) (startx + (Marker.SIZE * 1.5)), starty - Marker.Y_OFFSET);
if (series.getMarker() != null) {
g.setColor(series.getMarkerColor());
series.getMarker().paint(g, (int) (startx + (Marker.SIZE * 1.5)), starty - Marker.Y_OFFSET);
}
// paint series name
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));
starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getLegendPadding();
}
......
......@@ -77,13 +77,13 @@ public class PlotContent implements ChartPart {
int yTopMargin = AxisPair.getTickStartOffset((int) bounds.getHeight(), yTickSpace);
// data points
Collection<?> xData = series.xData;
Collection<?> xData = series.getxData();
BigDecimal xMin = getChart().getAxisPair().getxAxis().getMin();
BigDecimal xMax = getChart().getAxisPair().getxAxis().getMax();
Collection<Number> yData = series.yData;
Collection<Number> yData = series.getyData();
BigDecimal yMin = getChart().getAxisPair().getyAxis().getMin();
BigDecimal yMax = getChart().getAxisPair().getyAxis().getMax();
Collection<Number> errorBars = series.errorBars;
Collection<Number> errorBars = series.getErrorBars();
int previousX = Integer.MIN_VALUE;
int previousY = Integer.MIN_VALUE;
......@@ -133,10 +133,10 @@ public class PlotContent implements ChartPart {
// System.out.println(yTransform);
// paint line
if (series.stroke != null && !isScatterChart) {
if (series.getStroke() != null && !isScatterChart) {
if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) {
g.setColor(series.strokeColor);
g.setStroke(series.stroke);
g.setColor(series.getStrokeColor());
g.setStroke(series.getStroke());
g.drawLine(previousX, previousY, xOffset, yOffset);
}
previousX = xOffset;
......@@ -144,9 +144,9 @@ public class PlotContent implements ChartPart {
}
// paint marker
if (series.marker != null) {
g.setColor(series.markerColor);
series.marker.paint(g, xOffset, yOffset);
if (series.getMarker() != null) {
g.setColor(series.getMarkerColor());
series.getMarker().paint(g, xOffset, yOffset);
}
// paint errorbar
......
......@@ -32,37 +32,37 @@ import com.xeiam.xchart.internal.markers.Marker;
*/
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 */
public BigDecimal xMin;
private BigDecimal xMin;
/** the maximum value of axis range */
public BigDecimal xMax;
private BigDecimal xMax;
/** the minimum value of axis range */
public BigDecimal yMin;
private BigDecimal yMin;
/** the maximum value of axis range */
public BigDecimal yMax;
private BigDecimal yMax;
/** Line Style */
public BasicStroke stroke;
private BasicStroke stroke;
/** Line Color */
public Color strokeColor;
private Color strokeColor;
/** Marker Style */
public Marker marker;
private Marker marker;
/** Marker Color */
public Color markerColor;
private Color markerColor;
/**
* Constructor
......@@ -234,4 +234,63 @@ public class Series {
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