diff --git a/README.md b/README.md index bd945e26d6c36bae0c54818d0075822b7c9f2fc8..60e3148e364c22c22fe21bb51e17adf63d3b74fc 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Add the XChart library as a dependency to your pom.xml file: <dependency> <groupId>com.xeiam.xchart</groupId> <artifactId>xchart</artifactId> - <version>2.4.1</version> + <version>2.4.2</version> </dependency> For snapshots, add the following to your pom.xml file: @@ -77,7 +77,7 @@ For snapshots, add the following to your pom.xml file: <dependency> <groupId>com.xeiam</groupId> <artifactId>xchart</artifactId> - <version>2.4.2-SNAPSHOT</version> + <version>2.4.3-SNAPSHOT</version> </dependency> ## Building @@ -95,7 +95,7 @@ For snapshots, add the following to your pom.xml file: ## Running Demo cd /path/to/xchart-demo/jar/ - java -cp xchart-demo-2.4.1.jar:xchart-2.4.1.jar com.xeiam.xchart.demo.XChartDemo + java -cp xchart-demo-2.4.2.jar:xchart-2.4.2.jar com.xeiam.xchart.demo.XChartDemo ## Bugs Please report any bugs or submit feature requests to [XChart's Github issue tracker](https://github.com/timmolter/XChart/issues). diff --git a/pom.xml b/pom.xml index 4519217acf4dfe0a9b4194dd7f3d4364dcf44e07..b55f4596a0273ba4d52c7836a1e8f3271e1a6003 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ <groupId>com.xeiam.xchart</groupId> <artifactId>xchart-parent</artifactId> - <version>2.4.2-SNAPSHOT</version> + <version>2.4.3-SNAPSHOT</version> <packaging>pom</packaging> <name>XChart Parent</name> <description>Basic Charts for Java Applications</description> diff --git a/xchart-demo/pom.xml b/xchart-demo/pom.xml index 0fe5dd0f84242660ee9db472e83f417f695e9c84..62a79f307c5390d071b5c975387e674cbbfa683b 100644 --- a/xchart-demo/pom.xml +++ b/xchart-demo/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>com.xeiam.xchart</groupId> <artifactId>xchart-parent</artifactId> - <version>2.4.2-SNAPSHOT</version> + <version>2.4.3-SNAPSHOT</version> </parent> <artifactId>xchart-demo</artifactId> @@ -17,7 +17,7 @@ <dependency> <groupId>com.xeiam.xchart</groupId> <artifactId>xchart</artifactId> - <version>2.4.2-SNAPSHOT</version> + <version>2.4.3-SNAPSHOT</version> </dependency> </dependencies> diff --git a/xchart/pom.xml b/xchart/pom.xml index 8d58c647c28a43850be040d0dee49d0e1657a3e8..890259a664063e1cc7f9d6d12449edef6af7502a 100644 --- a/xchart/pom.xml +++ b/xchart/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>com.xeiam.xchart</groupId> <artifactId>xchart-parent</artifactId> - <version>2.4.2-SNAPSHOT</version> + <version>2.4.3-SNAPSHOT</version> </parent> <artifactId>xchart</artifactId> 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 973ff52a9d50c184a5f7548bebe0c184b14cdab4..adb3ff43f1af7aa51fb22d9d37f5e85bd9064b54 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 @@ -39,7 +39,7 @@ public class ChartTitle implements ChartPart { /** * Constructor - * + * * @param chartPainter */ public ChartTitle(ChartPainter chartPainter) { @@ -49,7 +49,7 @@ public class ChartTitle implements ChartPart { /** * set the chart title's text - * + * * @param text */ public void setText(String text) { @@ -65,7 +65,7 @@ public class ChartTitle implements ChartPart { /** * get the height of the chart title including the chart padding - * + * * @return */ protected int getSizeHint() { @@ -94,8 +94,8 @@ public class ChartTitle implements ChartPart { TextLayout textLayout = new TextLayout(text, chartPainter.getStyleManager().getChartTitleFont(), frc); Rectangle2D rectangle = textLayout.getBounds(); - int xOffset = (int) chartPainter.getPlot().getBounds().getX(); - int yOffset = chartPainter.getStyleManager().getChartPadding(); + double xOffset = (int) chartPainter.getPlot().getBounds().getX(); + double yOffset = chartPainter.getStyleManager().getChartPadding(); if (chartPainter.getStyleManager().isChartTitleBoxVisible()) { @@ -109,12 +109,11 @@ public class ChartTitle implements ChartPart { g.fill(rect); g.setColor(chartPainter.getStyleManager().getChartTitleBoxBorderColor()); g.draw(rect); - } // paint title - xOffset = (int) (chartPainter.getPlot().getBounds().getX() + (chartPainter.getPlot().getBounds().getWidth() - rectangle.getWidth()) / 2.0); - yOffset = (int) (chartPainter.getStyleManager().getChartPadding() - rectangle.getY() + chartPainter.getStyleManager().getChartTitlePadding()); + xOffset = chartPainter.getPlot().getBounds().getX() + (chartPainter.getPlot().getBounds().getWidth() - rectangle.getWidth()) / 2.0; + yOffset = chartPainter.getStyleManager().getChartPadding() - rectangle.getY() + chartPainter.getStyleManager().getChartTitlePadding(); bounds = new Rectangle2D.Double(xOffset, yOffset + rectangle.getY(), rectangle.getWidth(), rectangle.getHeight()); // g.setColor(Color.green); 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 59be2c9fa4880d91e08a2dda15d15250dd591f20..be45c59ad18869dff579f8a2fc27fb4aa2dabca5 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 @@ -37,14 +37,13 @@ public class Plot implements ChartPart { /** * Constructor - * + * * @param chartPainter */ public Plot(ChartPainter chartPainter) { this.chartPainter = chartPainter; this.plotSurface = new PlotSurface(this); - } @Override @@ -61,11 +60,11 @@ public class Plot implements ChartPart { // calculate bounds double xOffset = chartPainter.getAxisPair().getYAxis().getBounds().getX() - + chartPainter.getAxisPair().getYAxis().getBounds().getWidth() + + chartPainter.getAxisPair().getYAxis().getBounds().getWidth() - + (chartPainter.getStyleManager().isYAxisTicksVisible() ? (chartPainter.getStyleManager().getPlotPadding()) : 0) + + (chartPainter.getStyleManager().isYAxisTicksVisible() ? (chartPainter.getStyleManager().getPlotPadding()) : 0) - ; + ; double yOffset = chartPainter.getAxisPair().getYAxis().getBounds().getY(); double width = chartPainter.getAxisPair().getXAxis().getBounds().getWidth(); diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentBarChart.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentBarChart.java index 197a8002b6f9537a0ba80c64df9f598030e30612..6ee673bdc1a24d37e79bf606de58b0f2989ee4b4 100644 --- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentBarChart.java +++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentBarChart.java @@ -45,10 +45,17 @@ public class PlotContentBarChart extends PlotContent { public void paint(Graphics2D g) { Rectangle2D bounds = plot.getBounds(); + // g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); + // g.setColor(Color.red); + // g.draw(bounds); + StyleManager styleManager = plot.getChartPainter().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, getChartPainter().getWidth(), getChartPainter().getHeight()); + // g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); + // g.setColor(Color.green); + // g.draw(rectangle); g.setClip(bounds.createIntersection(rectangle)); // X-Axis @@ -206,7 +213,7 @@ public class PlotContentBarChart extends PlotContent { } seriesCounter++; } - + g.setClip(null); } @Override