diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java index 49ac9f0fbaf375f71b1cb249064ef9bf91d8e8f8..e3e91564be8b8c6f69b842659d2b45d4dc17858a 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java @@ -179,7 +179,7 @@ public class Axis implements ChartPart { xOffset = paintZone.getX(); yOffset = paintZone.getY(); - width = (getChartPainter().getStyleManager().isYAxisTitleVisible() ? axisTitle.getBounds().getWidth() : 0) + (int) axisTick.getBounds().getWidth(); + width = (getChartPainter().getStyleManager().isYAxisTitleVisible() ? axisTitle.getBounds().getWidth() : 0) + axisTick.getBounds().getWidth(); height = paintZone.getHeight(); bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); @@ -191,9 +191,9 @@ public class Axis implements ChartPart { // calculate paint zone // |____________________| - double xOffset = (int) (axisPair.getyAxis().getBounds().getWidth() + (getChartPainter().getStyleManager().isYAxisTicksVisible() ? getChartPainter().getStyleManager().getPlotPadding() : 0) + getChartPainter() - .getStyleManager().getChartPadding()); - double yOffset = (int) (axisPair.getyAxis().getBounds().getY() + axisPair.getyAxis().getBounds().getHeight() + getChartPainter().getStyleManager().getPlotPadding()); + double xOffset = axisPair.getyAxis().getBounds().getWidth() + (getChartPainter().getStyleManager().isYAxisTicksVisible() ? getChartPainter().getStyleManager().getPlotPadding() : 0) + + getChartPainter().getStyleManager().getChartPadding(); + double yOffset = axisPair.getyAxis().getBounds().getY() + axisPair.getyAxis().getBounds().getHeight() + getChartPainter().getStyleManager().getPlotPadding(); double chartLegendWidth = 0; if (getChartPainter().getStyleManager().getLegendPosition() == LegendPosition.OutsideE) { @@ -231,7 +231,7 @@ public class Axis implements ChartPart { xOffset = paintZone.getX(); yOffset = paintZone.getY(); width = paintZone.getWidth(); - height = (getChartPainter().getStyleManager().isXAxisTitleVisible() ? axisTitle.getBounds().getHeight() : 0) + (int) axisTick.getBounds().getHeight(); + height = (getChartPainter().getStyleManager().isXAxisTitleVisible() ? axisTitle.getBounds().getHeight() : 0) + axisTick.getBounds().getHeight(); bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); // g.setColor(Color.yellow); // g.draw(bounds); 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 d91f18a31a70412c9b63538eeed184762189dfb2..14d2cba906588f7e8efcd697d6cbabc2805936ac 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 @@ -73,20 +73,20 @@ public class AxisTickLabels implements ChartPart { layout.draw(g, (float) xOffset, (float) (yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0)); if (tickLabelBounds.getWidth() > maxTickLabelWidth) { - maxTickLabelWidth = (int) tickLabelBounds.getWidth(); + maxTickLabelWidth = tickLabelBounds.getWidth(); } } } // bounds - bounds = new Rectangle2D.Double(xOffset, yOffset, maxTickLabelWidth, (int) axisTick.getAxis().getPaintZone().getHeight()); + bounds = new Rectangle2D.Double(xOffset, yOffset, maxTickLabelWidth, axisTick.getAxis().getPaintZone().getHeight()); // g.setColor(Color.blue); // g.draw(bounds); } else if (axisTick.getAxis().getDirection() == Axis.Direction.X && getChartPainter().getStyleManager().isXAxisTicksVisible()) { // X-Axis - double xOffset = (int) (axisTick.getAxis().getPaintZone().getX()); - double yOffset = (int) (axisTick.getAxis().getAxisTitle().getBounds().getY()); + double xOffset = axisTick.getAxis().getPaintZone().getX(); + double yOffset = axisTick.getAxis().getAxisTitle().getBounds().getY(); double maxTickLabelHeight = 0; for (int i = 0; i < axisTick.getTickLabels().size(); i++) { @@ -100,7 +100,7 @@ public class AxisTickLabels implements ChartPart { layout.draw(g, (float) (xOffset + tickLocation - tickLabelBounds.getWidth() / 2.0), (float) yOffset); if (tickLabelBounds.getHeight() > maxTickLabelHeight) { - maxTickLabelHeight = (int) tickLabelBounds.getHeight(); + maxTickLabelHeight = tickLabelBounds.getHeight(); } } } 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 e876d4ca65701f7d65ec677b08061f5707f43104..cdeedc3fc04bd19cf0829ace0aedd2c9c725eb1a 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 @@ -65,15 +65,10 @@ public class AxisTickMarks implements ChartPart { int tickLocation = axisTick.getTickLocations().get(i); - // g.setColor(getChart().getStyleManager().getChartBordersColor()); - // g.setStroke(stroke); 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); - // g.drawLine(xOffset, yOffset + (int) (axisTick.getAxis().getPaintZone().getHeight() - tickLocation), xOffset + getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset - // + (int) (axisTick.getAxis().getPaintZone().getHeight() - tickLocation)); - } } // Line @@ -83,19 +78,16 @@ public class AxisTickMarks implements ChartPart { + axisTick.getAxis().getPaintZone().getHeight()); g.draw(line); - // g.drawLine(xOffset + getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset, xOffset + getChartPainter().getStyleManager().getAxisTickMarkLength(), yOffset - // + (int) axisTick.getAxis().getPaintZone().getHeight()); } // bounds - bounds = new Rectangle2D.Double(xOffset, yOffset, getChartPainter().getStyleManager().getAxisTickMarkLength(), (int) axisTick.getAxis().getPaintZone().getHeight()); + 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(); - // int yOffset = (int) (axisTick.getAxisTickLabels().getBounds().getY() - getChart().getStyleManager().getAxisTickPadding()); double yOffset = axisTick.getAxisTickLabels().getBounds().getY() - getChartPainter().getStyleManager().getAxisTickPadding(); // tick marks diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartTitle.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartTitle.java index 77ca627aa5e5c731ee5db4daba391ba7ac97e6a8..0e68beace09213e1e50a17ad95a9a9b185794ebe 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartTitle.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartTitle.java @@ -97,8 +97,8 @@ public class ChartTitle implements ChartPart { if (chartPainter.getStyleManager().isChartTitleBoxVisible()) { // paint the chart title box - int chartTitleBoxWidth = (int) chartPainter.getPlot().getBounds().getWidth(); - int chartTitleBoxHeight = (int) (rectangle.getHeight() + 2 * chartPainter.getStyleManager().getChartTitlePadding()); + double chartTitleBoxWidth = chartPainter.getPlot().getBounds().getWidth(); + double chartTitleBoxHeight = rectangle.getHeight() + 2 * chartPainter.getStyleManager().getChartTitlePadding(); g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); Shape rect = new Rectangle2D.Double(xOffset, yOffset, chartTitleBoxWidth, chartTitleBoxHeight); diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java index 89de73a87573103f05c704f5bff9126eea0bee16..0f56d50e7fa21a644ea080b235f1d9cfaf725e27 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java @@ -92,7 +92,7 @@ public class Legend implements ChartPart { // determine legend content width double legendContentWidth = 0; if (getChartPainter().getStyleManager().getChartType() != ChartType.Bar) { - legendContentWidth = (int) (3.0 * Marker.SIZE + chartPainter.getStyleManager().getLegendPadding() + legendTextContentMaxWidth); + legendContentWidth = 3.0 * Marker.SIZE + chartPainter.getStyleManager().getLegendPadding() + legendTextContentMaxWidth; } else { legendContentWidth = BOX_SIZE + chartPainter.getStyleManager().getLegendPadding() + legendTextContentMaxWidth; } @@ -173,7 +173,7 @@ public class Legend implements ChartPart { // paint marker if (series.getMarker() != null) { g.setColor(series.getMarkerColor()); - series.getMarker().paint(g, (int) (startx + (Marker.SIZE * 1.5)), (int) (starty + maxContentHeight / 2.0)); + series.getMarker().paint(g, startx + (Marker.SIZE * 1.5), starty + maxContentHeight / 2.0); } } else { // paint little box @@ -194,7 +194,7 @@ public class Legend implements ChartPart { } else { layout.draw(g, (float) (startx + BOX_SIZE + chartPainter.getStyleManager().getLegendPadding()), (float) (starty + (maxContentHeight + layout.getBounds().getHeight()) / 2.0)); } - starty = (int) (starty + maxContentHeight + chartPainter.getStyleManager().getLegendPadding()); + starty = starty + maxContentHeight + chartPainter.getStyleManager().getLegendPadding(); } // bounds diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentLineChart.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentLineChart.java index 493d3aa48ccf75a239da08df958cc025276db816..27cccf26c37daa4e8a56394f5ef6ef6688ed0d32 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentLineChart.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentLineChart.java @@ -143,17 +143,17 @@ public class PlotContentLineChart extends PlotContent { y = new BigDecimal(yOrig.doubleValue()); } - int xTransform = (int) (xLeftMargin + (x.subtract(xMin).doubleValue() / xMax.subtract(xMin).doubleValue() * xTickSpace)); - int yTransform = (int) (bounds.getHeight() - (yTopMargin + y.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace)); + double xTransform = xLeftMargin + (x.subtract(xMin).doubleValue() / xMax.subtract(xMin).doubleValue() * xTickSpace); + double yTransform = bounds.getHeight() - (yTopMargin + y.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace); // a check if all x data are the exact same values if (Math.abs(xMax.subtract(xMin).doubleValue()) / 5 == 0.0) { - xTransform = (int) (bounds.getWidth() / 2.0); + xTransform = bounds.getWidth() / 2.0; } // a check if all y data are the exact same values if (Math.abs(yMax.subtract(yMin).doubleValue()) / 5 == 0.0) { - yTransform = (int) (bounds.getHeight() / 2.0); + yTransform = bounds.getHeight() / 2.0; } double xOffset = bounds.getX() + xTransform - 1; @@ -176,7 +176,7 @@ public class PlotContentLineChart extends PlotContent { if (getChartPainter().getStyleManager().getChartType() == ChartType.Area) { if (previousX != Integer.MIN_VALUE && previousY != Integer.MIN_VALUE) { g.setColor(series.getStrokeColor()); - int yBottomOfArea = (int) (bounds.getY() + bounds.getHeight() - yTopMargin + 1); + double yBottomOfArea = bounds.getY() + bounds.getHeight() - yTopMargin + 1; Path2D.Double path = new Path2D.Double(); path.moveTo(previousX, previousY); @@ -210,8 +210,8 @@ public class PlotContentLineChart extends PlotContent { } else { topValue = y.add(eb); } - int topEBTransform = (int) (bounds.getHeight() - (yTopMargin + topValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace)); - int topEBOffset = (int) (bounds.getY() + topEBTransform); + double topEBTransform = bounds.getHeight() - (yTopMargin + topValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace); + double topEBOffset = bounds.getY() + topEBTransform; BigDecimal bottomValue = null; if (getChartPainter().getStyleManager().isYAxisLogarithmic()) { @@ -221,8 +221,8 @@ public class PlotContentLineChart extends PlotContent { } else { bottomValue = y.subtract(eb); } - int bottomEBTransform = (int) (bounds.getHeight() - (yTopMargin + bottomValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace)); - int bottomEBOffset = (int) (bounds.getY() + bottomEBTransform); + double bottomEBTransform = bounds.getHeight() - (yTopMargin + bottomValue.subtract(yMin).doubleValue() / yMax.subtract(yMin).doubleValue() * yTickSpace); + double bottomEBOffset = bounds.getY() + bottomEBTransform; Shape line = new Line2D.Double(xOffset, topEBOffset, xOffset, bottomEBOffset); g.draw(line); 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 1cde8841717cf96d03d7c0711c371dab5e636914..ef5ceb84c2e2de04cd6c4150beea8106a1c67982 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 @@ -70,15 +70,15 @@ public class PlotSurface implements ChartPart { List<Integer> yAxisTickLocations = getChartPainter().getAxisPair().getyAxis().getAxisTick().getTickLocations(); for (int i = 0; i < yAxisTickLocations.size(); i++) { - int tickLocation = yAxisTickLocations.get(i); - int yOffset = (int) (bounds.getY() + bounds.getHeight() - tickLocation); + double tickLocation = yAxisTickLocations.get(i); + double yOffset = bounds.getY() + bounds.getHeight() - tickLocation; // draw lines if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor()); g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke()); - Shape line = new Line2D.Double((int) bounds.getX(), yOffset, bounds.getX() + bounds.getWidth() - 2, yOffset); + Shape line = new Line2D.Double( bounds.getX(), yOffset, bounds.getX() + bounds.getWidth() - 2, yOffset); g.draw(line); } // tick marks @@ -100,8 +100,8 @@ public class PlotSurface implements ChartPart { List<Integer> xAxisTickLocations = getChartPainter().getAxisPair().getxAxis().getAxisTick().getTickLocations(); for (int i = 0; i < xAxisTickLocations.size(); i++) { - int tickLocation = xAxisTickLocations.get(i); - int xOffset = (int) (bounds.getX() + tickLocation - 1); + double tickLocation = xAxisTickLocations.get(i); + double xOffset = bounds.getX() + tickLocation - 1; // draw lines if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { @@ -117,9 +117,9 @@ public class PlotSurface implements ChartPart { g.setColor(getChartPainter().getStyleManager().getAxisTickMarksColor()); g.setStroke(getChartPainter().getStyleManager().getAxisTickMarksStroke()); - Shape line = new Line2D.Double(xOffset, (int) (bounds.getY()), xOffset, (int) (bounds.getY()) + getChartPainter().getStyleManager().getAxisTickMarkLength()); + Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + getChartPainter().getStyleManager().getAxisTickMarkLength()); g.draw(line); - line = new Line2D.Double(xOffset, (int) (bounds.getY() + bounds.getHeight() - 1), xOffset, (int) (bounds.getY() + bounds.getHeight() - 1) + line = new Line2D.Double(xOffset, bounds.getY() + bounds.getHeight() - 1, xOffset, bounds.getY() + bounds.getHeight() - 1 - getChartPainter().getStyleManager().getAxisTickMarkLength()); g.draw(line); } diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/markers/Marker.java b/xchart/src/main/java/com/xeiam/xchart/internal/markers/Marker.java index cac88797726e6d8ca8c0a1b6b692868866b59765..05bd0edb2581d0162e0cac75a0ed5fbe7dd8e8ad 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/markers/Marker.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/markers/Marker.java @@ -27,8 +27,8 @@ public abstract class Marker { public static final double SIZE = 8; - public static final double X_OFFSET = (int) (-1.0 * (SIZE / 2.0)); - public static final double Y_OFFSET = (int) (-1.0 * (SIZE / 2.0)); + public static final double X_OFFSET = -1.0 * (SIZE / 2.0); + public static final double Y_OFFSET = -1.0 * (SIZE / 2.0); public abstract void paint(Graphics2D g, double xOffset, double yOffset); }