From 7c203682600f583dcb41f512d664f7dbfc01eacd Mon Sep 17 00:00:00 2001 From: Tim Molter Date: Fri, 10 May 2024 10:52:45 +0200 Subject: [PATCH] code reformat --- pom.xml | 9 +- xchart-demo/pom.xml | 83 +++++++++-------- .../xchart/demo/charts/bar/BarChart12.java | 11 +-- .../demo/charts/heatmap/HeatMapChart05.java | 9 +- .../standalone/issues/TestForIssue582.java | 92 ++++++++++--------- .../standalone/issues/TestForIssue707.java | 35 +++---- xchart/pom.xml | 64 +++++++------ .../chartpart/AxisTickCalculator_.java | 46 +++++----- 8 files changed, 181 insertions(+), 168 deletions(-) diff --git a/pom.xml b/pom.xml index 1469695f..79440043 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,9 @@ - + + + + 3.9.0 + 4.0.0 org.knowm.xchart @@ -123,7 +128,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.3 + 3.2.4 sign-artifacts diff --git a/xchart-demo/pom.xml b/xchart-demo/pom.xml index 82a22865..9754c5de 100644 --- a/xchart-demo/pom.xml +++ b/xchart-demo/pom.xml @@ -1,45 +1,50 @@ - + - 4.0.0 + + 3.9.0 + - - org.knowm.xchart - xchart-parent - 3.8.8-SNAPSHOT - + 4.0.0 - xchart-demo + + org.knowm.xchart + xchart-parent + 3.8.8-SNAPSHOT + - XChart Demo - A Swing App demonstration of various charts using XChart + xchart-demo - - - org.knowm.xchart - xchart - 3.8.8-SNAPSHOT - - - org.openjfx - javafx-swing - 11.0.2 - - - org.openjfx - javafx-controls - 11.0.2 - - - - - - org.openjfx - javafx-maven-plugin - 0.0.8 - - org.knowm.xchart.standalone.JavaFXDemo - - - - + XChart Demo + A Swing App demonstration of various charts using XChart + + + + org.knowm.xchart + xchart + 3.8.8-SNAPSHOT + + + org.openjfx + javafx-swing + 11.0.2 + + + org.openjfx + javafx-controls + 11.0.2 + + + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + org.knowm.xchart.standalone.JavaFXDemo + + + + diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart12.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart12.java index a09846fa..a4e23395 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart12.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart12.java @@ -4,17 +4,16 @@ package org.knowm.xchart.demo.charts.bar; -import org.knowm.xchart.CategoryChart; -import org.knowm.xchart.CategoryChartBuilder; -import org.knowm.xchart.CategorySeries; -import org.knowm.xchart.SwingWrapper; -import org.knowm.xchart.demo.charts.ExampleChart; - import java.awt.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; +import org.knowm.xchart.CategoryChart; +import org.knowm.xchart.CategoryChartBuilder; +import org.knowm.xchart.CategorySeries; +import org.knowm.xchart.SwingWrapper; +import org.knowm.xchart.demo.charts.ExampleChart; /** * Stacked Bars with Overlapped Line Chart diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/heatmap/HeatMapChart05.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/heatmap/HeatMapChart05.java index 8b0d7606..8849e058 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/heatmap/HeatMapChart05.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/heatmap/HeatMapChart05.java @@ -46,10 +46,11 @@ public HeatMapChart getChart() { .yAxisTitle("Working day") .build(); - chart.getStyler() - .setPlotContentSize(0.999) - .setLegendFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)) - .setToolTipsEnabled(true); + chart + .getStyler() + .setPlotContentSize(0.999) + .setLegendFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)) + .setToolTipsEnabled(true); chart .getStyler() .setPiecewise(true) diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue582.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue582.java index a58df763..da00904a 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue582.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue582.java @@ -1,54 +1,56 @@ package org.knowm.xchart.standalone.issues; +import java.text.ParseException; +import java.util.Locale; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.XYChart; import org.knowm.xchart.XYChartBuilder; -import java.text.DecimalFormatSymbols; -import java.text.ParseException; -import java.util.Locale; - public class TestForIssue582 { - public static void main(String[] args) throws ParseException { - - XYChart chart = getXYChart(); - new SwingWrapper(chart).displayChart(); - } - - public static XYChart getXYChart() { - XYChart chart = new XYChartBuilder() - .width(720) - .height(480) - .title("Deadlock Example") - .xAxisTitle("Count") - .yAxisTitle("Value") - .build(); - - // If the decimal places in the pattern is fewer than the largest data value, the deadlock occurs. -// chart.getStyler().setDecimalPattern("#0.0000"); -// chart.getStyler().setDecimalPattern("#,###.00"); - -// chart.getStyler().setDecimalPattern("$ #0.00"); -// chart.getStyler().setDecimalPattern("$ #0.000"); - - chart.getStyler().setLocale(Locale.ITALIAN); - chart.getStyler().setDecimalPattern("#0.000"); - - double[] xValues = new double[]{1, 2, 3, 4, 5, 6, 7, 8}; - - // The only value here is 0.001 which is one decimal place below the pattern. - double[] yValues = new double[] { 0.0, 0.0, 0.0, 0.0, 0.001, 0.0, 0.0, 0.0}; -// double[] yValues = new double[] { 0.0, 0.0, 0.0, 0.0, -0.001, 0.0, 0.0, 0.0}; -// double[] yValues = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; -// double[] yValues = new double[] { 0.0001, 0.0, 0.0, 0.0, -0.001, 0.0, 0.0, 0.0}; -// double[] yValues = new double[] { -0.0002, -0.0002, -0.0002, -0.0002, -0.001, -0.0002, -0.0002, -0.0002}; -// double[] yValues = new double[]{0.0002, 0.0002, 0.0002, 0.0002, 0.0001, 0.0002, 0.0002, 0.0002}; -// double[] yValues = new double[] { 20.0002, 20.0002, 20.0002, 20.0002, 20.001, 20.0002, 20.0002, 20.0002}; - - chart.addSeries("main", xValues, yValues); - - - return chart; - } + public static void main(String[] args) throws ParseException { + + XYChart chart = getXYChart(); + new SwingWrapper(chart).displayChart(); + } + + public static XYChart getXYChart() { + XYChart chart = + new XYChartBuilder() + .width(720) + .height(480) + .title("Deadlock Example") + .xAxisTitle("Count") + .yAxisTitle("Value") + .build(); + + // If the decimal places in the pattern is fewer than the largest data value, the deadlock + // occurs. + // chart.getStyler().setDecimalPattern("#0.0000"); + // chart.getStyler().setDecimalPattern("#,###.00"); + + // chart.getStyler().setDecimalPattern("$ #0.00"); + // chart.getStyler().setDecimalPattern("$ #0.000"); + + chart.getStyler().setLocale(Locale.ITALIAN); + chart.getStyler().setDecimalPattern("#0.000"); + + double[] xValues = new double[] {1, 2, 3, 4, 5, 6, 7, 8}; + + // The only value here is 0.001 which is one decimal place below the pattern. + double[] yValues = new double[] {0.0, 0.0, 0.0, 0.0, 0.001, 0.0, 0.0, 0.0}; + // double[] yValues = new double[] { 0.0, 0.0, 0.0, 0.0, -0.001, 0.0, 0.0, 0.0}; + // double[] yValues = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + // double[] yValues = new double[] { 0.0001, 0.0, 0.0, 0.0, -0.001, 0.0, 0.0, 0.0}; + // double[] yValues = new double[] { -0.0002, -0.0002, -0.0002, -0.0002, -0.001, -0.0002, + // -0.0002, -0.0002}; + // double[] yValues = new double[]{0.0002, 0.0002, 0.0002, 0.0002, 0.0001, 0.0002, + // 0.0002, 0.0002}; + // double[] yValues = new double[] { 20.0002, 20.0002, 20.0002, 20.0002, 20.001, + // 20.0002, 20.0002, 20.0002}; + + chart.addSeries("main", xValues, yValues); + + return chart; + } } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java index 5227162f..d0ef2205 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/issues/TestForIssue707.java @@ -1,13 +1,11 @@ package org.knowm.xchart.standalone.issues; +import java.text.ParseException; import org.knowm.xchart.CategoryChart; import org.knowm.xchart.CategoryChartBuilder; -import org.knowm.xchart.CategorySeries; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.style.Styler; -import java.text.ParseException; - public class TestForIssue707 { public static void main(String[] args) throws ParseException { @@ -17,22 +15,19 @@ public static void main(String[] args) throws ParseException { } public static CategoryChart getCategoryChart() { - double[] xData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 }; - double[] yData = new double[] { 2.0, 1.5, 4.0, 3.77, 2.5 }; - - // Create Chart - CategoryChartBuilder builder = new CategoryChartBuilder(); - builder.title("Sample Chart") - .xAxisTitle("X") - .yAxisTitle("Y") - .theme(Styler.ChartTheme.Matlab); - CategoryChart chart = builder.build(); - // chart.getStyler().setYAxisMin(1.0); - chart.getStyler().setLabelsVisible(true); - //.setDefaultSeriesRenderStyle(CategorySeries.CategorySeriesRenderStyle.Line). - - chart.addSeries("y(x)", xData, yData); - - return chart; + double[] xData = new double[] {0.0, 1.0, 2.0, 3.0, 4.0}; + double[] yData = new double[] {2.0, 1.5, 4.0, 3.77, 2.5}; + + // Create Chart + CategoryChartBuilder builder = new CategoryChartBuilder(); + builder.title("Sample Chart").xAxisTitle("X").yAxisTitle("Y").theme(Styler.ChartTheme.Matlab); + CategoryChart chart = builder.build(); + // chart.getStyler().setYAxisMin(1.0); + chart.getStyler().setLabelsVisible(true); + // .setDefaultSeriesRenderStyle(CategorySeries.CategorySeriesRenderStyle.Line). + + chart.addSeries("y(x)", xData, yData); + + return chart; } } diff --git a/xchart/pom.xml b/xchart/pom.xml index d45ef564..7197c25b 100644 --- a/xchart/pom.xml +++ b/xchart/pom.xml @@ -1,31 +1,37 @@ - - - 4.0.0 - - - org.knowm.xchart - xchart-parent - 3.8.8-SNAPSHOT - - - xchart - - XChart - The core XChart library - - - - de.erichseifert.vectorgraphics2d - VectorGraphics2D - - - de.rototor.pdfbox - graphics2d - - - com.madgag - animated-gif-lib - - + + + + + 3.9.0 + + + 4.0.0 + + + org.knowm.xchart + xchart-parent + 3.8.8-SNAPSHOT + + + xchart + + XChart + The core XChart library + + + + de.erichseifert.vectorgraphics2d + VectorGraphics2D + + + de.rototor.pdfbox + graphics2d + + + com.madgag + animated-gif-lib + + diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_.java index ba440c0b..05d013cc 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_.java @@ -161,7 +161,7 @@ public Format getAxisFormat() { protected void calculate() { - // System.out.println("calculate"); + // System.out.println("calculate"); // a check if all axis data are the exact same values if (minValue == maxValue) { @@ -188,14 +188,15 @@ protected void calculate() { return; } - // this prevents an infinite loop when the axis number formatter "rounds" all axis ticks to the same value i.e. "#0.00" for 0.0, 0.0001, 0.0002 - // issue #582 - if(isNumberFormatChoppingDecimals(maxValue, minValue)){ - System.out.println("returning"); - return; - } + // this prevents an infinite loop when the axis number formatter "rounds" all axis ticks to the + // same value i.e. "#0.00" for 0.0, 0.0001, 0.0002 + // issue #582 + if (isNumberFormatChoppingDecimals(maxValue, minValue)) { + System.out.println("returning"); + return; + } - // where the tick should begin in the working space in pixels + // where the tick should begin in the working space in pixels double margin = Utils.getTickStartOffset( workingSpace, @@ -225,7 +226,7 @@ protected void calculate() { do { -// System.out.println("calculating ticks..."); + // System.out.println("calculating ticks..."); tickLabels.clear(); tickLocations.clear(); @@ -351,7 +352,6 @@ protected void calculate() { } } while (!areAllTickLabelsUnique(tickLabels) || !willLabelsFitInTickSpaceHint(tickLabels, gridStepInChartSpace)); - } private boolean areValuesEquallySpaced(List values) { @@ -463,18 +463,18 @@ private static double getAxisMaxValue( return dataMaxValue; } - private boolean isNumberFormatChoppingDecimals(double axisMax, double axisMin){ - -// System.out.println("axisMax = " + axisMax); -// System.out.println("axisMin = " + axisMin); - String formattedMaxValue = getAxisFormat().format(axisMax); -// System.out.println("formattedMaxValue = " + formattedMaxValue); - String formattedMinValue = getAxisFormat().format(axisMin); -// System.out.println("formattedMinValue = " + formattedMinValue); - // if formatted number lost its decimals due to formatter - if(formattedMaxValue.equals(formattedMinValue)){ - return true; - } - return false; + private boolean isNumberFormatChoppingDecimals(double axisMax, double axisMin) { + + // System.out.println("axisMax = " + axisMax); + // System.out.println("axisMin = " + axisMin); + String formattedMaxValue = getAxisFormat().format(axisMax); + // System.out.println("formattedMaxValue = " + formattedMaxValue); + String formattedMinValue = getAxisFormat().format(axisMin); + // System.out.println("formattedMinValue = " + formattedMinValue); + // if formatted number lost its decimals due to formatter + if (formattedMaxValue.equals(formattedMinValue)) { + return true; } + return false; + } }