From 206c149a608be223f6985697788704a7c7b9b0af Mon Sep 17 00:00:00 2001 From: Tim Molter <tim@knowm.org> Date: Sat, 2 Jan 2016 12:14:07 +0100 Subject: [PATCH] misc. cleanup --- .../xchart/internal/chartpart/AxisTick.java | 37 ++++++++++++------- .../PlotContentCategoricalChart.java | 6 +-- .../chartpart/PlotContentNumericalChart.java | 2 +- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java index be540b5c..469d10c0 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java @@ -57,18 +57,18 @@ public class AxisTick implements ChartPart { @Override public void paint(Graphics2D g) { - double workingSpace = 0.0; - // Y-Axis - if (axis.getDirection() == Axis.Direction.Y) { - workingSpace = axis.getPaintZone().getHeight(); // number of pixels the axis has to work with for drawing AxisTicks - // System.out.println("workingspace= " + workingSpace); - } - // X-Axis - else if (axis.getDirection() == Axis.Direction.X) { - workingSpace = axis.getPaintZone().getWidth(); // number of pixels the axis has to work with for drawing AxisTicks - // System.out.println("workingspace= " + workingSpace); - } - + // double workingSpace = 0.0; + // // Y-Axis + // if (axis.getDirection() == Axis.Direction.Y) { + // workingSpace = axis.getPaintZone().getHeight(); // number of pixels the axis has to work with for drawing AxisTicks + // // System.out.println("workingspace= " + workingSpace); + // } + // // X-Axis + // else if (axis.getDirection() == Axis.Direction.X) { + // workingSpace = axis.getPaintZone().getWidth(); // number of pixels the axis has to work with for drawing AxisTicks + // // System.out.println("workingspace= " + workingSpace); + // } + // // System.out.println("AxisTick: " + axis.getDirection()); // System.out.println("workingSpace: " + workingSpace); @@ -98,8 +98,17 @@ public class AxisTick implements ChartPart { axisTickLabels.paint(g); axisTickMarks.paint(g); - bounds = new Rectangle2D.Double(axisTickMarks.getBounds().getX(), axisTickMarks.getBounds().getY(), axisTickLabels.getBounds().getWidth(), axisTickMarks.getBounds().getHeight() - + getChartInternal().getStyleManager().getAxisTickPadding() + axisTickLabels.getBounds().getHeight()); + bounds = new Rectangle2D.Double( + + axisTickMarks.getBounds().getX(), + + axisTickMarks.getBounds().getY(), + + axisTickLabels.getBounds().getWidth(), + + axisTickMarks.getBounds().getHeight() + getChartInternal().getStyleManager().getAxisTickPadding() + axisTickLabels.getBounds().getHeight() + + ); // g.setColor(Color.red); // g.draw(bounds); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentCategoricalChart.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentCategoricalChart.java index 3f1f88f2..af0a421f 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentCategoricalChart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentCategoricalChart.java @@ -53,7 +53,7 @@ public class PlotContentCategoricalChart extends PlotContent { // g.setColor(Color.red); // g.draw(bounds); - StyleManager styleManager = plot.getChartInternal().getStyleManager(); + StyleManager styleManager = getChartInternal().getStyleManager(); // this is for preventing the series to be drawn outside the plot area if min and max is overridden to fall inside the data range Rectangle rectangle = new Rectangle(0, 0, getChartInternal().getWidth(), getChartInternal().getHeight()); @@ -70,8 +70,8 @@ public class PlotContentCategoricalChart extends PlotContent { double yTickSpace = styleManager.getAxisTickSpacePercentage() * bounds.getHeight(); double yTopMargin = Utils.getTickStartOffset(bounds.getHeight(), yTickSpace); - int numBars = getChartInternal().getSeriesMap().values().iterator().next().getXData().size(); - double gridStep = xTickSpace / numBars; + int numCategories = getChartInternal().getSeriesMap().values().iterator().next().getXData().size(); + double gridStep = xTickSpace / numCategories; // plot series int seriesCounter = 0; diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentNumericalChart.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentNumericalChart.java index 64013cac..468df772 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentNumericalChart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContentNumericalChart.java @@ -59,7 +59,7 @@ public class PlotContentNumericalChart extends PlotContent { return; } - StyleManager styleManager = plot.getChartInternal().getStyleManager(); + StyleManager styleManager = getChartInternal().getStyleManager(); // this is for preventing the series to be drawn outside the plot area if min and max is overridden to fall inside the data range -- GitLab