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 39fd0e0d17d4f17b9d1f8373b8e193f895a3728a..49ac9f0fbaf375f71b1cb249064ef9bf91d8e8f8 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 @@ -16,7 +16,6 @@ package com.xeiam.xchart.internal.chartpart; import java.awt.Graphics2D; -import java.awt.Rectangle; import java.awt.font.FontRenderContext; import java.awt.font.TextLayout; import java.awt.geom.Rectangle2D; @@ -149,8 +148,8 @@ public class Axis implements ChartPart { @Override public void paint(Graphics2D g) { - paintZone = new Rectangle(); - bounds = new Rectangle(); + paintZone = new Rectangle2D.Double(); + bounds = new Rectangle2D.Double(); // determine Axis bounds if (direction == Direction.Y) { // Y-Axis 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 86174fa9e18e396f6b85668c8872c716ccf84899..83f547b6cf5b61c43da3b2449f76caf3291d712f 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 @@ -16,7 +16,6 @@ package com.xeiam.xchart.internal.chartpart; import java.awt.Graphics2D; -import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.util.List; @@ -38,7 +37,7 @@ public class AxisTick implements ChartPart { private AxisTickMarks axisTickMarks; /** the bounds */ - private Rectangle2D bounds = new Rectangle2D.Double(0, 0, 0, 0); + private Rectangle2D bounds = new Rectangle2D.Double(); AxisTickCalculator gridStep = null; @@ -99,15 +98,15 @@ public class AxisTick implements ChartPart { axisTickLabels.paint(g); axisTickMarks.paint(g); - bounds = new Rectangle( + bounds = new Rectangle2D.Double( - (int) axisTickLabels.getBounds().getX(), + axisTickLabels.getBounds().getX(), - (int) (axisTickLabels.getBounds().getY()), + axisTickLabels.getBounds().getY(), - (int) (axisTickLabels.getBounds().getWidth() + getChartPainter().getStyleManager().getAxisTickPadding() + axisTickMarks.getBounds().getWidth()), + axisTickLabels.getBounds().getWidth() + getChartPainter().getStyleManager().getAxisTickPadding() + axisTickMarks.getBounds().getWidth(), - (int) (axisTickMarks.getBounds().getHeight()) + axisTickMarks.getBounds().getHeight() ); @@ -119,9 +118,8 @@ public class AxisTick implements ChartPart { axisTickLabels.paint(g); axisTickMarks.paint(g); - bounds = new Rectangle((int) axisTickMarks.getBounds().getX(), (int) (axisTickMarks.getBounds().getY()), (int) axisTickLabels.getBounds().getWidth(), (int) (axisTickMarks.getBounds() - .getHeight() - + getChartPainter().getStyleManager().getAxisTickPadding() + axisTickLabels.getBounds().getHeight())); + bounds = new Rectangle2D.Double(axisTickMarks.getBounds().getX(), axisTickMarks.getBounds().getY(), axisTickLabels.getBounds().getWidth(), axisTickMarks.getBounds().getHeight() + + getChartPainter().getStyleManager().getAxisTickPadding() + axisTickLabels.getBounds().getHeight()); // g.setColor(Color.red); // 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 7c16c821f6e71e15e0242d7cde104e62ac92322f..d91f18a31a70412c9b63538eeed184762189dfb2 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 @@ -16,7 +16,6 @@ package com.xeiam.xchart.internal.chartpart; import java.awt.Graphics2D; -import java.awt.Rectangle; import java.awt.font.FontRenderContext; import java.awt.font.TextLayout; import java.awt.geom.Rectangle2D; @@ -30,7 +29,7 @@ public class AxisTickLabels implements ChartPart { private final AxisTick axisTick; /** the bounds */ - private Rectangle2D bounds = new Rectangle2D.Double(0, 0, 0, 0); + private Rectangle2D bounds = new Rectangle2D.Double(); /** * Constructor @@ -57,9 +56,9 @@ public class AxisTickLabels implements ChartPart { if (axisTick.getAxis().getDirection() == Axis.Direction.Y && getChartPainter().getStyleManager().isYAxisTicksVisible()) { // Y-Axis - int xOffset = (int) (axisTick.getAxis().getAxisTitle().getBounds().getX() + axisTick.getAxis().getAxisTitle().getBounds().getWidth()); - int yOffset = (int) (axisTick.getAxis().getPaintZone().getY()); - int maxTickLabelWidth = 0; + double xOffset = axisTick.getAxis().getAxisTitle().getBounds().getX() + axisTick.getAxis().getAxisTitle().getBounds().getWidth(); + double yOffset = axisTick.getAxis().getPaintZone().getY(); + double maxTickLabelWidth = 0; for (int i = 0; i < axisTick.getTickLabels().size(); i++) { String tickLabel = axisTick.getTickLabels().get(i); @@ -71,7 +70,7 @@ public class AxisTickLabels implements ChartPart { // 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, xOffset, (int) (yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0)); + layout.draw(g, (float) xOffset, (float) (yOffset + axisTick.getAxis().getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0)); if (tickLabelBounds.getWidth() > maxTickLabelWidth) { maxTickLabelWidth = (int) tickLabelBounds.getWidth(); @@ -80,15 +79,15 @@ public class AxisTickLabels implements ChartPart { } // bounds - bounds = new Rectangle(xOffset, yOffset, maxTickLabelWidth, (int) axisTick.getAxis().getPaintZone().getHeight()); + bounds = new Rectangle2D.Double(xOffset, yOffset, maxTickLabelWidth, (int) axisTick.getAxis().getPaintZone().getHeight()); // g.setColor(Color.blue); // g.draw(bounds); } else if (axisTick.getAxis().getDirection() == Axis.Direction.X && getChartPainter().getStyleManager().isXAxisTicksVisible()) { // X-Axis - int xOffset = (int) (axisTick.getAxis().getPaintZone().getX()); - int yOffset = (int) (axisTick.getAxis().getAxisTitle().getBounds().getY()); - int maxTickLabelHeight = 0; + double xOffset = (int) (axisTick.getAxis().getPaintZone().getX()); + double yOffset = (int) (axisTick.getAxis().getAxisTitle().getBounds().getY()); + double maxTickLabelHeight = 0; for (int i = 0; i < axisTick.getTickLabels().size(); i++) { String tickLabel = axisTick.getTickLabels().get(i); @@ -98,7 +97,7 @@ public class AxisTickLabels implements ChartPart { FontRenderContext frc = g.getFontRenderContext(); TextLayout layout = new TextLayout(tickLabel, getChartPainter().getStyleManager().getAxisTickLabelsFont(), frc); Rectangle2D tickLabelBounds = layout.getBounds(); - layout.draw(g, (int) (xOffset + tickLocation - tickLabelBounds.getWidth() / 2.0), yOffset); + layout.draw(g, (float) (xOffset + tickLocation - tickLabelBounds.getWidth() / 2.0), (float) yOffset); if (tickLabelBounds.getHeight() > maxTickLabelHeight) { maxTickLabelHeight = (int) tickLabelBounds.getHeight(); @@ -107,7 +106,7 @@ public class AxisTickLabels implements ChartPart { } // bounds - bounds = new Rectangle(xOffset, yOffset - maxTickLabelHeight, (int) axisTick.getAxis().getPaintZone().getWidth(), maxTickLabelHeight); + bounds = new Rectangle2D.Double(xOffset, yOffset - maxTickLabelHeight, axisTick.getAxis().getPaintZone().getWidth(), 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 3b51212519e62477d5a7d678ff7174aeba7407b5..e876d4ca65701f7d65ec677b08061f5707f43104 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 @@ -16,7 +16,6 @@ package com.xeiam.xchart.internal.chartpart; import java.awt.Graphics2D; -import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; @@ -30,7 +29,7 @@ public class AxisTickMarks implements ChartPart { private AxisTick axisTick; /** the bounds */ - private Rectangle2D bounds = new Rectangle2D.Double(0, 0, 0, 0); + private Rectangle2D bounds = new Rectangle2D.Double(); /** * Constructor @@ -56,8 +55,8 @@ public class AxisTickMarks implements ChartPart { if (axisTick.getAxis().getDirection() == Axis.Direction.Y && getChartPainter().getStyleManager().isYAxisTicksVisible()) { // Y-Axis - int xOffset = (int) (axisTick.getAxisTickLabels().getBounds().getX() + axisTick.getAxisTickLabels().getBounds().getWidth() + getChartPainter().getStyleManager().getAxisTickPadding()); - int yOffset = (int) (axisTick.getAxis().getPaintZone().getY()); + double xOffset = axisTick.getAxisTickLabels().getBounds().getX() + axisTick.getAxisTickLabels().getBounds().getWidth() + getChartPainter().getStyleManager().getAxisTickPadding(); + double yOffset = axisTick.getAxis().getPaintZone().getY(); // tick marks if (getChartPainter().getStyleManager().isAxisTicksMarksVisible()) { @@ -89,15 +88,15 @@ public class AxisTickMarks implements ChartPart { } // bounds - bounds = new Rectangle(xOffset, yOffset, getChartPainter().getStyleManager().getAxisTickMarkLength(), (int) axisTick.getAxis().getPaintZone().getHeight()); + bounds = new Rectangle2D.Double(xOffset, yOffset, getChartPainter().getStyleManager().getAxisTickMarkLength(), (int) axisTick.getAxis().getPaintZone().getHeight()); // g.setColor(Color.yellow); // g.draw(bounds); } else if (axisTick.getAxis().getDirection() == Axis.Direction.X && getChartPainter().getStyleManager().isXAxisTicksVisible()) { // X-Axis - int xOffset = (int) (axisTick.getAxis().getPaintZone().getX()); + double xOffset = axisTick.getAxis().getPaintZone().getX(); // int yOffset = (int) (axisTick.getAxisTickLabels().getBounds().getY() - getChart().getStyleManager().getAxisTickPadding()); - int yOffset = (int) (axisTick.getAxisTickLabels().getBounds().getY() - getChartPainter().getStyleManager().getAxisTickPadding()); + double yOffset = axisTick.getAxisTickLabels().getBounds().getY() - getChartPainter().getStyleManager().getAxisTickPadding(); // tick marks if (getChartPainter().getStyleManager().isAxisTicksMarksVisible()) { @@ -106,11 +105,8 @@ 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 + tickLocation, yOffset, xOffset + tickLocation, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength()); g.draw(line); - // g.drawLine(xOffset + tickLocation, yOffset, xOffset + tickLocation, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength()); } } // Line @@ -119,12 +115,10 @@ public class AxisTickMarks implements ChartPart { Shape line = new Line2D.Double(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength(), xOffset + axisTick.getAxis().getPaintZone().getWidth(), yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength()); g.draw(line); - // g.drawLine(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength(), xOffset + (int) axisTick.getAxis().getPaintZone().getWidth(), yOffset - // - getChartPainter().getStyleManager().getAxisTickMarkLength()); } // bounds - bounds = new Rectangle(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTickMarkLength(), (int) axisTick.getAxis().getPaintZone().getWidth(), getChartPainter().getStyleManager() + 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/AxisTitle.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java index 1af0d40a8f18fd71cbf6073534d4e49ba609141b..ac58fc3f050216ab665bdd23a8ac7ce0637f1988 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java @@ -16,7 +16,6 @@ package com.xeiam.xchart.internal.chartpart; import java.awt.Graphics2D; -import java.awt.Rectangle; import java.awt.font.FontRenderContext; import java.awt.font.TextLayout; import java.awt.geom.AffineTransform; @@ -55,7 +54,7 @@ public class AxisTitle implements ChartPart { @Override public void paint(Graphics2D g) { - bounds = new Rectangle(); + bounds = new Rectangle2D.Double(); g.setColor(getChartPainter().getStyleManager().getChartFontColor()); g.setFont(getChartPainter().getStyleManager().getAxisTitleFont()); @@ -81,12 +80,12 @@ public class AxisTitle implements ChartPart { // System.out.println(nonRotatedRectangle.getHeight()); // bounds - bounds = new Rectangle((int) (xOffset - nonRotatedRectangle.getHeight()), (int) (yOffset - nonRotatedRectangle.getWidth()), (int) nonRotatedRectangle.getHeight() - + getChartPainter().getStyleManager().getAxisTitlePadding(), (int) nonRotatedRectangle.getWidth()); + bounds = new Rectangle2D.Double(xOffset - nonRotatedRectangle.getHeight(), yOffset - nonRotatedRectangle.getWidth(), nonRotatedRectangle.getHeight() + + getChartPainter().getStyleManager().getAxisTitlePadding(), nonRotatedRectangle.getWidth()); // g.setColor(Color.blue); // g.draw(bounds); } else { - bounds = new Rectangle((int) axis.getPaintZone().getX(), (int) axis.getPaintZone().getY(), 0, (int) axis.getPaintZone().getHeight()); + bounds = new Rectangle2D.Double(axis.getPaintZone().getX(), axis.getPaintZone().getY(), 0, axis.getPaintZone().getHeight()); } } else { @@ -98,18 +97,18 @@ public class AxisTitle implements ChartPart { Rectangle2D rectangle = textLayout.getBounds(); // System.out.println(rectangle); - int xOffset = (int) (axis.getPaintZone().getX() + (axis.getPaintZone().getWidth() - rectangle.getWidth()) / 2.0); - int yOffset = (int) (axis.getPaintZone().getY() + axis.getPaintZone().getHeight() - rectangle.getHeight()); + double xOffset = axis.getPaintZone().getX() + (axis.getPaintZone().getWidth() - rectangle.getWidth()) / 2.0; + double yOffset = axis.getPaintZone().getY() + axis.getPaintZone().getHeight() - rectangle.getHeight(); - textLayout.draw(g, xOffset, (float) (yOffset - rectangle.getY())); + textLayout.draw(g, (float) xOffset, (float) (yOffset - rectangle.getY())); - bounds = new Rectangle(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTitlePadding(), (int) rectangle.getWidth(), (int) rectangle.getHeight() + bounds = new Rectangle2D.Double(xOffset, yOffset - getChartPainter().getStyleManager().getAxisTitlePadding(), rectangle.getWidth(), rectangle.getHeight() + getChartPainter().getStyleManager().getAxisTitlePadding()); // g.setColor(Color.blue); // g.draw(bounds); } else { - bounds = new Rectangle((int) axis.getPaintZone().getX(), (int) (axis.getPaintZone().getY() + axis.getPaintZone().getHeight()), (int) axis.getPaintZone().getWidth(), 0); + bounds = new Rectangle2D.Double(axis.getPaintZone().getX(), axis.getPaintZone().getY() + axis.getPaintZone().getHeight(), axis.getPaintZone().getWidth(), 0); // g.setColor(Color.blue); // g.draw(bounds); 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 ca676d8f4b40abea336a024e566124c8f7db330d..77ca627aa5e5c731ee5db4daba391ba7ac97e6a8 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 @@ -82,7 +82,6 @@ public class ChartTitle implements ChartPart { @Override public void paint(Graphics2D g) { - // bounds = new Rectangle(); g.setFont(chartPainter.getStyleManager().getChartTitleFont()); if (chartPainter.getStyleManager().isChartTitleVisible()) { 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 b175c6032be44bedf8b761e91d01a6c6d26e2609..89de73a87573103f05c704f5bff9126eea0bee16 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 @@ -17,7 +17,6 @@ package com.xeiam.xchart.internal.chartpart; import java.awt.BasicStroke; import java.awt.Graphics2D; -import java.awt.Rectangle; import java.awt.Shape; import java.awt.font.FontRenderContext; import java.awt.font.TextLayout; @@ -109,7 +108,7 @@ public class Legend implements ChartPart { @Override public void paint(Graphics2D g) { - bounds = new Rectangle(); + bounds = new Rectangle2D.Double(); g.setFont(chartPainter.getStyleManager().getLegendFont()); if (chartPainter.getStyleManager().isLegendVisible()) { diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java index 7bd3e766de1087acda3516bd4c7d6e970f821543..bf49f65c897417c2be8e7d9e0b4ef67b7a786a4e 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java @@ -16,7 +16,6 @@ package com.xeiam.xchart.internal.chartpart; import java.awt.Graphics2D; -import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import com.xeiam.xchart.StyleManager.ChartType; @@ -57,21 +56,21 @@ public class Plot implements ChartPart { @Override public void paint(Graphics2D g) { - bounds = new Rectangle(); + bounds = new Rectangle2D.Double(); // calculate bounds - int xOffset = (int) (chartPainter.getAxisPair().getyAxis().getBounds().getX() + double xOffset = chartPainter.getAxisPair().getyAxis().getBounds().getX() + chartPainter.getAxisPair().getyAxis().getBounds().getWidth() + (chartPainter.getStyleManager().isYAxisTicksVisible() ? (chartPainter.getStyleManager().getPlotPadding() + 1) : 0) - ); + ; - int yOffset = (int) (chartPainter.getAxisPair().getyAxis().getBounds().getY()); - int width = (int) chartPainter.getAxisPair().getxAxis().getBounds().getWidth(); - int height = (int) chartPainter.getAxisPair().getyAxis().getBounds().getHeight(); - bounds = new Rectangle(xOffset, yOffset, width, height); + double yOffset = chartPainter.getAxisPair().getyAxis().getBounds().getY(); + double width = chartPainter.getAxisPair().getxAxis().getBounds().getWidth(); + double height = chartPainter.getAxisPair().getyAxis().getBounds().getHeight(); + bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); // g.setColor(Color.green); // g.draw(bounds);