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

fix and cleanup formatting

parent 1d4022c7
Branches
Tags
No related merge requests found
...@@ -127,6 +127,8 @@ public class PlotContentLineChart extends PlotContent { ...@@ -127,6 +127,8 @@ public class PlotContentLineChart extends PlotContent {
Number next = yItr.next(); Number next = yItr.next();
if (next == null) { if (next == null) {
// for area charts
closePath(g, path, previousX, bounds, yTopMargin); closePath(g, path, previousX, bounds, yTopMargin);
path = null; path = null;
...@@ -145,7 +147,8 @@ public class PlotContentLineChart extends PlotContent { ...@@ -145,7 +147,8 @@ public class PlotContentLineChart extends PlotContent {
// System.out.println(y); // System.out.println(y);
if (getChartPainter().getStyleManager().isYAxisLogarithmic()) { if (getChartPainter().getStyleManager().isYAxisLogarithmic()) {
y = new BigDecimal(Math.log10(yOrig.doubleValue())); y = new BigDecimal(Math.log10(yOrig.doubleValue()));
} else { }
else {
y = new BigDecimal(yOrig.doubleValue()); y = new BigDecimal(yOrig.doubleValue());
} }
...@@ -180,16 +183,12 @@ public class PlotContentLineChart extends PlotContent { ...@@ -180,16 +183,12 @@ public class PlotContentLineChart extends PlotContent {
// paint area // paint area
if (getChartPainter().getStyleManager().getChartType() == ChartType.Area) { if (getChartPainter().getStyleManager().getChartType() == ChartType.Area) {
if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) { if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) {
g.setColor(series.getStrokeColor()); g.setColor(series.getStrokeColor());
double yBottomOfArea = bounds.getY() + bounds.getHeight() - yTopMargin + 1; double yBottomOfArea = bounds.getY() + bounds.getHeight() - yTopMargin + 1;
// if the new x value is smaller than the previous one, close the current path
if (xOffset < previousX) {
closePath(g, path, previousX, bounds, yTopMargin);
path = null;
}
if (path == null) { if (path == null) {
path = new Path2D.Double(); path = new Path2D.Double();
path.moveTo(previousX, yBottomOfArea); path.moveTo(previousX, yBottomOfArea);
...@@ -219,7 +218,8 @@ public class PlotContentLineChart extends PlotContent { ...@@ -219,7 +218,8 @@ public class PlotContentLineChart extends PlotContent {
if (getChartPainter().getStyleManager().isYAxisLogarithmic()) { if (getChartPainter().getStyleManager().isYAxisLogarithmic()) {
topValue = yOrig.add(eb); topValue = yOrig.add(eb);
topValue = new BigDecimal(Math.log10(topValue.doubleValue())); topValue = new BigDecimal(Math.log10(topValue.doubleValue()));
} else { }
else {
topValue = y.add(eb); topValue = y.add(eb);
} }
double topEBTransform = bounds.getHeight() - (yTopMargin + topValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace); double topEBTransform = bounds.getHeight() - (yTopMargin + topValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace);
...@@ -230,7 +230,8 @@ public class PlotContentLineChart extends PlotContent { ...@@ -230,7 +230,8 @@ public class PlotContentLineChart extends PlotContent {
bottomValue = yOrig.subtract(eb); bottomValue = yOrig.subtract(eb);
// System.out.println(bottomValue); // System.out.println(bottomValue);
bottomValue = new BigDecimal(Math.log10(bottomValue.doubleValue())); bottomValue = new BigDecimal(Math.log10(bottomValue.doubleValue()));
} else { }
else {
bottomValue = y.subtract(eb); bottomValue = y.subtract(eb);
} }
double bottomEBTransform = bounds.getHeight() - (yTopMargin + bottomValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace); double bottomEBTransform = bounds.getHeight() - (yTopMargin + bottomValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace);
...@@ -254,6 +255,7 @@ public class PlotContentLineChart extends PlotContent { ...@@ -254,6 +255,7 @@ public class PlotContentLineChart extends PlotContent {
* Closes a path for area charts if one is available. * Closes a path for area charts if one is available.
*/ */
private void closePath(Graphics2D g, Path2D.Double path, double previousX, Rectangle2D bounds, double yTopMargin) { private void closePath(Graphics2D g, Path2D.Double path, double previousX, Rectangle2D bounds, double yTopMargin) {
if (path != null) { if (path != null) {
double yBottomOfArea = bounds.getY() + bounds.getHeight() - yTopMargin + 1; double yBottomOfArea = bounds.getY() + bounds.getHeight() - yTopMargin + 1;
path.lineTo(previousX, yBottomOfArea); path.lineTo(previousX, yBottomOfArea);
...@@ -261,4 +263,5 @@ public class PlotContentLineChart extends PlotContent { ...@@ -261,4 +263,5 @@ public class PlotContentLineChart extends PlotContent {
g.fill(path); g.fill(path);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment