diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java index c44f3b490ca7a1f54f5876769166e4fd63507e79..1d2a4a9d35c333ef1b2fa8a1991aabe0a18a8fd8 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java @@ -39,7 +39,7 @@ public class AxisTick implements ChartPart { /** the bounds */ private Rectangle2D bounds = new Rectangle2D.Double(); - AxisTickCalculator gridStep = null; + AxisTickCalculator axisTickCalculator = null; /** * Constructor @@ -74,27 +74,27 @@ public class AxisTick implements ChartPart { if (axis.getDirection() == Axis.Direction.X && getChartPainter().getStyleManager().getChartType() == ChartType.Bar) { - gridStep = new AxisTickBarChartCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter()); + axisTickCalculator = new AxisTickBarChartCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter()); } else if (axis.getDirection() == Axis.Direction.X && getChartPainter().getStyleManager().isXAxisLogarithmic() && axis.getAxisType() != AxisType.Date) { - gridStep = new AxisTickLogarithmicCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); + axisTickCalculator = new AxisTickLogarithmicCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); } else if (axis.getDirection() == Axis.Direction.Y && getChartPainter().getStyleManager().isYAxisLogarithmic() && axis.getAxisType() != AxisType.Date) { - gridStep = new AxisTickLogarithmicCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); + axisTickCalculator = new AxisTickLogarithmicCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); } else if (axis.getAxisType() == AxisType.Number) { - gridStep = new AxisTickNumericalCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); + axisTickCalculator = new AxisTickNumericalCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); } else if (axis.getAxisType() == AxisType.Date) { - gridStep = new AxisTickDateCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); + axisTickCalculator = new AxisTickDateCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChartPainter().getStyleManager()); } @@ -154,11 +154,11 @@ public class AxisTick implements ChartPart { public List<Double> getTickLocations() { - return gridStep.getTickLocations(); + return axisTickCalculator.getTickLocations(); } public List<String> getTickLabels() { - return gridStep.getTickLabels(); + return axisTickCalculator.getTickLabels(); } } diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickBarChartCalculator.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickBarChartCalculator.java index 6d64fa151f42ad59af0ade8adb365fd9a13aa775..422bc51bd6f25ea88c16d49a1c3457f7b470ace8 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickBarChartCalculator.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickBarChartCalculator.java @@ -147,7 +147,7 @@ public class AxisTickBarChartCalculator extends AxisTickCalculator { dateFormatter = new DateFormatter(chartPainter.getStyleManager()); } - for (double tickPosition = firstPosition; tickPosition <= maxValue; tickPosition = tickPosition + gridStep) { + for (double tickPosition = firstPosition; tickPosition <= maxValue + 2 * gridStep; tickPosition = tickPosition + gridStep) { if (chartPainter.getAxisPair().getXAxis().getAxisType() == AxisType.Number) { tickLabels.add(numberFormatter.formatNumber(BigDecimal.valueOf(tickPosition), minValue, maxValue)); diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java index f75fa3670571d8f4e0e1e98efdcc8303b37bb994..a36884dd4a4458f229383bacbef602fa5fd60f78 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickCalculator.java @@ -102,11 +102,12 @@ public abstract class AxisTickCalculator { // System.out.println("******"); - double firstPosition = minValue - (minValue % gridStep) + gridStep; - - if ((firstPosition - minValue) > gridStep) { - firstPosition = minValue - (minValue % gridStep); - } + // double firstPosition = minValue - (minValue % gridStep) + gridStep; + double firstPosition = minValue - (minValue % gridStep) - gridStep; + // + // if ((firstPosition - minValue) > gridStep) { + // firstPosition = minValue - (minValue % gridStep); + // } return firstPosition; } diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickDateCalculator.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickDateCalculator.java index 4e2a3f220b82bdb2c9ab7ee21b071be6d1a706e3..89963ba2d0546affc216fe29b2756b59a468fa60 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickDateCalculator.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickDateCalculator.java @@ -21,7 +21,7 @@ import com.xeiam.xchart.internal.chartpart.Axis.Direction; /** * This class encapsulates the logic to generate the axis tick mark and axis tick label data for rendering the axis ticks for date axes - * + * * @author timmolter */ public class AxisTickDateCalculator extends AxisTickCalculator { @@ -30,7 +30,7 @@ public class AxisTickDateCalculator extends AxisTickCalculator { /** * Constructor - * + * * @param axisDirection * @param workingSpace * @param minValue @@ -70,7 +70,7 @@ public class AxisTickDateCalculator extends AxisTickCalculator { double firstPosition = getFirstPosition(gridStep); // generate all tickLabels and tickLocations from the first to last position - for (double tickPosition = firstPosition; tickPosition <= maxValue; tickPosition = tickPosition + gridStep) { + for (double tickPosition = firstPosition; tickPosition <= maxValue + 2 * gridStep; tickPosition = tickPosition + gridStep) { tickLabels.add(dateFormatter.formatDate(tickPosition, timeUnit)); // here we convert tickPosition finally to plot space, i.e. pixels diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java index 095345667cdf7e46891294f763d256d5b7077c0b..a9d308043bc1601bae75352a57a3bf246bbfc8cf 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java @@ -35,7 +35,7 @@ public class AxisTickLabels implements ChartPart { /** * Constructor - * + * * @param axisTick */ protected AxisTickLabels(AxisTick axisTick) { @@ -60,31 +60,27 @@ public class AxisTickLabels implements ChartPart { double xOffset = axisTick.getAxis().getAxisTitle().getBounds().getX() + axisTick.getAxis().getAxisTitle().getBounds().getWidth(); double yOffset = axisTick.getAxis().getPaintZone().getY(); + double height = axisTick.getAxis().getPaintZone().getHeight(); double maxTickLabelWidth = 0; + for (int i = 0; i < axisTick.getTickLabels().size(); i++) { String tickLabel = axisTick.getTickLabels().get(i); // System.out.println(tickLabel); double tickLocation = axisTick.getTickLocations().get(i); + double flippedTickLocation = yOffset + height - tickLocation; - if (tickLabel != null) { // some are null for logarithmic axes - - // AffineTransform orig = g.getTransform(); - // AffineTransform at = new AffineTransform(); - // at.rotate(Math.PI / -2.0, xOffset, (float) (yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation / 2.0)); - // g.transform(at); + if (tickLabel != null && flippedTickLocation > yOffset && flippedTickLocation < yOffset + height) { // some are null for logarithmic axes FontRenderContext frc = g.getFontRenderContext(); - // TextLayout layout = new TextLayout(tickLabel, font, new FontRenderContext(null, true, false)); TextLayout layout = new TextLayout(tickLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), frc); Rectangle2D tickLabelBounds = layout.getBounds(); - // layout.draw(g, (float) xOffset, (float) (yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0)); Shape shape = layout.getOutline(null); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); - at.translate(xOffset, yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0); + at.translate(xOffset, flippedTickLocation + tickLabelBounds.getHeight() / 2.0); g.transform(at); g.fill(shape); g.setTransform(orig); @@ -97,7 +93,7 @@ public class AxisTickLabels implements ChartPart { } // bounds - bounds = new Rectangle2D.Double(xOffset, yOffset, maxTickLabelWidth, axisTick.getAxis().getPaintZone().getHeight()); + bounds = new Rectangle2D.Double(xOffset, yOffset, maxTickLabelWidth, height); // g.setColor(Color.blue); // g.draw(bounds); @@ -106,6 +102,7 @@ public class AxisTickLabels implements ChartPart { double xOffset = axisTick.getAxis().getPaintZone().getX(); double yOffset = axisTick.getAxis().getAxisTitle().getBounds().getY(); + double width = axisTick.getAxis().getPaintZone().getWidth(); double maxTickLabelHeight = 0; // System.out.println("axisTick.getTickLabels().size(): " + axisTick.getTickLabels().size()); @@ -114,11 +111,12 @@ public class AxisTickLabels implements ChartPart { String tickLabel = axisTick.getTickLabels().get(i); // System.out.println("tickLabel: " + tickLabel); double tickLocation = axisTick.getTickLocations().get(i); + double shiftedTickLocation = xOffset + tickLocation; + + if (tickLabel != null && shiftedTickLocation > xOffset && shiftedTickLocation < xOffset + width) { // some are null for logarithmic axes - if (tickLabel != null) { // some are null for logarithmic axes FontRenderContext frc = g.getFontRenderContext(); TextLayout textLayout = new TextLayout(tickLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), frc); - // GlyphVector v = getChartPainter().getStyleManager().getAxisTickLabelsFont().createGlyphVector(frc, tickLabel); // Shape shape = v.getOutline(); Shape shape = textLayout.getOutline(null); @@ -126,7 +124,7 @@ public class AxisTickLabels implements ChartPart { AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); - at.translate(xOffset + tickLocation - tickLabelBounds.getWidth() / 2.0, yOffset); + at.translate(shiftedTickLocation - tickLabelBounds.getWidth() / 2.0, yOffset); g.transform(at); g.fill(shape); g.setTransform(orig); @@ -142,7 +140,7 @@ public class AxisTickLabels implements ChartPart { } // bounds - bounds = new Rectangle2D.Double(xOffset, yOffset - maxTickLabelHeight, axisTick.getAxis().getPaintZone().getWidth(), maxTickLabelHeight); + bounds = new Rectangle2D.Double(xOffset, yOffset - maxTickLabelHeight, width, maxTickLabelHeight); // g.setColor(Color.blue); // g.draw(bounds); diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickMarks.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickMarks.java index 9dc312310dfbc8aebc6b3cec8e6d9874d1b33a18..6d913bf40e6d7d0fb0ea3321a1eefe95303512f0 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickMarks.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickMarks.java @@ -33,7 +33,7 @@ public class AxisTickMarks implements ChartPart { /** * Constructor - * + * * @param axisTick */ protected AxisTickMarks(AxisTick axisTick) { @@ -58,20 +58,26 @@ public class AxisTickMarks implements ChartPart { double xOffset = axisTick.getAxisTickLabels().getBounds().getX() + axisTick.getAxisTickLabels().getBounds().getWidth() + getChartPainter().getStyleManager().getAxisTickPadding(); double yOffset = axisTick.getAxis().getPaintZone().getY(); + // bounds + bounds = new Rectangle2D.Double(xOffset, yOffset, getChartPainter().getStyleManager().getAxisTickMarkLength(), axisTick.getAxis().getPaintZone().getHeight()); + // g.setColor(Color.yellow); + // g.draw(bounds); + // tick marks if (getChartPainter().getStyleManager().isAxisTicksMarksVisible()) { for (int i = 0; i < axisTick.getTickLabels().size(); i++) { double tickLocation = axisTick.getTickLocations().get(i); + double flippedTickLocation = yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation; + if (flippedTickLocation > bounds.getY() && flippedTickLocation < bounds.getY() + bounds.getHeight()) { - Shape line = - new Line2D.Double(xOffset, yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation, xOffset + getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset - + axisTick.getAxis().getPaintZone().getHeight() - tickLocation); - g.draw(line); - + Shape line = new Line2D.Double(xOffset, flippedTickLocation, xOffset + getChartPainter().getStyleManager().getAxisTickMarkLength(), flippedTickLocation); + g.draw(line); + } } } + // Line if (getChartPainter().getStyleManager().isAxisTicksLineVisible()) { @@ -82,28 +88,35 @@ public class AxisTickMarks implements ChartPart { } - // bounds - bounds = new Rectangle2D.Double(xOffset, yOffset, getChartPainter().getStyleManager().getAxisTickMarkLength(), axisTick.getAxis().getPaintZone().getHeight()); - // g.setColor(Color.yellow); - // g.draw(bounds); - } else if (axisTick.getAxis().getDirection() == Axis.Direction.X && getChartPainter().getStyleManager().isXAxisTicksVisible()) { // X-Axis double xOffset = axisTick.getAxis().getPaintZone().getX(); double yOffset = axisTick.getAxisTickLabels().getBounds().getY() - getChartPainter().getStyleManager().getAxisTickPadding(); + // bounds + bounds = + new Rectangle2D.Double(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength(), axisTick.getAxis().getPaintZone().getWidth(), getChartPainter().getStyleManager() + .getAxisTickMarkLength()); + // g.setColor(Color.yellow); + // g.draw(bounds); + // tick marks if (getChartPainter().getStyleManager().isAxisTicksMarksVisible()) { for (int i = 0; i < axisTick.getTickLabels().size(); i++) { double tickLocation = axisTick.getTickLocations().get(i); + double shiftedTickLocation = xOffset + tickLocation; + + if (shiftedTickLocation > bounds.getX() && shiftedTickLocation < bounds.getX() + bounds.getWidth()) { - Shape line = new Line2D.Double(xOffset + tickLocation, yOffset, xOffset + tickLocation, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength()); - g.draw(line); + Shape line = new Line2D.Double(shiftedTickLocation, yOffset, xOffset + tickLocation, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength()); + g.draw(line); + } } } + // Line if (getChartPainter().getStyleManager().isAxisTicksLineVisible()) { @@ -113,12 +126,6 @@ public class AxisTickMarks implements ChartPart { g.draw(line); } - // bounds - bounds = - new Rectangle2D.Double(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength(), axisTick.getAxis().getPaintZone().getWidth(), getChartPainter().getStyleManager() - .getAxisTickMarkLength()); - // g.setColor(Color.yellow); - // g.draw(bounds); } } diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java index 53b925b4a51605fe048bcbef7f86c8afa1961f90..dffe6f11d5e6f499460ef3e1a555c813983fbee2 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickNumericalCalculator.java @@ -72,7 +72,7 @@ public class AxisTickNumericalCalculator extends AxisTickCalculator { // System.out.println("scaledfirstPosition: " + cleanedFirstPosition); // generate all tickLabels and tickLocations from the first to last position - for (BigDecimal tickPosition = cleanedFirstPosition; tickPosition.compareTo(BigDecimal.valueOf(maxValue)) < 0; tickPosition = tickPosition.add(cleanedGridStep)) { + for (BigDecimal tickPosition = cleanedFirstPosition; tickPosition.compareTo(BigDecimal.valueOf(maxValue + 2 * cleanedGridStep.doubleValue())) < 0; tickPosition = tickPosition.add(cleanedGridStep)) { tickLabels.add(numberFormatter.formatNumber(tickPosition, minValue, maxValue)); // here we convert tickPosition finally to plot space, i.e. pixels diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartPainter.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartPainter.java index ccc1e09db98bca490120d4e092cdf6fb625c5174..dcc231fe169dee18fec55e04db62988f56c623fb 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartPainter.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartPainter.java @@ -41,7 +41,7 @@ public class ChartPainter { /** * Constructor - * + * * @param width * @param height */ @@ -117,7 +117,7 @@ public class ChartPainter { /** * for internal usage - * + * * @return */ public ChartTitle getChartTitle() { @@ -127,7 +127,7 @@ public class ChartPainter { /** * for internal usage - * + * * @return */ public Legend getChartLegend() { @@ -137,7 +137,7 @@ public class ChartPainter { /** * for internal usage - * + * * @return */ public AxisPair getAxisPair() { @@ -147,7 +147,7 @@ public class ChartPainter { /** * for internal usage - * + * * @return */ public Plot getPlot() { @@ -167,7 +167,7 @@ public class ChartPainter { /** * Gets the Chart's style manager, which can be used to customize the Chart's appearance - * + * * @return the style manager */ public StyleManager getStyleManager() { diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java index 5580d85bc1e92315a9276d4aa5901fd90e7a138a..c36dbebba04db8774bc34c5957d8fb54d2837ac7 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotSurface.java @@ -24,6 +24,8 @@ import java.util.List; import com.xeiam.xchart.StyleManager.ChartType; /** + * Draws the plot background, the plot border and the horizontal and vertical grid lines + * * @author timmolter */ public class PlotSurface implements ChartPart { @@ -33,7 +35,7 @@ public class PlotSurface implements ChartPart { /** * Constructor - * + * * @param plot */ protected PlotSurface(Plot plot) { @@ -70,26 +72,28 @@ public class PlotSurface implements ChartPart { List<Double> yAxisTickLocations = getChartPainter().getAxisPair().getYAxis().getAxisTick().getTickLocations(); for (int i = 0; i < yAxisTickLocations.size(); i++) { - double tickLocation = yAxisTickLocations.get(i); - double yOffset = bounds.getY() + bounds.getHeight() - tickLocation; + double yOffset = bounds.getY() + bounds.getHeight() - yAxisTickLocations.get(i); - // draw lines - if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { + if (yOffset > bounds.getY() && yOffset < bounds.getY() + bounds.getHeight()) { - g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor()); - g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke()); - Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + bounds.getWidth(), yOffset); - g.draw(line); - } - // tick marks - if (getChartPainter().getStyleManager().isPlotTicksMarksVisible()) { - - g.setColor(getChartPainter().getStyleManager().getAxisTickMarksColor()); - g.setStroke(getChartPainter().getStyleManager().getAxisTickMarksStroke()); - Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset); - g.draw(line); - line = new Line2D.Double(bounds.getX() + bounds.getWidth(), yOffset, bounds.getX() + bounds.getWidth() - getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset); - g.draw(line); + // draw lines + if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { + + g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor()); + g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke()); + Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + bounds.getWidth(), yOffset); + g.draw(line); + } + // tick marks + if (getChartPainter().getStyleManager().isPlotTicksMarksVisible()) { + + g.setColor(getChartPainter().getStyleManager().getAxisTickMarksColor()); + g.setStroke(getChartPainter().getStyleManager().getAxisTickMarksStroke()); + Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset); + g.draw(line); + line = new Line2D.Double(bounds.getX() + bounds.getWidth(), yOffset, bounds.getX() + bounds.getWidth() - getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset); + g.draw(line); + } } } @@ -108,24 +112,27 @@ public class PlotSurface implements ChartPart { double tickLocation = xAxisTickLocations.get(i); double xOffset = bounds.getX() + tickLocation; - // draw lines - if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { - g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor()); - g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke()); + if (xOffset > bounds.getX() && xOffset < bounds.getX() + bounds.getWidth()) { - Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + bounds.getHeight()); - g.draw(line); - } - // tick marks - if (getChartPainter().getStyleManager().isPlotTicksMarksVisible()) { + // draw lines + if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { + g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor()); + g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke()); - g.setColor(getChartPainter().getStyleManager().getAxisTickMarksColor()); - g.setStroke(getChartPainter().getStyleManager().getAxisTickMarksStroke()); + Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + bounds.getHeight()); + g.draw(line); + } + // tick marks + if (getChartPainter().getStyleManager().isPlotTicksMarksVisible()) { - Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + getChartPainter().getStyleManager().getAxisTickMarkLength()); - g.draw(line); - line = new Line2D.Double(xOffset, bounds.getY() + bounds.getHeight(), xOffset, bounds.getY() + bounds.getHeight() - getChartPainter().getStyleManager().getAxisTickMarkLength()); - g.draw(line); + g.setColor(getChartPainter().getStyleManager().getAxisTickMarksColor()); + g.setStroke(getChartPainter().getStyleManager().getAxisTickMarksStroke()); + + Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + getChartPainter().getStyleManager().getAxisTickMarkLength()); + g.draw(line); + line = new Line2D.Double(xOffset, bounds.getY() + bounds.getHeight(), xOffset, bounds.getY() + bounds.getHeight() - getChartPainter().getStyleManager().getAxisTickMarkLength()); + g.draw(line); + } } } }