diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart01.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart01.java index e0d5f4149b24d0fb45f381de105b3454d40eabe9..e7ea68043a7dd5b04aff2d05cd27eeb87e652df8 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart01.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart01.java @@ -22,7 +22,7 @@ import org.knowm.xchart.Series_XY.ChartXYSeriesRenderStyle; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Area Chart with 3 series @@ -52,9 +52,9 @@ public class AreaChart01 implements ExampleChart { chart.addSeries("c", new double[] { 0, 1, 3, 8, 9 }, new double[] { -2, -1, 1, 0, 1 }); // Customize Chart - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNE); - chart.getStyleManager().setAxisTitlesVisible(false); - chart.getStyleManager().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Area); + chart.getStyler().setLegendPosition(LegendPosition.InsideNE); + chart.getStyler().setAxisTitlesVisible(false); + chart.getStyler().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Area); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart02.java index 892c02c739f85de2c38211bc67522cee42dabb9a..3a8196751360cbef6ee90a51ef630e564d0b7f39 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart02.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaChart02.java @@ -25,7 +25,7 @@ import org.knowm.xchart.Series_XY.ChartXYSeriesRenderStyle; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Null Y-Axis Data Points @@ -74,8 +74,8 @@ public class AreaChart02 implements ExampleChart { chart.addSeries("a", xData, yData); // Customize Chart - chart.getStyleManager().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Area); - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Area); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaLineChart03.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaLineChart03.java index be67a8d48023fb895ec79b53aa43593074ce9a84..b64a6de4b54cbde2a0bf00d37bce3ad74d3e788b 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaLineChart03.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/area/AreaLineChart03.java @@ -22,8 +22,8 @@ import org.knowm.xchart.Series_XY.ChartXYSeriesRenderStyle; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.markers.SeriesMarkers; /** @@ -54,8 +54,8 @@ public class AreaLineChart03 implements ExampleChart { chart.setTitle(getClass().getSimpleName()); chart.setXAxisTitle("Age"); chart.setYAxisTitle("Amount"); - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); - chart.getStyleManager().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Line); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Line); // @formatter:off double[] xAges = new double[] { 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, @@ -91,11 +91,11 @@ public class AreaLineChart03 implements ExampleChart { Series_XY seriesPercentile25th = chart.addSeries("25th Percentile", xAges, yPercentile25th); seriesPercentile25th.setMarker(SeriesMarkers.NONE); - chart.getStyleManager().setYAxisLabelAlignment(StyleManager.TextAlignment.Right); - chart.getStyleManager().setYAxisDecimalPattern("$ #,###.##"); + chart.getStyler().setYAxisLabelAlignment(Styler.TextAlignment.Right); + chart.getStyler().setYAxisDecimalPattern("$ #,###.##"); - chart.getStyleManager().setPlotPadding(0); - chart.getStyleManager().setAxisTickSpacePercentage(.95); + chart.getStyler().setPlotPadding(0); + chart.getStyler().setAxisTickSpacePercentage(.95); // chart.getStyleManager().setYAxisMax(1620725 * 1.15); // We want to ensure there is a % of padding on the top of the chart return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart01.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart01.java index 8e2aef59ec2ead6e1ecf66f7bef66c98520dc74f..ed4d1e63b50c0982cfc9d31c4e2feb239c0b7ace 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart01.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart01.java @@ -23,7 +23,7 @@ import org.knowm.xchart.Chart_Category; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Basic Bar Chart @@ -52,7 +52,7 @@ public class BarChart01 implements ExampleChart { chart.addSeries("test 1", Arrays.asList(new Integer[] { 0, 1, 2, 3, 4 }), Arrays.asList(new Integer[] { 4, 5, 9, 6, 5 })); // Customize Chart - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart02.java index f68cbbfaadb63ee8aa690d7f34ef09d1b0f540fb..0a855449ec11c6d0cb96cf157c8fe2d201298ad0 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart02.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart02.java @@ -30,7 +30,7 @@ import org.knowm.xchart.Series_Category; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; import org.knowm.xchart.internal.style.colors.MatlabSeriesColors; /** @@ -77,9 +77,9 @@ public class BarChart02 implements ExampleChart { } Series_Category series = chart.addSeries("Model 77", xData, yData); series.setLineColor(MatlabSeriesColors.RED); - chart.getStyleManager().setPlotGridLinesVisible(false); - chart.getStyleManager().setBarFilled(false); - chart.getStyleManager().setDatePattern("YYYY"); + chart.getStyler().setPlotGridLinesVisible(false); + chart.getStyler().setBarFilled(false); + chart.getStyler().setDatePattern("YYYY"); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart04.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart04.java index c00b78ba57933642ec5a0278eb284bfd4953ab34..ac7517e7c1b7c10d87b76848b7588683bebdef19 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart04.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart04.java @@ -52,8 +52,8 @@ public class BarChart04 implements ExampleChart { chart.addSeries("female", Arrays.asList(new Integer[] { 10, 20, 30, 40, 50 }), Arrays.asList(new Integer[] { 50, 10, 20, 40, 35 })); chart.addSeries("male", Arrays.asList(new Integer[] { 10, 20, 30, 40, 50 }), Arrays.asList(new Integer[] { 40, 30, 20, null, 60 })); - chart.getStyleManager().setYAxisMin(5); - chart.getStyleManager().setYAxisMax(70); + chart.getStyler().setYAxisMin(5); + chart.getStyler().setYAxisMax(70); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart05.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart05.java index bdfab910088782fdf8acb865278f58cae37484ec..23086e033415b233bc7eddf503bdf820eb5033b2 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart05.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart05.java @@ -24,7 +24,7 @@ import org.knowm.xchart.Chart_Category; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; /** * GGPlot2 Theme diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart06.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart06.java index 01fa815a32e1813330ea8a71e91aa2f74af5d51a..07d92467a846d6cc9b2d29e664bf0fdba48212e7 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart06.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart06.java @@ -26,7 +26,7 @@ import org.knowm.xchart.Histogram; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Histogram Overlapped @@ -57,9 +57,9 @@ public class BarChart06 implements ExampleChart { chart.addSeries("histogram 2", histogram2.getxAxisData(), histogram2.getyAxisData()); // Customize Chart - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); - chart.getStyleManager().setBarWidthPercentage(.96); - chart.getStyleManager().setBarsOverlapped(true); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setBarWidthPercentage(.96); + chart.getStyler().setBarsOverlapped(true); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart07.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart07.java index 3932d53ac4afd0714e1923f064e5fe48124b392f..75447932da5d1d7c9d42869f5a76fd01b05032f6 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart07.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart07.java @@ -26,7 +26,7 @@ import org.knowm.xchart.Histogram; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Histogram Not Overlapped @@ -58,8 +58,8 @@ public class BarChart07 implements ExampleChart { chart.addSeries("histogram 2", histogram2.getxAxisData(), histogram2.getyAxisData()); // Customize Chart - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); - chart.getStyleManager().setBarWidthPercentage(.96); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setBarWidthPercentage(.96); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart08.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart08.java index 799cd18142d9eb5d62d1ded4aba36f213de1ba82..d31e558940c632afa8615977c5a070b7ae1daf0b 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart08.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart08.java @@ -26,7 +26,7 @@ import org.knowm.xchart.Histogram; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Histogram with Error Bars @@ -55,8 +55,8 @@ public class BarChart08 implements ExampleChart { chart.addSeries("histogram", histogram1.getxAxisData(), histogram1.getyAxisData(), getFakeErrorData(histogram1.getxAxisData().size())); // Customize Chart - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); - chart.getStyleManager().setBarWidthPercentage(.96); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setBarWidthPercentage(.96); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart09.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart09.java index 55acc4fa65381ee7008f8a58ca65e198a0357a34..e4212a6562034e7c74a99321d7a5abaa7850270d 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart09.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/bar/BarChart09.java @@ -26,8 +26,8 @@ import org.knowm.xchart.Series_Category.ChartCategorySeriesRenderStyle; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.ChartTheme; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Category chart with Bar, Line and Scatter Series @@ -60,9 +60,9 @@ public class BarChart09 implements ExampleChart { series3.setChartCategorySeriesRenderStyle(ChartCategorySeriesRenderStyle.Scatter); // Customize Chart - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); - chart.getStyleManager().setBarWidthPercentage(.55); - chart.getStyleManager().setBarsOverlapped(true); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setBarWidthPercentage(.55); + chart.getStyler().setBarsOverlapped(true); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart01.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart01.java index 205402bad7739789171d32b90e480d27fb473e4a..8b6074550ce7c196f04950c4b3a8201e2cc111f4 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart01.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart01.java @@ -54,7 +54,7 @@ public class DateChart01 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Millisecond Scale").build(); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); Random random = new Random(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart02.java index f57e41505ffade138de8c956fc54980b4bb10e7b..7468de5f60613ba4cc56dc3d7b560e9ace3be106 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart02.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart02.java @@ -47,7 +47,7 @@ public class DateChart02 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Second Scale").build(); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); // generate data List<Date> xData = new ArrayList<Date>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart03.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart03.java index 0ff35af1b8bd3fdb290957166bf83066049fa4b0..d3d70a9dc78a18ad03c12940913495e94f7c6253 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart03.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart03.java @@ -47,7 +47,7 @@ public class DateChart03 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Minute Scale").build(); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); // generate data List<Date> xData = new ArrayList<Date>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart04.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart04.java index 68f9d4057633ebd8b3196306b21dcb59b3548bf0..b8b9b5cade6cbf338d90960f0f945d039d45b4ee 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart04.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart04.java @@ -47,7 +47,7 @@ public class DateChart04 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Hour Scale").build(); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); // generate data List<Date> xData = new ArrayList<Date>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart05.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart05.java index 571a355708f0c4b24278fc100ea51952e9fc0aaa..ae1cea1657567c06516a52ca93d227138954a0b7 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart05.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart05.java @@ -47,7 +47,7 @@ public class DateChart05 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Day Scale").build(); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); // generate data List<Date> xData = new ArrayList<Date>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart06.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart06.java index 6751636de912bdb6a35f36928ce5152bdc8f4822..5b0f347014f1bbc4e01ccde588d8a4598a76bed1 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart06.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart06.java @@ -47,7 +47,7 @@ public class DateChart06 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Month Scale").build(); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); // generate data List<Date> xData = new ArrayList<Date>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart07.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart07.java index 94c25f48dcdd8a8dd4e778aa1cd7b5cff0e1856e..fcf751c545e7a3efc321ec0e6d5e6fd77384b37f 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart07.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart07.java @@ -47,7 +47,7 @@ public class DateChart07 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Year Scale").build(); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); // generate data List<Date> xData = new ArrayList<Date>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart08.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart08.java index 10906660cac241825b1bc50e578efe666af11731..24b527a517ebde91bb318ee2b13599e06ebaf1ab 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart08.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart08.java @@ -52,9 +52,9 @@ public class DateChart08 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Rotated Tick Labels").build(); - chart.getStyleManager().setLegendVisible(false); - chart.getStyleManager().setXAxisLabelRotation(60); - chart.getStyleManager().setDatePattern("yyyy-MM-dd"); + chart.getStyler().setLegendVisible(false); + chart.getStyler().setXAxisLabelRotation(60); + chart.getStyler().setDatePattern("yyyy-MM-dd"); // generate data List<Date> xData = new ArrayList<Date>(); List<Double> yData = new ArrayList<Double>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart01.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart01.java index 4d5922fa72e5fbb152569d19cdf386b8347c6a19..9571bbea00cd8e0d66bedaa7a3d780dd3804f839 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart01.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart01.java @@ -24,7 +24,7 @@ import org.knowm.xchart.Chart_XY; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Logarithmic Y-Axis @@ -59,11 +59,11 @@ public class LineChart01 implements ExampleChart { Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("Powers of Ten").xAxisTitle("Power").yAxisTitle("Value").build(); // Customize Chart - chart.getStyleManager().setChartTitleVisible(true); - chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW); - chart.getStyleManager().setYAxisLogarithmic(true); + chart.getStyler().setChartTitleVisible(true); + chart.getStyler().setLegendPosition(LegendPosition.InsideNW); + chart.getStyler().setYAxisLogarithmic(true); // chart.getStyleManager().setXAxisLabelAlignment(TextAlignment.Right); - chart.getStyleManager().setXAxisLabelRotation(45); + chart.getStyler().setXAxisLabelRotation(45); // chart.getStyleManager().setXAxisLabelRotation(90); // chart.getStyleManager().setXAxisLabelRotation(0); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart02.java index 6343531eec437116bfc09db4c01eb9c871d23d6d..a8d5d3bf5e01f5a9e13f481b8eb009c8362ff5d6 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart02.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart02.java @@ -61,8 +61,8 @@ public class LineChart02 implements ExampleChart { Chart_XY chart = new Chart_XY(800, 600); // Customize Chart - chart.getStyleManager().setChartTitleVisible(false); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setChartTitleVisible(false); + chart.getStyler().setLegendVisible(false); // Series 1 Series_XY series1 = chart.addSeries("y=sin(x)", xData, yData); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart03.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart03.java index e2f77d7a8bdd016269a6c3eea0d4bde4bcea4426..e093737298e2df4dfbab4a11bfaaa31768462b88 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart03.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart03.java @@ -31,7 +31,7 @@ import org.knowm.xchart.Series_XY; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.colors.ChartColor; import org.knowm.xchart.internal.style.colors.XChartSeriesColors; import org.knowm.xchart.internal.style.lines.SeriesLines; @@ -76,31 +76,31 @@ public class LineChart03 implements ExampleChart { chart.setTitle("LineChart03"); chart.setXAxisTitle("X"); chart.setYAxisTitle("Y"); - chart.getStyleManager().setPlotBackgroundColor(ChartColor.getAWTColor(ChartColor.GREY)); - chart.getStyleManager().setPlotGridLinesColor(new Color(255, 255, 255)); - chart.getStyleManager().setChartBackgroundColor(Color.WHITE); - chart.getStyleManager().setLegendBackgroundColor(Color.PINK); - chart.getStyleManager().setChartFontColor(Color.MAGENTA); - chart.getStyleManager().setChartTitleBoxBackgroundColor(new Color(0, 222, 0)); - chart.getStyleManager().setChartTitleBoxVisible(true); - chart.getStyleManager().setChartTitleBoxBorderColor(Color.BLACK); - chart.getStyleManager().setPlotGridLinesVisible(false); - - chart.getStyleManager().setAxisTickPadding(20); - - chart.getStyleManager().setAxisTickMarkLength(15); - - chart.getStyleManager().setPlotPadding(20); - - chart.getStyleManager().setChartTitleFont(new Font(Font.MONOSPACED, Font.BOLD, 24)); - chart.getStyleManager().setLegendFont(new Font(Font.SERIF, Font.PLAIN, 18)); - chart.getStyleManager().setLegendPosition(LegendPosition.InsideSE); - chart.getStyleManager().setLegendSeriesLineLength(12); - chart.getStyleManager().setAxisTitleFont(new Font(Font.SANS_SERIF, Font.ITALIC, 18)); - chart.getStyleManager().setAxisTickLabelsFont(new Font(Font.SERIF, Font.PLAIN, 11)); - chart.getStyleManager().setDatePattern("dd-MMM"); - chart.getStyleManager().setDecimalPattern("#0.000"); - chart.getStyleManager().setLocale(Locale.GERMAN); + chart.getStyler().setPlotBackgroundColor(ChartColor.getAWTColor(ChartColor.GREY)); + chart.getStyler().setPlotGridLinesColor(new Color(255, 255, 255)); + chart.getStyler().setChartBackgroundColor(Color.WHITE); + chart.getStyler().setLegendBackgroundColor(Color.PINK); + chart.getStyler().setChartFontColor(Color.MAGENTA); + chart.getStyler().setChartTitleBoxBackgroundColor(new Color(0, 222, 0)); + chart.getStyler().setChartTitleBoxVisible(true); + chart.getStyler().setChartTitleBoxBorderColor(Color.BLACK); + chart.getStyler().setPlotGridLinesVisible(false); + + chart.getStyler().setAxisTickPadding(20); + + chart.getStyler().setAxisTickMarkLength(15); + + chart.getStyler().setPlotPadding(20); + + chart.getStyler().setChartTitleFont(new Font(Font.MONOSPACED, Font.BOLD, 24)); + chart.getStyler().setLegendFont(new Font(Font.SERIF, Font.PLAIN, 18)); + chart.getStyler().setLegendPosition(LegendPosition.InsideSE); + chart.getStyler().setLegendSeriesLineLength(12); + chart.getStyler().setAxisTitleFont(new Font(Font.SANS_SERIF, Font.ITALIC, 18)); + chart.getStyler().setAxisTickLabelsFont(new Font(Font.SERIF, Font.PLAIN, 11)); + chart.getStyler().setDatePattern("dd-MMM"); + chart.getStyler().setDecimalPattern("#0.000"); + chart.getStyler().setLocale(Locale.GERMAN); Series_XY series = chart.addSeries("Fake Data", xData, yData); series.setLineColor(XChartSeriesColors.BLUE); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart04.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart04.java index c92d5e421a2e811d2bddeba7644e4f374822a6de..6d024a6d067e083b7b9eac21ad1ada45f3e13747 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart04.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart04.java @@ -47,7 +47,7 @@ public class LineChart04 implements ExampleChart { chart.setTitle("LineChart04"); chart.setXAxisTitle("X"); chart.setYAxisTitle("Y"); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); for (int i = 0; i < 200; i++) { Series_XY series = chart.addSeries("A" + i, new double[] { Math.random() / 1000, Math.random() / 1000 }, new double[] { Math.random() / -1000, Math.random() / -1000 }); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart05.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart05.java index 39d3666ae5093b5f7e73d348a7b6a4f0671fba9b..6cf8e42adccd41302829e29f743baafd7af7ac19 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart05.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart05.java @@ -23,7 +23,7 @@ import org.knowm.xchart.Series_XY; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.lines.SeriesLines; import org.knowm.xchart.internal.style.markers.SeriesMarkers; @@ -56,7 +56,7 @@ public class LineChart05 implements ExampleChart { chart.setTitle("LineChart05"); chart.setXAxisTitle("X"); chart.setYAxisTitle("Y"); - chart.getStyleManager().setLegendPosition(LegendPosition.InsideSW); + chart.getStyler().setLegendPosition(LegendPosition.InsideSW); double[] xData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5, 6 }; double[] yData = new double[] { 106, 44, 26, 10, 7.5, 3.4, .88 }; @@ -72,13 +72,13 @@ public class LineChart05 implements ExampleChart { series2.setLineStyle(SeriesLines.DASH_DASH); series2.setLineColor(Color.BLACK); - chart.getStyleManager().setYAxisLogarithmic(true); + chart.getStyler().setYAxisLogarithmic(true); - chart.getStyleManager().setYAxisMin(0.01); - chart.getStyleManager().setYAxisMax(1000); + chart.getStyler().setYAxisMin(0.01); + chart.getStyler().setYAxisMax(1000); - chart.getStyleManager().setXAxisMin(2); - chart.getStyleManager().setXAxisMax(7); + chart.getStyler().setXAxisMin(2); + chart.getStyler().setXAxisMax(7); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart06.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart06.java index 9f02c45762de565f1352cdd897654529593e3fde..59ab0cacddd20598ae2759f109b727621b293a5d 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart06.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart06.java @@ -56,13 +56,13 @@ public class LineChart06 implements ExampleChart { Chart_XY chart = new Chart_XY(800, 600); - chart.getStyleManager().setYAxisLogarithmic(true); + chart.getStyler().setYAxisLogarithmic(true); - chart.getStyleManager().setYAxisMin(.08); + chart.getStyler().setYAxisMin(.08); - chart.getStyleManager().setYAxisMax(1000); + chart.getStyler().setYAxisMax(1000); - chart.getStyleManager().setErrorBarsColor(Color.black); + chart.getStyler().setErrorBarsColor(Color.black); Series_XY series1 = chart.addSeries("Error bar\ntest data", xData, yData1, errdata); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart07.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart07.java index c54cc7b244299a2b6bb66e6ed0e5da8c10710fe1..6d3bb600034e2d9dd56ecf8a0be91c06cc43fe41 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart07.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/line/LineChart07.java @@ -25,8 +25,8 @@ import org.knowm.xchart.Series_Category.ChartCategorySeriesRenderStyle; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.ChartTheme; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.markers.SeriesMarkers; /** @@ -51,16 +51,16 @@ public class LineChart07 implements ExampleChart { // Create Chart Chart_Category chart = new Chart_Category(1024, 768, ChartTheme.GGPlot2); - chart.getStyleManager().setChartCategorySeriesRenderStyle(ChartCategorySeriesRenderStyle.Line); + chart.getStyler().setChartCategorySeriesRenderStyle(ChartCategorySeriesRenderStyle.Line); // Customize Chart chart.setTitle("ThreadPoolBenchmark"); chart.setXAxisTitle("Threads"); chart.setYAxisTitle("Executions"); - chart.getStyleManager().setXAxisLabelRotation(270); - chart.getStyleManager().setLegendPosition(LegendPosition.OutsideE); - chart.getStyleManager().setBarWidthPercentage(0); - chart.getStyleManager().setBarsOverlapped(true); + chart.getStyler().setXAxisLabelRotation(270); + chart.getStyler().setLegendPosition(LegendPosition.OutsideE); + chart.getStyler().setBarWidthPercentage(0); + chart.getStyler().setBarsOverlapped(true); // Declare data List<String> xAxisKeys = Arrays.asList(new String[] { "release-0.5", "release-0.6", "release-0.7", "release-0.8", "release-0.9", "release-1.0.0", "release-1.1.0", "release-1.2.0", "release-1.3.0", @@ -99,7 +99,7 @@ public class LineChart07 implements ExampleChart { series.setMarker(SeriesMarkers.NONE); // series.setChartCategorySeriesRenderStyle(ChartCategorySeriesRenderStyle.Line); } - chart.getStyleManager().setYAxisLogarithmic(true); + chart.getStyler().setYAxisLogarithmic(true); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java index e8cb40a6f30d5593ef25e6d72dee87144b056d0c..2e3ff91472c30c5a92829d5ca51118a15571674f 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/pie/PieChart02.java @@ -53,7 +53,7 @@ public class PieChart02 implements ExampleChart<Chart_Pie> { chart.addSeries("Zinc", 40); Color[] sliceColors = new Color[] { new Color(224, 68, 14), new Color(230, 105, 62), new Color(236, 143, 110), new Color(243, 180, 159), new Color(246, 199, 182) }; - chart.getStyleManager().setSeriesColors(sliceColors); + chart.getStyler().setSeriesColors(sliceColors); return chart; } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart01.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart01.java index 1546be81534d17aedbf346847e49ccc53073f693..6ecbef2cad6d629a34237f8d719d403668af6ede 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart01.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart01.java @@ -25,7 +25,7 @@ import org.knowm.xchart.Series_XY.ChartXYSeriesRenderStyle; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Gaussian Blob @@ -60,12 +60,12 @@ public class ScatterChart01 implements ExampleChart { // Create Chart Chart_XY chart = new Chart_XY(800, 600); - chart.getStyleManager().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Scatter); + chart.getStyler().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Scatter); // Customize Chart - chart.getStyleManager().setChartTitleVisible(false); - chart.getStyleManager().setLegendPosition(LegendPosition.InsideSW); - chart.getStyleManager().setMarkerSize(16); + chart.getStyler().setChartTitleVisible(false); + chart.getStyler().setLegendPosition(LegendPosition.InsideSW); + chart.getStyler().setMarkerSize(16); // Series chart.addSeries("Gaussian Blob", xData, yData); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart02.java index bdbb9304af7695af98f53d910914a3de06159c2d..230cb384f7d9a721f6b2317bc004babbb80ee4bb 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart02.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart02.java @@ -25,7 +25,7 @@ import org.knowm.xchart.Series_XY.ChartXYSeriesRenderStyle; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * Logarithmic Data @@ -64,11 +64,11 @@ public class ScatterChart02 implements ExampleChart { // Create Chart Chart_XY chart = new Chart_XY(800, 600); chart.setTitle("Logarithmic Data"); - chart.getStyleManager().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Scatter); - chart.getStyleManager().setXAxisLogarithmic(true); + chart.getStyler().setChartXYSeriesRenderStyle(ChartXYSeriesRenderStyle.Scatter); + chart.getStyler().setXAxisLogarithmic(true); // Customize Chart - chart.getStyleManager().setLegendPosition(LegendPosition.InsideN); + chart.getStyler().setLegendPosition(LegendPosition.InsideN); // Series chart.addSeries("logarithmic data", xData, yData); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart04.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart04.java index f62a81b3464368ea3f85dcd4d020cdd06aaea6b2..5c4cbeaf0b256c144c5794a021d778730b8c8b18 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart04.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/scatter/ScatterChart04.java @@ -66,10 +66,10 @@ public class ScatterChart04 implements ExampleChart { Chart_XY chart = new ChartBuilder_XY().width(800).height(600).title("ScatterChart04").xAxisTitle("X").yAxisTitle("Y").build(); // Customize Chart - chart.getStyleManager().setChartTitleVisible(false); - chart.getStyleManager().setLegendVisible(false); - chart.getStyleManager().setAxisTitlesVisible(false); - chart.getStyleManager().setXAxisDecimalPattern("0.0000000"); + chart.getStyler().setChartTitleVisible(false); + chart.getStyler().setLegendVisible(false); + chart.getStyler().setAxisTitlesVisible(false); + chart.getStyler().setXAxisDecimalPattern("0.0000000"); // Series Series_XY series = chart.addSeries("10^(-x)", xData, yData, errorBars); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart01.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart01.java index 35e6d989eccbe1d168b19cfe20cbf4f217a54a83..ac794c7894d6f7a805991edc1773c17f5c46a5de 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart01.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart01.java @@ -64,7 +64,7 @@ public class ThemeChart01 implements ExampleChart { String seriesName = "y=" + 2 * i + "x-" + i * b + "b"; chart.addSeries(seriesName, xData, yData); - chart.getStyleManager().setMarkerSize(11); + chart.getStyler().setMarkerSize(11); } return chart; diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart02.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart02.java index 0766fbcdea580acfa0ff64bee730b3aae765d4bb..868e25d3955e9342f7885b9f278a163b30140391 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart02.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart02.java @@ -21,7 +21,7 @@ import org.knowm.xchart.Chart_XY; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; /** * GGPlot2 Theme diff --git a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart03.java b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart03.java index 7d45de8a7939bdaa3de2e5adb98e38f1143adec1..38b28ee876b8836c3daa9125abec1658129a3c0f 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart03.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/theme/ThemeChart03.java @@ -28,7 +28,7 @@ import org.knowm.xchart.Chart_XY; import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.demo.charts.ExampleChart; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; /** * Matlab Theme @@ -53,8 +53,8 @@ public class ThemeChart03 implements ExampleChart { // Create Chart Chart_XY chart = new ChartBuilder_XY().width(800).height(600).theme(ChartTheme.Matlab).title("Matlab Theme").xAxisTitle("X").yAxisTitle("Y").build(); - chart.getStyleManager().setPlotGridLinesVisible(false); - chart.getStyleManager().setXAxisTickMarkSpacingHint(100); + chart.getStyler().setPlotGridLinesVisible(false); + chart.getStyler().setXAxisTickMarkSpacingHint(100); // generate data List<Date> xData = new ArrayList<Date>(); List<Double> y1Data = new ArrayList<Double>(); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarLogTest.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarLogTest.java index 5fb51619ad9fe804bc794672b6dc6e2b2fb0b27d..51eaa940f0fad62dfac4804a9a68240bc0cfc556 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarLogTest.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarLogTest.java @@ -46,13 +46,13 @@ public class ErrorBarLogTest { Chart_XY mychart = new Chart_XY(1200, 800); - mychart.getStyleManager().setYAxisLogarithmic(true); // set log or linear Y axis + mychart.getStyler().setYAxisLogarithmic(true); // set log or linear Y axis - mychart.getStyleManager().setYAxisMin(.08); + mychart.getStyler().setYAxisMin(.08); - mychart.getStyleManager().setYAxisMax(1000); + mychart.getStyler().setYAxisMax(1000); - mychart.getStyleManager().setErrorBarsColor(Color.black); + mychart.getStyler().setErrorBarsColor(Color.black); Series_XY series1 = mychart.addSeries("Error bar test data", xData, yData1, errdata); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarTest.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarTest.java index 5f4c2db347180c6db3f06dda4897c4dd37ae48a0..fd4a58311cfb53cc5578ced6a791134278934c34 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarTest.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/ErrorBarTest.java @@ -40,9 +40,9 @@ public class ErrorBarTest { double[] yData3 = new double[] { 150, 120, 110, 100, 90, 70, 60 }; Chart_XY mychart = new Chart_XY(900, 700); - mychart.getStyleManager().setYAxisMin(0); - mychart.getStyleManager().setYAxisMax(150); - mychart.getStyleManager().setErrorBarsColor(Color.black); + mychart.getStyler().setYAxisMin(0); + mychart.getStyler().setYAxisMax(150); + mychart.getStyler().setErrorBarsColor(Color.black); Series_XY series1 = mychart.addSeries("Error bar test data", xData, yData1, errdata); Series_XY series2 = mychart.addSeries("Y+error", xData, yData2); Series_XY series3 = mychart.addSeries("Y-error", xData, yData3); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutHorizontalLines.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutHorizontalLines.java index 2b3a8533d3af68ead04321cb61c8b64fb8d08f2d..c923833137bf079fca499637afb0f2aeb18ead6e 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutHorizontalLines.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutHorizontalLines.java @@ -39,9 +39,9 @@ public class Example0WithoutHorizontalLines { for (int i = 0; i < numCharts; i++) { Chart_XY chart = new ChartBuilder_XY().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build(); - chart.getStyleManager().setYAxisMin(-10); - chart.getStyleManager().setYAxisMax(10); - chart.getStyleManager().setPlotGridHorizontalLinesVisible(false); + chart.getStyler().setYAxisMin(-10); + chart.getStyler().setYAxisMax(10); + chart.getStyler().setPlotGridHorizontalLinesVisible(false); Series_XY series = chart.addSeries("" + i, null, getRandomWalk(200)); series.setMarker(SeriesMarkers.NONE); charts.add(chart); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalAndHorizontalLines.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalAndHorizontalLines.java index 03ccf9a7376ec558a6852139a0fd4cbc6d07d47d..a1608009af7d9d2147f6125b63549ffdf8a0bf53 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalAndHorizontalLines.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalAndHorizontalLines.java @@ -41,10 +41,10 @@ public class Example0WithoutVerticalAndHorizontalLines { for (int i = 0; i < numCharts; i++) { Chart_XY chart = new ChartBuilder_XY().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build(); - chart.getStyleManager().setYAxisMin(-10); - chart.getStyleManager().setYAxisMax(10); - chart.getStyleManager().setPlotGridVerticalLinesVisible(false); - chart.getStyleManager().setPlotGridHorizontalLinesVisible(false); + chart.getStyler().setYAxisMin(-10); + chart.getStyler().setYAxisMax(10); + chart.getStyler().setPlotGridVerticalLinesVisible(false); + chart.getStyler().setPlotGridHorizontalLinesVisible(false); Series_XY series = chart.addSeries("" + i, null, getRandomWalk(200)); series.setMarker(SeriesMarkers.NONE); charts.add(chart); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalLines.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalLines.java index 42e101435eaebc491ecd6976f673368d99edb8ea..ae2e8b8d10c566cc2e31b7d5a05b7ba292e91491 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalLines.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example0WithoutVerticalLines.java @@ -39,9 +39,9 @@ public class Example0WithoutVerticalLines { for (int i = 0; i < numCharts; i++) { Chart_XY chart = new ChartBuilder_XY().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build(); - chart.getStyleManager().setYAxisMin(-10); - chart.getStyleManager().setYAxisMax(10); - chart.getStyleManager().setPlotGridVerticalLinesVisible(false); + chart.getStyler().setYAxisMin(-10); + chart.getStyler().setYAxisMax(10); + chart.getStyler().setPlotGridVerticalLinesVisible(false); Series_XY series = chart.addSeries("" + i, null, getRandomWalk(200)); series.setMarker(SeriesMarkers.NONE); charts.add(chart); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example2.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example2.java index db660fbc4899de32da42e01fc90109d02810a113..aff6fe7e3fa78376e2f68ceda9128cf1995e6f9c 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example2.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/Example2.java @@ -41,8 +41,8 @@ public class Example2 { for (int i = 0; i < numCharts; i++) { Chart_XY chart = new ChartBuilder_XY().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build(); - chart.getStyleManager().setYAxisMin(-10); - chart.getStyleManager().setYAxisMax(10); + chart.getStyler().setYAxisMin(-10); + chart.getStyler().setYAxisMax(10); Series_XY series = chart.addSeries("" + i, null, getRandomWalk(200)); series.setMarker(SeriesMarkers.NONE); charts.add(chart); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue111.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue111.java index 3bdb025bed7167e7d95ffe090fca205749fc6612..221edb8af2021c7cdd29dff7796ad31abeadf08b 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue111.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue111.java @@ -34,7 +34,7 @@ public class TestForIssue111 { Chart_Category chart = new ChartBuilder_Category().width(640).height(480).build(); chart.addSeries("test", x, y); - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); new SwingWrapper(chart).displayChart(); } diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue127.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue127.java new file mode 100644 index 0000000000000000000000000000000000000000..b7e8c36a28e54359c28cdfce35fb9ca8c42c974a --- /dev/null +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue127.java @@ -0,0 +1,42 @@ +/** + * Copyright 2015-2016 Knowm Inc. (http://knowm.org) and contributors. + * Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.knowm.xchart.standalone; + +import org.knowm.xchart.ChartBuilder_XY; +import org.knowm.xchart.Chart_XY; +import org.knowm.xchart.SwingWrapper; + +/** + * @author timmolter + */ +public class TestForIssue127 { + + public static void main(String[] args) { + + int[] x = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; + int[] y = new int[] { 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1 }; + // int[] x = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }; + // int[] y = new int[] { 1, 0, 1, 0, 1, 0, 0, 0 }; + + Chart_XY chart = new ChartBuilder_XY().width(640).height(480).xAxisTitle("x").yAxisTitle("y").build(); + chart.setTitle("TEst"); + // chart.addSeries("test", x, y); + chart.getStyler().setLegendVisible(false); + new SwingWrapper(chart).displayChart(); + } + +} diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue83.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue83.java index 862d35289b25cb40d716410843b71e8af9afe67d..ce10a7db5003278c300beb3d6dc46a15a5729842 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue83.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue83.java @@ -20,8 +20,8 @@ import java.io.IOException; import org.knowm.xchart.Chart_XY; import org.knowm.xchart.SwingWrapper; -import org.knowm.xchart.internal.style.StyleManager; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.lines.SeriesLines; /** @@ -32,7 +32,7 @@ public class TestForIssue83 { public static void main(String[] args) throws IOException { final Chart_XY chart = new Chart_XY(500, 580); - final StyleManager styleManager = chart.getStyleManager(); + final Styler styleManager = chart.getStyler(); styleManager.setLegendPosition(LegendPosition.InsideNW); styleManager.setLegendVisible(false); diff --git a/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue98.java b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue98.java index ef218ce5bf2d6ae2457a1f7d7c52791f3a469fac..763e14a2381840f61b2cb2f77b0c93e28aeddcc6 100644 --- a/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue98.java +++ b/xchart-demo/src/main/java/org/knowm/xchart/standalone/TestForIssue98.java @@ -23,7 +23,7 @@ import java.util.Date; import org.knowm.xchart.Chart_XY; import org.knowm.xchart.Styler_XY; import org.knowm.xchart.SwingWrapper; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * @author timmolter @@ -33,7 +33,7 @@ public class TestForIssue98 { public static void main(String[] args) throws IOException { final Chart_XY chart = new Chart_XY(1920, 1080); - Styler_XY manager = chart.getStyleManager(); + Styler_XY manager = chart.getStyler(); manager.setLegendPosition(LegendPosition.InsideNW); manager.setYAxisLogarithmic(true); diff --git a/xchart/src/main/java/org/knowm/xchart/CSVImporter.java b/xchart/src/main/java/org/knowm/xchart/CSVImporter.java index 77f7f2517b94221c0788f8cd15c6b309dfc8ab32..6a5f1c06e2410fd12d077f04fe3555224882a07b 100644 --- a/xchart/src/main/java/org/knowm/xchart/CSVImporter.java +++ b/xchart/src/main/java/org/knowm/xchart/CSVImporter.java @@ -23,7 +23,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; /** * This class is used to create a Chart object from a folder containing one or more CSV files. The parent folder's name becomes the title of the diff --git a/xchart/src/main/java/org/knowm/xchart/Chart_Category.java b/xchart/src/main/java/org/knowm/xchart/Chart_Category.java index 62953ee6b36327e7e8e0808050465e2143a7c94d..060ad0af520f21feb1e58092fae80a0b04c9cd06 100644 --- a/xchart/src/main/java/org/knowm/xchart/Chart_Category.java +++ b/xchart/src/main/java/org/knowm/xchart/Chart_Category.java @@ -25,12 +25,12 @@ import java.util.List; import org.knowm.xchart.internal.chartpart.Axis.AxisDataType; import org.knowm.xchart.internal.chartpart.AxisPair; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.chartpart.LegendAxesChart; +import org.knowm.xchart.internal.chartpart.Legend_AxesChart; import org.knowm.xchart.internal.chartpart.Plot_Category; import org.knowm.xchart.internal.style.SeriesColorMarkerLineStyle; import org.knowm.xchart.internal.style.SeriesColorMarkerLineStyleCycler; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; -import org.knowm.xchart.internal.style.Theme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; +import org.knowm.xchart.internal.style.Theme_; /** * @author timmolter @@ -48,7 +48,7 @@ public class Chart_Category extends Chart<Styler_Category, Series_Category> { super(width, height, new Styler_Category()); axisPair = new AxisPair(this); plot = new Plot_Category(this); - chartLegend = new LegendAxesChart(this); + legend = new Legend_AxesChart(this); } /** @@ -58,10 +58,10 @@ public class Chart_Category extends Chart<Styler_Category, Series_Category> { * @param height * @param theme - pass in a instance of Theme class, probably a custom Theme. */ - public Chart_Category(int width, int height, Theme theme) { + public Chart_Category(int width, int height, Theme_ theme) { this(width, height); - styleManager.setTheme(theme); + styler.setTheme(theme); } /** @@ -229,29 +229,29 @@ public class Chart_Category extends Chart<Styler_Category, Series_Category> { public void paint(Graphics2D g) { // Sanity checks - if (getSeriesMap().isEmpty()) { - throw new RuntimeException("No series defined for Chart!!!"); - } + // if (getSeriesMap().isEmpty()) { + // throw new RuntimeException("No series defined for Chart!!!"); + // } // set the series render styles if they are not set. Legend and Plot need it. for (Series_Category seriesCategory : getSeriesMap().values()) { Series_Category.ChartCategorySeriesRenderStyle seriesType = seriesCategory.getChartCategorySeriesRenderStyle(); // would be directly set if (seriesType == null) { // wasn't overridden, use default from Style Manager - seriesCategory.setChartCategorySeriesRenderStyle(getStyleManager().getChartCategorySeriesRenderStyle()); + seriesCategory.setChartCategorySeriesRenderStyle(getStyler().getChartCategorySeriesRenderStyle()); } } setSeriesStyles(); // paint chart main background g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // global rendering hint - g.setColor(styleManager.getChartBackgroundColor()); + g.setColor(styler.getChartBackgroundColor()); Shape rect = new Rectangle2D.Double(0, 0, getWidth(), getHeight()); g.fill(rect); axisPair.paint(g); plot.paint(g); chartTitle.paint(g); - chartLegend.paint(g); + legend.paint(g); g.dispose(); } @@ -261,8 +261,8 @@ public class Chart_Category extends Chart<Styler_Category, Series_Category> { */ public void setSeriesStyles() { - SeriesColorMarkerLineStyleCycler seriesColorMarkerLineStyleCycler = new SeriesColorMarkerLineStyleCycler(getStyleManager().getSeriesColors(), getStyleManager().getSeriesMarkers(), - getStyleManager().getSeriesLines()); + SeriesColorMarkerLineStyleCycler seriesColorMarkerLineStyleCycler = new SeriesColorMarkerLineStyleCycler(getStyler().getSeriesColors(), getStyler().getSeriesMarkers(), + getStyler().getSeriesLines()); for (Series_Category series : getSeriesMap().values()) { SeriesColorMarkerLineStyle seriesColorMarkerLineStyle = seriesColorMarkerLineStyleCycler.getNextSeriesColorMarkerLineStyle(); diff --git a/xchart/src/main/java/org/knowm/xchart/Chart_Pie.java b/xchart/src/main/java/org/knowm/xchart/Chart_Pie.java index c290d07456d5b7e5fe2dd91d2689b76916a473e6..26bb75fb8c456983a135af21db9fc79bcfbd1b0d 100644 --- a/xchart/src/main/java/org/knowm/xchart/Chart_Pie.java +++ b/xchart/src/main/java/org/knowm/xchart/Chart_Pie.java @@ -23,12 +23,12 @@ import java.awt.geom.Rectangle2D; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.chartpart.LegendPie; +import org.knowm.xchart.internal.chartpart.Legend_Pie; import org.knowm.xchart.internal.chartpart.Plot_Pie; import org.knowm.xchart.internal.style.SeriesColorMarkerLineStyle; import org.knowm.xchart.internal.style.SeriesColorMarkerLineStyleCycler; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; -import org.knowm.xchart.internal.style.Theme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; +import org.knowm.xchart.internal.style.Theme_; /** * @author timmolter @@ -45,7 +45,7 @@ public class Chart_Pie extends Chart<Styler_Pie, Series_Pie> { super(width, height, new Styler_Pie()); plot = new Plot_Pie(this); - chartLegend = new LegendPie(this); + legend = new Legend_Pie(this); } /** @@ -55,10 +55,10 @@ public class Chart_Pie extends Chart<Styler_Pie, Series_Pie> { * @param height * @param theme - pass in a instance of Theme class, probably a custom Theme. */ - public Chart_Pie(int width, int height, Theme theme) { + public Chart_Pie(int width, int height, Theme_ theme) { this(width, height); - styleManager.setTheme(theme); + styler.setTheme(theme); } /** @@ -115,29 +115,28 @@ public class Chart_Pie extends Chart<Styler_Pie, Series_Pie> { public void paint(Graphics2D g) { // Sanity checks - if (getSeriesMap().isEmpty()) { - throw new RuntimeException("No series defined for Chart!!!"); - } + // if (getSeriesMap().isEmpty()) { + // throw new RuntimeException("No series defined for Chart!!!"); + // } // set the series types if they are not set. Legend and Plot need it. for (Series_Pie seriesPie : getSeriesMap().values()) { Series_Pie.ChartPieSeriesRenderStyle seriesType = seriesPie.getChartPieSeriesRenderStyle(); // would be directly set if (seriesType == null) { // wasn't overridden, use default from Style Manager - seriesPie.setChartPieSeriesRenderStyle(getStyleManager().getChartPieSeriesRenderStyle()); + seriesPie.setChartPieSeriesRenderStyle(getStyler().getChartPieSeriesRenderStyle()); } } - setSeriesStyles(); // paint chart main background g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // global rendering hint - g.setColor(styleManager.getChartBackgroundColor()); + g.setColor(styler.getChartBackgroundColor()); Shape rect = new Rectangle2D.Double(0, 0, getWidth(), getHeight()); g.fill(rect); plot.paint(g); chartTitle.paint(g); - chartLegend.paint(g); + legend.paint(g); g.dispose(); } @@ -147,8 +146,8 @@ public class Chart_Pie extends Chart<Styler_Pie, Series_Pie> { */ public void setSeriesStyles() { - SeriesColorMarkerLineStyleCycler seriesColorMarkerLineStyleCycler = new SeriesColorMarkerLineStyleCycler(getStyleManager().getSeriesColors(), getStyleManager().getSeriesMarkers(), - getStyleManager().getSeriesLines()); + SeriesColorMarkerLineStyleCycler seriesColorMarkerLineStyleCycler = new SeriesColorMarkerLineStyleCycler(getStyler().getSeriesColors(), getStyler().getSeriesMarkers(), + getStyler().getSeriesLines()); for (Series series : getSeriesMap().values()) { SeriesColorMarkerLineStyle seriesColorMarkerLineStyle = seriesColorMarkerLineStyleCycler.getNextSeriesColorMarkerLineStyle(); diff --git a/xchart/src/main/java/org/knowm/xchart/Chart_XY.java b/xchart/src/main/java/org/knowm/xchart/Chart_XY.java index 6246c56b66cc47e3fb07b938c8626dba76b4c97a..1350d81cc505a0cead9cd86c8977146ba291469e 100644 --- a/xchart/src/main/java/org/knowm/xchart/Chart_XY.java +++ b/xchart/src/main/java/org/knowm/xchart/Chart_XY.java @@ -25,12 +25,12 @@ import java.util.List; import org.knowm.xchart.internal.chartpart.Axis.AxisDataType; import org.knowm.xchart.internal.chartpart.AxisPair; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.chartpart.LegendAxesChart; +import org.knowm.xchart.internal.chartpart.Legend_AxesChart; import org.knowm.xchart.internal.chartpart.Plot_XY; import org.knowm.xchart.internal.style.SeriesColorMarkerLineStyle; import org.knowm.xchart.internal.style.SeriesColorMarkerLineStyleCycler; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; -import org.knowm.xchart.internal.style.Theme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; +import org.knowm.xchart.internal.style.Theme_; /** * @author timmolter @@ -48,7 +48,7 @@ public class Chart_XY extends Chart<Styler_XY, Series_XY> { super(width, height, new Styler_XY()); axisPair = new AxisPair(this); plot = new Plot_XY(this); - chartLegend = new LegendAxesChart(this); + legend = new Legend_AxesChart(this); } /** @@ -58,10 +58,10 @@ public class Chart_XY extends Chart<Styler_XY, Series_XY> { * @param height * @param theme - pass in a instance of Theme class, probably a custom Theme. */ - public Chart_XY(int width, int height, Theme theme) { + public Chart_XY(int width, int height, Theme_ theme) { this(width, height); - styleManager.setTheme(theme); + styler.setTheme(theme); } /** @@ -229,29 +229,29 @@ public class Chart_XY extends Chart<Styler_XY, Series_XY> { public void paint(Graphics2D g) { // Sanity checks - if (getSeriesMap().isEmpty()) { - throw new RuntimeException("No series defined for Chart!!!"); - } + // if (getSeriesMap().isEmpty()) { + // throw new RuntimeException("No series defined for Chart!!!"); + // } // set the series render styles if they are not set. Legend and Plot need it. for (Series_XY seriesXY : getSeriesMap().values()) { Series_XY.ChartXYSeriesRenderStyle chartXYSeriesRenderStyle = seriesXY.getChartXYSeriesRenderStyle(); // would be directly set if (chartXYSeriesRenderStyle == null) { // wasn't overridden, use default from Style Manager - seriesXY.setChartXYSeriesRenderStyle(getStyleManager().getChartXYSeriesRenderStyle()); + seriesXY.setChartXYSeriesRenderStyle(getStyler().getChartXYSeriesRenderStyle()); } } setSeriesStyles(); // paint chart main background g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // global rendering hint - g.setColor(styleManager.getChartBackgroundColor()); + g.setColor(styler.getChartBackgroundColor()); Shape rect = new Rectangle2D.Double(0, 0, getWidth(), getHeight()); g.fill(rect); axisPair.paint(g); plot.paint(g); chartTitle.paint(g); - chartLegend.paint(g); + legend.paint(g); g.dispose(); } @@ -261,8 +261,8 @@ public class Chart_XY extends Chart<Styler_XY, Series_XY> { */ public void setSeriesStyles() { - SeriesColorMarkerLineStyleCycler seriesColorMarkerLineStyleCycler = new SeriesColorMarkerLineStyleCycler(getStyleManager().getSeriesColors(), getStyleManager().getSeriesMarkers(), - getStyleManager().getSeriesLines()); + SeriesColorMarkerLineStyleCycler seriesColorMarkerLineStyleCycler = new SeriesColorMarkerLineStyleCycler(getStyler().getSeriesColors(), getStyler().getSeriesMarkers(), + getStyler().getSeriesLines()); for (Series_XY series : getSeriesMap().values()) { SeriesColorMarkerLineStyle seriesColorMarkerLineStyle = seriesColorMarkerLineStyleCycler.getNextSeriesColorMarkerLineStyle(); diff --git a/xchart/src/main/java/org/knowm/xchart/Histogram.java b/xchart/src/main/java/org/knowm/xchart/Histogram.java index 619889d08715cebc7049cf394b6bdfdc49cc70a2..8b1fdc6d7816895490b56cda17d9e205a3c81769 100644 --- a/xchart/src/main/java/org/knowm/xchart/Histogram.java +++ b/xchart/src/main/java/org/knowm/xchart/Histogram.java @@ -22,7 +22,7 @@ import java.util.Iterator; import java.util.List; /** - * This class can be used to create histogram data for histogram bar charts + * This class can be used to create histogram * * @author timmolter */ diff --git a/xchart/src/main/java/org/knowm/xchart/QuickChart.java b/xchart/src/main/java/org/knowm/xchart/QuickChart.java index 7ce6f04266d1994ed7290b0d4706a518b6421049..45060305769b4b55486aa7582b352ff8c187c441 100644 --- a/xchart/src/main/java/org/knowm/xchart/QuickChart.java +++ b/xchart/src/main/java/org/knowm/xchart/QuickChart.java @@ -88,7 +88,7 @@ public final class QuickChart { series = chart.addSeries(seriesNames[i], xData, yData[i]); } else { - chart.getStyleManager().setLegendVisible(false); + chart.getStyler().setLegendVisible(false); series = chart.addSeries(" " + i, xData, yData[i]); } series.setMarker(SeriesMarkers.NONE); diff --git a/xchart/src/main/java/org/knowm/xchart/Styler_Category.java b/xchart/src/main/java/org/knowm/xchart/Styler_Category.java index e626d6208c4dbd2eb64753db106d3a4e791238b0..fc180b132a2b4806c793344bdc3da06af91e17f3 100644 --- a/xchart/src/main/java/org/knowm/xchart/Styler_Category.java +++ b/xchart/src/main/java/org/knowm/xchart/Styler_Category.java @@ -17,13 +17,13 @@ package org.knowm.xchart; import org.knowm.xchart.Series_Category.ChartCategorySeriesRenderStyle; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; -import org.knowm.xchart.internal.style.Theme; +import org.knowm.xchart.internal.style.Styler_AxesChart; +import org.knowm.xchart.internal.style.Theme_; /** * @author timmolter */ -public class Styler_Category extends StyleManagerAxesChart { +public class Styler_Category extends Styler_AxesChart { private ChartCategorySeriesRenderStyle chartCategorySeriesRenderStyle; @@ -58,17 +58,17 @@ public class Styler_Category extends StyleManagerAxesChart { } /** - * Set the theme the style manager should use + * Set the theme the styler should use * * @param theme */ - protected void setTheme(Theme theme) { + protected void setTheme(Theme_ theme) { this.theme = theme; super.setAllStyles(); } - public Theme getTheme() { + public Theme_ getTheme() { return theme; } diff --git a/xchart/src/main/java/org/knowm/xchart/Styler_Pie.java b/xchart/src/main/java/org/knowm/xchart/Styler_Pie.java index a1a2a326a9ce0bf22f348882b61d9d1562bdfac0..3608a056ad7fbb29c1c3c53c6b4556cb1677ea19 100644 --- a/xchart/src/main/java/org/knowm/xchart/Styler_Pie.java +++ b/xchart/src/main/java/org/knowm/xchart/Styler_Pie.java @@ -17,13 +17,13 @@ package org.knowm.xchart; import org.knowm.xchart.Series_Pie.ChartPieSeriesRenderStyle; -import org.knowm.xchart.internal.style.StyleManager; -import org.knowm.xchart.internal.style.Theme; +import org.knowm.xchart.internal.style.Styler; +import org.knowm.xchart.internal.style.Theme_; /** * @author timmolter */ -public class Styler_Pie extends StyleManager { +public class Styler_Pie extends Styler { private ChartPieSeriesRenderStyle chartPieSeriesRenderStyle; @@ -109,17 +109,17 @@ public class Styler_Pie extends StyleManager { } /** - * Set the theme the style manager should use + * Set the theme the styler should use * * @param theme */ - protected void setTheme(Theme theme) { + protected void setTheme(Theme_ theme) { this.theme = theme; super.setAllStyles(); } - public Theme getTheme() { + public Theme_ getTheme() { return theme; } diff --git a/xchart/src/main/java/org/knowm/xchart/Styler_XY.java b/xchart/src/main/java/org/knowm/xchart/Styler_XY.java index d4fd8389607f6e1ceb067f9c821f5e6f792d9fdb..d000c37e145b0f94b2534516c1d381220d92d395 100644 --- a/xchart/src/main/java/org/knowm/xchart/Styler_XY.java +++ b/xchart/src/main/java/org/knowm/xchart/Styler_XY.java @@ -17,13 +17,13 @@ package org.knowm.xchart; import org.knowm.xchart.Series_XY.ChartXYSeriesRenderStyle; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; -import org.knowm.xchart.internal.style.Theme; +import org.knowm.xchart.internal.style.Styler_AxesChart; +import org.knowm.xchart.internal.style.Theme_; /** * @author timmolter */ -public class Styler_XY extends StyleManagerAxesChart { +public class Styler_XY extends Styler_AxesChart { private ChartXYSeriesRenderStyle chartXYSeriesRenderStyle; @@ -58,17 +58,17 @@ public class Styler_XY extends StyleManagerAxesChart { } /** - * Set the theme the style manager should use + * Set the theme the styler should use * * @param theme */ - protected void setTheme(Theme theme) { + protected void setTheme(Theme_ theme) { this.theme = theme; super.setAllStyles(); } - public Theme getTheme() { + public Theme_ getTheme() { return theme; } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/ChartBuilder.java b/xchart/src/main/java/org/knowm/xchart/internal/ChartBuilder.java index ddeb48283067888c0beabb25a3353acc2ff016ae..00d3a5ca0e89a8395308aed62aec4e325ad14a64 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/ChartBuilder.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/ChartBuilder.java @@ -17,7 +17,7 @@ package org.knowm.xchart.internal; import org.knowm.xchart.internal.chartpart.Chart; -import org.knowm.xchart.internal.style.StyleManager.ChartTheme; +import org.knowm.xchart.internal.style.Styler.ChartTheme; /** * A "Builder" to make creating charts easier diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Axis.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Axis.java index a36623a4845fac36118fdbe97f912cd6b8155d3e..f3cb5340cec2613b6de9c3cefe3e76450ff3965e 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Axis.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Axis.java @@ -27,22 +27,22 @@ import java.util.List; import org.knowm.xchart.Styler_Category; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Series_AxesChart; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * Axis * * @author timmolter */ -public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements ChartPart { +public class Axis<ST extends Styler_AxesChart, S extends Series> implements ChartPart { public enum AxisDataType { Number, Date, String; } - private final Chart<StyleManagerAxesChart, Series_AxesChart> chart; + private final Chart<Styler_AxesChart, Series_AxesChart> chart; private Rectangle2D bounds; // TODO 3.0.0 use bounds only??? @@ -58,10 +58,10 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements private AxisDataType axisDataType; /** the axis title */ - private AxisTitle<StyleManagerAxesChart, Series_AxesChart> axisTitle; + private AxisTitle<Styler_AxesChart, Series_AxesChart> axisTitle; /** the axis tick */ - private AxisTick<StyleManagerAxesChart, Series_AxesChart> axisTick; + private AxisTick<Styler_AxesChart, Series_AxesChart> axisTick; /** the axis tick calculator */ private AxisTickCalculator_ axisTickCalculator; @@ -89,12 +89,13 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements * @param chart the Chart * @param direction the axis direction (X or Y) */ - public Axis(Chart<StyleManagerAxesChart, Series_AxesChart> chart, Direction direction) { + public Axis(Chart<Styler_AxesChart, Series_AxesChart> chart, Direction direction) { this.chart = chart; this.direction = direction; - axisTitle = new AxisTitle<StyleManagerAxesChart, Series_AxesChart>(chart, direction); - axisTick = new AxisTick<StyleManagerAxesChart, Series_AxesChart>(chart, direction); + axisTitle = new AxisTitle<Styler_AxesChart, Series_AxesChart>(chart, direction); + axisTick = new AxisTick<Styler_AxesChart, Series_AxesChart>(chart, direction); + // resetMinMax(); } /** @@ -152,9 +153,10 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements // | // | // ---- - double xOffset = chart.getStyleManager().getChartPadding(); - double yOffset = chart.getChartTitle().getBounds().getHeight() < .1 ? chart.getStyleManager().getChartPadding() : chart.getChartTitle().getBounds().getHeight() + 2 * chart.getStyleManager() - .getChartPadding(); + double xOffset = chart.getStyler().getChartPadding(); + double yOffset = chart.getChartTitle().getBounds().getHeight() < .1 ? chart.getStyler().getChartPadding() : chart.getChartTitle().getBounds().getHeight() + + + chart.getStyler().getChartPadding(); ///////////////////////// int i = 1; // just twice through is all it takes @@ -169,17 +171,17 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements - width // y-axis approx. width - - (chart.getStyleManager().getLegendPosition() == LegendPosition.OutsideE ? chart.getChartLegend().getBounds().getWidth() : 0) + - (chart.getStyler().getLegendPosition() == LegendPosition.OutsideE ? chart.getLegend().getBounds().getWidth() : 0) - - 2 * chart.getStyleManager().getChartPadding() + - 2 * chart.getStyler().getChartPadding() - - (chart.getStyleManager().isYAxisTicksVisible() ? (chart.getStyleManager().getPlotPadding()) : 0) + - (chart.getStyler().isYAxisTicksVisible() ? (chart.getStyler().getPlotPadding()) : 0) - - (chart.getStyleManager().getLegendPosition() == LegendPosition.OutsideE && chart.getStyleManager().isLegendVisible() ? chart.getStyleManager().getChartPadding() : 0) + - (chart.getStyler().getLegendPosition() == LegendPosition.OutsideE && chart.getStyler().isLegendVisible() ? chart.getStyler().getChartPadding() : 0) ; - height = chart.getHeight() - yOffset - chart.getXAxis().getXAxisHeightHint(approximateXAxisWidth) - chart.getStyleManager().getPlotPadding() - chart.getStyleManager().getChartPadding(); + height = chart.getHeight() - yOffset - chart.getXAxis().getXAxisHeightHint(approximateXAxisWidth) - chart.getStyler().getPlotPadding() - chart.getStyler().getChartPadding(); width = getYAxisWidthHint(height); // System.out.println("width after: " + width); @@ -201,7 +203,7 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements xOffset = paintZone.getX(); yOffset = paintZone.getY(); - width = (chart.getStyleManager().isYAxisTitleVisible() ? axisTitle.getBounds().getWidth() : 0) + axisTick.getBounds().getWidth(); + width = (chart.getStyler().isYAxisTitleVisible() ? axisTitle.getBounds().getWidth() : 0) + axisTick.getBounds().getWidth(); height = paintZone.getHeight(); bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); @@ -214,9 +216,8 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements // calculate paint zone // |____________________| - double xOffset = chart.getYAxis().getBounds().getWidth() + (chart.getStyleManager().isYAxisTicksVisible() ? chart.getStyleManager().getPlotPadding() : 0) + chart.getStyleManager() - .getChartPadding(); - double yOffset = chart.getYAxis().getBounds().getY() + chart.getYAxis().getBounds().getHeight() + chart.getStyleManager().getPlotPadding(); + double xOffset = chart.getYAxis().getBounds().getWidth() + (chart.getStyler().isYAxisTicksVisible() ? chart.getStyler().getPlotPadding() : 0) + chart.getStyler().getChartPadding(); + double yOffset = chart.getYAxis().getBounds().getY() + chart.getYAxis().getBounds().getHeight() + chart.getStyler().getPlotPadding(); double width = @@ -224,21 +225,20 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements - chart.getYAxis().getBounds().getWidth() // y-axis was already painted - - (chart.getStyleManager().getLegendPosition() == LegendPosition.OutsideE ? chart.getChartLegend().getBounds().getWidth() : 0) + - (chart.getStyler().getLegendPosition() == LegendPosition.OutsideE ? chart.getLegend().getBounds().getWidth() : 0) - - 2 * chart.getStyleManager().getChartPadding() + - 2 * chart.getStyler().getChartPadding() - - (chart.getStyleManager().isYAxisTicksVisible() ? (chart.getStyleManager().getPlotPadding()) : 0) + - (chart.getStyler().isYAxisTicksVisible() ? (chart.getStyler().getPlotPadding()) : 0) - - (chart.getStyleManager().getLegendPosition() == LegendPosition.OutsideE && chart.getStyleManager().isLegendVisible() ? chart.getStyleManager().getChartPadding() : 0) + - (chart.getStyler().getLegendPosition() == LegendPosition.OutsideE && chart.getStyler().isLegendVisible() ? chart.getStyler().getChartPadding() : 0) ; // double height = this.getXAxisHeightHint(width); // System.out.println("height: " + height); // the Y-Axis was already draw at this point so we know how much vertical room is left for the X-Axis - double height = chart.getHeight() - chart.getYAxis().getBounds().getY() - chart.getYAxis().getBounds().getHeight() - chart.getStyleManager().getChartPadding() - chart.getStyleManager() - .getPlotPadding(); + double height = chart.getHeight() - chart.getYAxis().getBounds().getY() - chart.getYAxis().getBounds().getHeight() - chart.getStyler().getChartPadding() - chart.getStyler().getPlotPadding(); // System.out.println("height2: " + height2); Rectangle2D xAxisRectangle = new Rectangle2D.Double(xOffset, yOffset, width, height); @@ -271,15 +271,15 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements // Axis title double titleHeight = 0.0; - if (chart.getXAxisTitle() != null && !chart.getXAxisTitle().trim().equalsIgnoreCase("") && chart.getStyleManager().isXAxisTitleVisible()) { - TextLayout textLayout = new TextLayout(chart.getXAxisTitle(), chart.getStyleManager().getAxisTitleFont(), new FontRenderContext(null, true, false)); + if (chart.getXAxisTitle() != null && !chart.getXAxisTitle().trim().equalsIgnoreCase("") && chart.getStyler().isXAxisTitleVisible()) { + TextLayout textLayout = new TextLayout(chart.getXAxisTitle(), chart.getStyler().getAxisTitleFont(), new FontRenderContext(null, true, false)); Rectangle2D rectangle = textLayout.getBounds(); - titleHeight = rectangle.getHeight() + chart.getStyleManager().getAxisTitlePadding(); + titleHeight = rectangle.getHeight() + chart.getStyler().getAxisTitlePadding(); } // Axis tick labels double axisTickLabelsHeight = 0.0; - if (chart.getStyleManager().isXAxisTicksVisible()) { + if (chart.getStyler().isXAxisTicksVisible()) { // get some real tick labels // System.out.println("XAxisHeightHint"); @@ -297,12 +297,12 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements // System.out.println("sampleLabel: " + sampleLabel); // get the height of the label including rotation - TextLayout textLayout = new TextLayout(sampleLabel.length() == 0 ? " " : sampleLabel, chart.getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false)); - AffineTransform rot = chart.getStyleManager().getXAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-1 * Math.toRadians(chart.getStyleManager().getXAxisLabelRotation())); + TextLayout textLayout = new TextLayout(sampleLabel.length() == 0 ? " " : sampleLabel, chart.getStyler().getAxisTickLabelsFont(), new FontRenderContext(null, true, false)); + AffineTransform rot = chart.getStyler().getXAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-1 * Math.toRadians(chart.getStyler().getXAxisLabelRotation())); Shape shape = textLayout.getOutline(rot); Rectangle2D rectangle = shape.getBounds(); - axisTickLabelsHeight = rectangle.getHeight() + chart.getStyleManager().getAxisTickPadding() + chart.getStyleManager().getAxisTickMarkLength(); + axisTickLabelsHeight = rectangle.getHeight() + chart.getStyler().getAxisTickPadding() + chart.getStyler().getAxisTickMarkLength(); } return titleHeight + axisTickLabelsHeight; } @@ -311,15 +311,15 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements // Axis title double titleHeight = 0.0; - if (chart.getyYAxisTitle() != null && !chart.getyYAxisTitle().trim().equalsIgnoreCase("") && chart.getStyleManager().isYAxisTitleVisible()) { - TextLayout textLayout = new TextLayout(chart.getyYAxisTitle(), chart.getStyleManager().getAxisTitleFont(), new FontRenderContext(null, true, false)); + if (chart.getyYAxisTitle() != null && !chart.getyYAxisTitle().trim().equalsIgnoreCase("") && chart.getStyler().isYAxisTitleVisible()) { + TextLayout textLayout = new TextLayout(chart.getyYAxisTitle(), chart.getStyler().getAxisTitleFont(), new FontRenderContext(null, true, false)); Rectangle2D rectangle = textLayout.getBounds(); - titleHeight = rectangle.getHeight() + chart.getStyleManager().getAxisTitlePadding(); + titleHeight = rectangle.getHeight() + chart.getStyler().getAxisTitlePadding(); } // Axis tick labels double axisTickLabelsHeight = 0.0; - if (chart.getStyleManager().isYAxisTicksVisible()) { + if (chart.getStyler().isYAxisTicksVisible()) { // get some real tick labels // System.out.println("XAxisHeightHint"); @@ -335,10 +335,10 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements } // get the height of the label including rotation - TextLayout textLayout = new TextLayout(sampleLabel.length() == 0 ? " " : sampleLabel, chart.getStyleManager().getAxisTickLabelsFont(), new FontRenderContext(null, true, false)); + TextLayout textLayout = new TextLayout(sampleLabel.length() == 0 ? " " : sampleLabel, chart.getStyler().getAxisTickLabelsFont(), new FontRenderContext(null, true, false)); Rectangle2D rectangle = textLayout.getBounds(); - axisTickLabelsHeight = rectangle.getWidth() + chart.getStyleManager().getAxisTickPadding() + chart.getStyleManager().getAxisTickMarkLength(); + axisTickLabelsHeight = rectangle.getWidth() + chart.getStyler().getAxisTickPadding() + chart.getStyler().getAxisTickMarkLength(); } return titleHeight + axisTickLabelsHeight; } @@ -348,24 +348,24 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements // X-Axis if (getDirection() == Direction.X) { - if (chart.getStyleManager() instanceof Styler_Category) { + if (chart.getStyler() instanceof Styler_Category) { List<?> categories = (List<?>) chart.getSeriesMap().values().iterator().next().getXData(); AxisDataType axisType = chart.getAxisPair().getXAxis().getAxisDataType(); - return new AxisTickCalculator_Category(getDirection(), workingSpace, categories, axisType, chart.getStyleManager()); + return new AxisTickCalculator_Category(getDirection(), workingSpace, categories, axisType, chart.getStyler()); } else if (getAxisDataType() == AxisDataType.Date) { - return new AxisTickCalculator_Date(getDirection(), workingSpace, min, max, chart.getStyleManager()); + return new AxisTickCalculator_Date(getDirection(), workingSpace, min, max, chart.getStyler()); } - else if (chart.getStyleManager().isXAxisLogarithmic()) { + else if (chart.getStyler().isXAxisLogarithmic()) { - return new AxisTickCalculator_Logarithmic(getDirection(), workingSpace, min, max, chart.getStyleManager()); + return new AxisTickCalculator_Logarithmic(getDirection(), workingSpace, min, max, chart.getStyler()); } else { - return new AxisTickCalculator_Number(getDirection(), workingSpace, min, max, chart.getStyleManager()); + return new AxisTickCalculator_Number(getDirection(), workingSpace, min, max, chart.getStyler()); } } @@ -373,12 +373,12 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements // Y-Axis else { - if (chart.getStyleManager().isYAxisLogarithmic() && getAxisDataType() != AxisDataType.Date) { + if (chart.getStyler().isYAxisLogarithmic() && getAxisDataType() != AxisDataType.Date) { - return new AxisTickCalculator_Logarithmic(getDirection(), workingSpace, min, max, chart.getStyleManager()); + return new AxisTickCalculator_Logarithmic(getDirection(), workingSpace, min, max, chart.getStyler()); } else { - return new AxisTickCalculator_Number(getDirection(), workingSpace, min, max, chart.getStyleManager()); + return new AxisTickCalculator_Number(getDirection(), workingSpace, min, max, chart.getStyler()); } } @@ -412,7 +412,7 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements this.max = max; } - protected AxisTick<StyleManagerAxesChart, Series_AxesChart> getAxisTick() { + protected AxisTick<Styler_AxesChart, Series_AxesChart> getAxisTick() { return axisTick; } @@ -422,7 +422,7 @@ public class Axis<SM extends StyleManagerAxesChart, S extends Series> implements return direction; } - protected AxisTitle<StyleManagerAxesChart, Series_AxesChart> getAxisTitle() { + protected AxisTitle<Styler_AxesChart, Series_AxesChart> getAxisTitle() { return axisTitle; } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisPair.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisPair.java index 9183e315486bb6f33663432146096f9e0b87ec7e..e197aa113706cf77d930fa0a1cce6c036752cda1 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisPair.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisPair.java @@ -20,33 +20,33 @@ import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.knowm.xchart.Series_Category.ChartCategorySeriesRenderStyle; +import org.knowm.xchart.Styler_Category; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Series_AxesChart; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; -import org.knowm.xchart.Styler_Category; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * @author timmolter */ -public class AxisPair<SM extends StyleManagerAxesChart, S extends Series> implements ChartPart { +public class AxisPair<ST extends Styler_AxesChart, S extends Series> implements ChartPart { - private final Chart<StyleManagerAxesChart, Series_AxesChart> chart; + private final Chart<Styler_AxesChart, Series_AxesChart> chart; - private final Axis<StyleManagerAxesChart, Series_AxesChart> xAxis; - private final Axis<StyleManagerAxesChart, Series_AxesChart> yAxis; + private final Axis<Styler_AxesChart, Series_AxesChart> xAxis; + private final Axis<Styler_AxesChart, Series_AxesChart> yAxis; /** * Constructor * * @param chart */ - public AxisPair(Chart<StyleManagerAxesChart, Series_AxesChart> chart) { + public AxisPair(Chart<Styler_AxesChart, Series_AxesChart> chart) { this.chart = chart; // add axes - xAxis = new Axis<StyleManagerAxesChart, Series_AxesChart>(chart, Axis.Direction.X); - yAxis = new Axis<StyleManagerAxesChart, Series_AxesChart>(chart, Axis.Direction.Y); + xAxis = new Axis<Styler_AxesChart, Series_AxesChart>(chart, Axis.Direction.X); + yAxis = new Axis<Styler_AxesChart, Series_AxesChart>(chart, Axis.Direction.Y); } @Override @@ -63,24 +63,32 @@ public class AxisPair<SM extends StyleManagerAxesChart, S extends Series> implem // calculate axis min and max xAxis.resetMinMax(); yAxis.resetMinMax(); - for (Series_AxesChart series : chart.getSeriesMap().values()) { - // add min/max to axes - // System.out.println(series.getxMin()); - // System.out.println(series.getxMax()); - // System.out.println(series.getyMin()); - // System.out.println(series.getyMax()); - // System.out.println("****"); - xAxis.addMinMax(series.getXMin(), series.getXMax()); - yAxis.addMinMax(series.getYMin(), series.getYMax()); + + // if no series, we still want to plot an empty plot with axes. Since there are no min an max with no series added, we just fake it arbirarily. + if (chart.getSeriesMap() == null || chart.getSeriesMap().size() < 1) { + xAxis.addMinMax(-1, 1); + yAxis.addMinMax(-1, 1); + } + else { + for (Series_AxesChart series : chart.getSeriesMap().values()) { + // add min/max to axes + // System.out.println(series.getxMin()); + // System.out.println(series.getxMax()); + // System.out.println(series.getyMin()); + // System.out.println(series.getyMax()); + // System.out.println("****"); + xAxis.addMinMax(series.getXMin(), series.getXMax()); + yAxis.addMinMax(series.getYMin(), series.getYMax()); + } } overrideMinMax(); // logarithmic sanity check - if (chart.getStyleManager().isXAxisLogarithmic() && xAxis.getMin() <= 0.0) { + if (chart.getStyler().isXAxisLogarithmic() && xAxis.getMin() <= 0.0) { throw new IllegalArgumentException("Series data (accounting for error bars too) cannot be less or equal to zero for a logarithmic X-Axis!!!"); } - if (chart.getStyleManager().isYAxisLogarithmic() && yAxis.getMin() <= 0.0) { + if (chart.getStyler().isYAxisLogarithmic() && yAxis.getMin() <= 0.0) { // System.out.println(getMin()); throw new IllegalArgumentException("Series data (accounting for error bars too) cannot be less or equal to zero for a logarithmic Y-Axis!!!"); } @@ -93,10 +101,10 @@ public class AxisPair<SM extends StyleManagerAxesChart, S extends Series> implem double overrideYAxisMinValue = yAxis.getMin(); double overrideYAxisMaxValue = yAxis.getMax(); - if (chart.getStyleManager() instanceof Styler_Category) { + if (chart.getStyler() instanceof Styler_Category) { - Styler_Category styleManagerCategory = (Styler_Category) chart.getStyleManager(); - if (styleManagerCategory.getChartCategorySeriesRenderStyle() == ChartCategorySeriesRenderStyle.Bar) { + Styler_Category stylerCategory = (Styler_Category) chart.getStyler(); + if (stylerCategory.getChartCategorySeriesRenderStyle() == ChartCategorySeriesRenderStyle.Bar) { // override min/max value for bar charts' Y-Axis // There is a special case where it's desired to anchor the axis min or max to zero, like in the case of bar charts. This flag enables that feature. if (yAxis.getMin() > 0.0) { @@ -109,25 +117,25 @@ public class AxisPair<SM extends StyleManagerAxesChart, S extends Series> implem } // override min and maxValue if specified - if (chart.getStyleManager().getXAxisMin() != null) + if (chart.getStyler().getXAxisMin() != null) { - overrideXAxisMinValue = chart.getStyleManager().getXAxisMin(); + overrideXAxisMinValue = chart.getStyler().getXAxisMin(); } - if (chart.getStyleManager().getXAxisMax() != null) + if (chart.getStyler().getXAxisMax() != null) { - overrideXAxisMaxValue = chart.getStyleManager().getXAxisMax(); + overrideXAxisMaxValue = chart.getStyler().getXAxisMax(); } - if (chart.getStyleManager().getYAxisMin() != null) + if (chart.getStyler().getYAxisMin() != null) { - overrideYAxisMinValue = chart.getStyleManager().getYAxisMin(); + overrideYAxisMinValue = chart.getStyler().getYAxisMin(); } - if (chart.getStyleManager().getYAxisMax() != null) + if (chart.getStyler().getYAxisMax() != null) { - overrideYAxisMaxValue = chart.getStyleManager().getYAxisMax(); + overrideYAxisMaxValue = chart.getStyler().getYAxisMax(); } xAxis.setMin(overrideXAxisMinValue); @@ -139,12 +147,12 @@ public class AxisPair<SM extends StyleManagerAxesChart, S extends Series> implem // Getters & Setters ///////////////////////////////////////////////// - protected Axis<StyleManagerAxesChart, Series_AxesChart> getXAxis() { + protected Axis<Styler_AxesChart, Series_AxesChart> getXAxis() { return xAxis; } - protected Axis<StyleManagerAxesChart, Series_AxesChart> getYAxis() { + protected Axis<Styler_AxesChart, Series_AxesChart> getYAxis() { return yAxis; } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java index 71397dfbe45b747fbd4101f4fe19038fc3a0e1e3..acf8027b7ec40da381e96b47776d4d9afe28f6cb 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTick.java @@ -22,22 +22,22 @@ import java.awt.geom.Rectangle2D; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Series_AxesChart; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * An axis tick */ -public class AxisTick<SM extends StyleManagerAxesChart, S extends Series> implements ChartPart { +public class AxisTick<ST extends Styler_AxesChart, S extends Series> implements ChartPart { - private final Chart<StyleManagerAxesChart, Series_AxesChart> chart; + private final Chart<Styler_AxesChart, Series_AxesChart> chart; private Rectangle2D bounds; private final Direction direction; /** the axisticklabels */ - private AxisTickLabels<StyleManagerAxesChart, Series_AxesChart> axisTickLabels; + private AxisTickLabels<Styler_AxesChart, Series_AxesChart> axisTickLabels; /** the axistickmarks */ - private AxisTickMarks<StyleManagerAxesChart, Series_AxesChart> axisTickMarks; + private AxisTickMarks<Styler_AxesChart, Series_AxesChart> axisTickMarks; /** * Constructor @@ -45,12 +45,12 @@ public class AxisTick<SM extends StyleManagerAxesChart, S extends Series> implem * @param chart * @param direction */ - protected AxisTick(Chart<StyleManagerAxesChart, Series_AxesChart> chart, Direction direction) { + protected AxisTick(Chart<Styler_AxesChart, Series_AxesChart> chart, Direction direction) { this.chart = chart; this.direction = direction; - axisTickLabels = new AxisTickLabels<StyleManagerAxesChart, Series_AxesChart>(chart, direction); - axisTickMarks = new AxisTickMarks<StyleManagerAxesChart, Series_AxesChart>(chart, direction); + axisTickLabels = new AxisTickLabels<Styler_AxesChart, Series_AxesChart>(chart, direction); + axisTickMarks = new AxisTickMarks<Styler_AxesChart, Series_AxesChart>(chart, direction); } @Override @@ -62,7 +62,7 @@ public class AxisTick<SM extends StyleManagerAxesChart, S extends Series> implem @Override public void paint(Graphics2D g) { - if (direction == Axis.Direction.Y && chart.getStyleManager().isYAxisTicksVisible()) { + if (direction == Axis.Direction.Y && chart.getStyler().isYAxisTicksVisible()) { axisTickLabels.paint(g); axisTickMarks.paint(g); @@ -73,7 +73,7 @@ public class AxisTick<SM extends StyleManagerAxesChart, S extends Series> implem axisTickLabels.getBounds().getY(), - axisTickLabels.getBounds().getWidth() + chart.getStyleManager().getAxisTickPadding() + axisTickMarks.getBounds().getWidth(), + axisTickLabels.getBounds().getWidth() + chart.getStyler().getAxisTickPadding() + axisTickMarks.getBounds().getWidth(), axisTickMarks.getBounds().getHeight() @@ -83,7 +83,7 @@ public class AxisTick<SM extends StyleManagerAxesChart, S extends Series> implem // g.draw(bounds); } - else if (direction == Axis.Direction.X && chart.getStyleManager().isXAxisTicksVisible()) { + else if (direction == Axis.Direction.X && chart.getStyler().isXAxisTicksVisible()) { axisTickLabels.paint(g); axisTickMarks.paint(g); @@ -96,7 +96,7 @@ public class AxisTick<SM extends StyleManagerAxesChart, S extends Series> implem axisTickLabels.getBounds().getWidth(), - axisTickMarks.getBounds().getHeight() + chart.getStyleManager().getAxisTickPadding() + axisTickLabels.getBounds().getHeight() + axisTickMarks.getBounds().getHeight() + chart.getStyler().getAxisTickPadding() + axisTickLabels.getBounds().getHeight() ); @@ -112,7 +112,7 @@ public class AxisTick<SM extends StyleManagerAxesChart, S extends Series> implem // Getters ///////////////////////////////////////////////// - protected AxisTickLabels<StyleManagerAxesChart, Series_AxesChart> getAxisTickLabels() { + protected AxisTickLabels<Styler_AxesChart, Series_AxesChart> getAxisTickLabels() { return axisTickLabels; } 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 2ac60ffa6d9816ad4a3e78cec53fd7f9409c88b7..e06975dda2101854f814fe236b55235f631a102e 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 @@ -25,7 +25,7 @@ import java.util.LinkedList; import java.util.List; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * @author timmolter @@ -46,7 +46,7 @@ public abstract class AxisTickCalculator_ { protected final double maxValue; - protected final StyleManagerAxesChart styleManager; + protected final Styler_AxesChart styler; /** * Constructor @@ -55,15 +55,15 @@ public abstract class AxisTickCalculator_ { * @param workingSpace * @param minValue * @param maxValue - * @param styleManager + * @param styler */ - public AxisTickCalculator_(Direction axisDirection, double workingSpace, double minValue, double maxValue, StyleManagerAxesChart styleManager) { + public AxisTickCalculator_(Direction axisDirection, double workingSpace, double minValue, double maxValue, Styler_AxesChart styler) { this.axisDirection = axisDirection; this.workingSpace = workingSpace; this.minValue = minValue; this.maxValue = maxValue; - this.styleManager = styleManager; + this.styler = styler; } /** @@ -113,8 +113,8 @@ public abstract class AxisTickCalculator_ { } // System.out.println("longestLabel: " + sampleLabel); - TextLayout textLayout = new TextLayout(sampleLabel, styleManager.getAxisTickLabelsFont(), new FontRenderContext(null, true, false)); - AffineTransform rot = styleManager.getXAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-1 * Math.toRadians(styleManager.getXAxisLabelRotation())); + TextLayout textLayout = new TextLayout(sampleLabel, styler.getAxisTickLabelsFont(), new FontRenderContext(null, true, false)); + AffineTransform rot = styler.getXAxisLabelRotation() == 0 ? null : AffineTransform.getRotateInstance(-1 * Math.toRadians(styler.getXAxisLabelRotation())); Shape shape = textLayout.getOutline(rot); Rectangle2D rectangle = shape.getBounds(); double largestLabelWidth = rectangle.getWidth(); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Category.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Category.java index ff88d573d71f99fdfffaa10f739f46b85fb2480b..c262dfcb64163ece49bf2f6d27c058e1cb0403e2 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Category.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Category.java @@ -24,7 +24,7 @@ import java.util.List; import org.knowm.xchart.internal.Utils; import org.knowm.xchart.internal.chartpart.Axis.AxisDataType; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * This class encapsulates the logic to generate the axis tick mark and axis tick label data for rendering the axis ticks for String axes @@ -40,11 +40,11 @@ public class AxisTickCalculator_Category extends AxisTickCalculator_ { * @param workingSpace * @param categories * @param axisType - * @param styleManager + * @param styler */ - public AxisTickCalculator_Category(Direction axisDirection, double workingSpace, List<?> categories, AxisDataType axisType, StyleManagerAxesChart styleManager) { + public AxisTickCalculator_Category(Direction axisDirection, double workingSpace, List<?> categories, AxisDataType axisType, Styler_AxesChart styler) { - super(axisDirection, workingSpace, Double.NaN, Double.NaN, styleManager); + super(axisDirection, workingSpace, Double.NaN, Double.NaN, styler); calculate(categories, axisType); } @@ -52,7 +52,7 @@ public class AxisTickCalculator_Category extends AxisTickCalculator_ { private void calculate(List<?> categories, AxisDataType axisType) { // tick space - a percentage of the working space available for ticks - int tickSpace = (int) (styleManager.getAxisTickSpacePercentage() * workingSpace); // in plot space + int tickSpace = (int) (styler.getAxisTickSpacePercentage() * workingSpace); // in plot space // where the tick should begin in the working space in pixels double margin = Utils.getTickStartOffset(workingSpace, tickSpace); @@ -65,14 +65,14 @@ public class AxisTickCalculator_Category extends AxisTickCalculator_ { NumberFormatter numberFormatter = null; SimpleDateFormat simpleDateformat = null; if (axisType == AxisDataType.Number) { - numberFormatter = new NumberFormatter(styleManager); + numberFormatter = new NumberFormatter(styler); } else if (axisType == AxisDataType.Date) { - if (styleManager.getDatePattern() == null) { + if (styler.getDatePattern() == null) { throw new RuntimeException("You need to set the Date Formatting Pattern!!!"); } - simpleDateformat = new SimpleDateFormat(styleManager.getDatePattern(), styleManager.getLocale()); - simpleDateformat.setTimeZone(styleManager.getTimezone()); + simpleDateformat = new SimpleDateFormat(styler.getDatePattern(), styler.getLocale()); + simpleDateformat.setTimeZone(styler.getTimezone()); } int counter = 0; diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Date.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Date.java index d0a6c5c1b17525873b5f62752257d9416438033e..aba06fae685491b1a222fba450249fcebd855e16 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Date.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Date.java @@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit; import org.knowm.xchart.internal.Utils; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * This class encapsulates the logic to generate the axis tick mark and axis tick label data for rendering the axis ticks for date axes @@ -106,11 +106,11 @@ public class AxisTickCalculator_Date extends AxisTickCalculator_ { * @param workingSpace * @param minValue * @param maxValue - * @param styleManager + * @param styler */ - public AxisTickCalculator_Date(Direction axisDirection, double workingSpace, double minValue, double maxValue, StyleManagerAxesChart styleManager) { + public AxisTickCalculator_Date(Direction axisDirection, double workingSpace, double minValue, double maxValue, Styler_AxesChart styler) { - super(axisDirection, workingSpace, minValue, maxValue, styleManager); + super(axisDirection, workingSpace, minValue, maxValue, styler); calculate(); } @@ -118,10 +118,10 @@ public class AxisTickCalculator_Date extends AxisTickCalculator_ { private void calculate() { // tick space - a percentage of the working space available for ticks - double tickSpace = styleManager.getAxisTickSpacePercentage() * workingSpace; // in plot space + double tickSpace = styler.getAxisTickSpacePercentage() * workingSpace; // in plot space // this prevents an infinite loop when the plot gets sized really small. - if (tickSpace < styleManager.getXAxisTickMarkSpacingHint()) { + if (tickSpace < styler.getXAxisTickMarkSpacingHint()) { // System.out.println("Returning!"); return; } @@ -134,7 +134,7 @@ public class AxisTickCalculator_Date extends AxisTickCalculator_ { // System.out.println("span: " + span); // Generate the labels first, see if they "look" OK and reiterate with an increased tickSpacingHint - int tickSpacingHint = styleManager.getXAxisTickMarkSpacingHint(); + int tickSpacingHint = styler.getXAxisTickMarkSpacingHint(); int gridStepInChartSpace = 0; // System.out.println("calculating ticks..."); @@ -185,13 +185,13 @@ public class AxisTickCalculator_Date extends AxisTickCalculator_ { // Define Date Pattern // override pattern if one was explicitly given - if (styleManager.getDatePattern() != null) { - datePattern = styleManager.getDatePattern(); + if (styler.getDatePattern() != null) { + datePattern = styler.getDatePattern(); } // System.out.println("datePattern: " + datePattern); - SimpleDateFormat simpleDateformat = new SimpleDateFormat(datePattern, styleManager.getLocale()); - simpleDateformat.setTimeZone(styleManager.getTimezone()); + SimpleDateFormat simpleDateformat = new SimpleDateFormat(datePattern, styler.getLocale()); + simpleDateformat.setTimeZone(styler.getTimezone()); // return simpleDateformat.format(value); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Logarithmic.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Logarithmic.java index 61f092435a234d574bc6b961ff246f50b27cee37..ec48efad37a474fea60bbb4ad689e0ee00bd3374 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Logarithmic.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Logarithmic.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; import org.knowm.xchart.internal.Utils; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * This class encapsulates the logic to generate the axis tick mark and axis tick label data for rendering the axis ticks for logarithmic axes @@ -38,12 +38,12 @@ public class AxisTickCalculator_Logarithmic extends AxisTickCalculator_ { * @param workingSpace * @param minValue * @param maxValue - * @param styleManager + * @param styler */ - public AxisTickCalculator_Logarithmic(Direction axisDirection, double workingSpace, double minValue, double maxValue, StyleManagerAxesChart styleManager) { + public AxisTickCalculator_Logarithmic(Direction axisDirection, double workingSpace, double minValue, double maxValue, Styler_AxesChart styler) { - super(axisDirection, workingSpace, minValue, maxValue, styleManager); - numberFormatter = new NumberFormatter(styleManager); + super(axisDirection, workingSpace, minValue, maxValue, styler); + numberFormatter = new NumberFormatter(styler); calculate(); } @@ -57,10 +57,10 @@ public class AxisTickCalculator_Logarithmic extends AxisTickCalculator_ { } // tick space - a percentage of the working space available for ticks - double tickSpace = styleManager.getAxisTickSpacePercentage() * workingSpace; // in plot space + double tickSpace = styler.getAxisTickSpacePercentage() * workingSpace; // in plot space // this prevents an infinite loop when the plot gets sized really small. - if (tickSpace < styleManager.getXAxisTickMarkSpacingHint()) { + if (tickSpace < styler.getXAxisTickMarkSpacingHint()) { return; } @@ -74,17 +74,17 @@ public class AxisTickCalculator_Logarithmic extends AxisTickCalculator_ { // System.out.println("logMin: " + logMin); // System.out.println("logMax: " + logMax); - // if (axisDirection == Direction.Y && styleManager.getYAxisMin() != null) { - // logMin = (int) (Math.log10(styleManager.getYAxisMin())); // no floor + // if (axisDirection == Direction.Y && styler.getYAxisMin() != null) { + // logMin = (int) (Math.log10(styler.getYAxisMin())); // no floor // } - // if (axisDirection == Direction.Y && styleManager.getYAxisMax() != null) { - // logMax = (int) (Math.log10(styleManager.getYAxisMax())); // no floor + // if (axisDirection == Direction.Y && styler.getYAxisMax() != null) { + // logMax = (int) (Math.log10(styler.getYAxisMax())); // no floor // } - // if (axisDirection == Direction.X && styleManager.getXAxisMin() != null) { - // logMin = (int) (Math.log10(styleManager.getXAxisMin())); // no floor + // if (axisDirection == Direction.X && styler.getXAxisMin() != null) { + // logMin = (int) (Math.log10(styler.getXAxisMin())); // no floor // } - // if (axisDirection == Direction.X && styleManager.getXAxisMax() != null) { - // logMax = (int) (Math.log10(styleManager.getXAxisMax())); // no floor + // if (axisDirection == Direction.X && styler.getXAxisMax() != null) { + // logMax = (int) (Math.log10(styler.getXAxisMax())); // no floor // } double firstPosition = Utils.pow(10, logMin); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Number.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Number.java index 6f0c0637b3424d446ba08ca54270432669873ceb..091ec58309d63b89c1a58c43c2297f13099e6520 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Number.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickCalculator_Number.java @@ -21,7 +21,7 @@ import java.math.RoundingMode; import org.knowm.xchart.internal.Utils; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * This class encapsulates the logic to generate the axis tick mark and axis tick label data for rendering the axis ticks for decimal axes @@ -39,12 +39,12 @@ public class AxisTickCalculator_Number extends AxisTickCalculator_ { * @param workingSpace * @param minValue * @param maxValue - * @param styleManager + * @param styler */ - public AxisTickCalculator_Number(Direction axisDirection, double workingSpace, double minValue, double maxValue, StyleManagerAxesChart styleManager) { + public AxisTickCalculator_Number(Direction axisDirection, double workingSpace, double minValue, double maxValue, Styler_AxesChart styler) { - super(axisDirection, workingSpace, minValue, maxValue, styleManager); - numberFormatter = new NumberFormatter(styleManager); + super(axisDirection, workingSpace, minValue, maxValue, styler); + numberFormatter = new NumberFormatter(styler); calculate(); } @@ -58,21 +58,21 @@ public class AxisTickCalculator_Number extends AxisTickCalculator_ { } // tick space - a percentage of the working space available for ticks - double tickSpace = styleManager.getAxisTickSpacePercentage() * workingSpace; // in plot space + double tickSpace = styler.getAxisTickSpacePercentage() * workingSpace; // in plot space // this prevents an infinite loop when the plot gets sized really small. - if (tickSpace < styleManager.getXAxisTickMarkSpacingHint()) { + if (tickSpace < styler.getXAxisTickMarkSpacingHint()) { return; } // where the tick should begin in the working space in pixels double margin = Utils.getTickStartOffset(workingSpace, tickSpace); // in plot space double gridStep = getGridStepForDecimal(tickSpace); // the span of the data - double span = Math.abs(maxValue - minValue); // in data space + double span = Math.abs(Math.min((maxValue - minValue), Double.MAX_VALUE - 1)); // in data space ////////////////////////// - int tickSpacingHint = (axisDirection == Direction.X ? styleManager.getXAxisTickMarkSpacingHint() : styleManager.getYAxisTickMarkSpacingHint()) - 5; + int tickSpacingHint = (axisDirection == Direction.X ? styler.getXAxisTickMarkSpacingHint() : styler.getYAxisTickMarkSpacingHint()) - 5; // for very short plots, squeeze some more ticks in than normal into the Y-Axis if (axisDirection == Direction.Y && tickSpace < 160) { diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickLabels.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickLabels.java index e917ca546dd55155d0261911225813c782efac59..8e69be386ab68eb687345287b1114cbc4a3c4df4 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickLabels.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickLabels.java @@ -28,14 +28,14 @@ import java.util.Map; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Series_AxesChart; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * Axis tick labels */ -public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> implements ChartPart { +public class AxisTickLabels<ST extends Styler_AxesChart, S extends Series> implements ChartPart { - private final Chart<StyleManagerAxesChart, Series_AxesChart> chart; + private final Chart<Styler_AxesChart, Series_AxesChart> chart; private Rectangle2D bounds; private final Direction direction; @@ -45,7 +45,7 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> * @param chart * @param direction */ - protected AxisTickLabels(Chart<StyleManagerAxesChart, Series_AxesChart> chart, Direction direction) { + protected AxisTickLabels(Chart<Styler_AxesChart, Series_AxesChart> chart, Direction direction) { this.chart = chart; this.direction = direction; @@ -54,11 +54,11 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> @Override public void paint(Graphics2D g) { - g.setFont(chart.getStyleManager().getAxisTickLabelsFont()); + g.setFont(chart.getStyler().getAxisTickLabelsFont()); - g.setColor(chart.getStyleManager().getAxisTickLabelsColor()); + g.setColor(chart.getStyler().getAxisTickLabelsColor()); - if (direction == Axis.Direction.Y && chart.getStyleManager().isYAxisTicksVisible()) { // Y-Axis + if (direction == Axis.Direction.Y && chart.getStyler().isYAxisTicksVisible()) { // Y-Axis double xWidth = chart.getYAxis().getAxisTitle().getBounds().getWidth(); double xOffset = chart.getYAxis().getAxisTitle().getBounds().getX() + xWidth; @@ -76,7 +76,7 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> if (tickLabel != null && flippedTickLocation > yOffset && flippedTickLocation < yOffset + height) { // some are null for logarithmic axes FontRenderContext frc = g.getFontRenderContext(); - TextLayout axisLabelTextLayout = new TextLayout(tickLabel, chart.getStyleManager().getAxisTickLabelsFont(), frc); + TextLayout axisLabelTextLayout = new TextLayout(tickLabel, chart.getStyler().getAxisTickLabelsFont(), frc); Rectangle2D tickLabelBounds = axisLabelTextLayout.getBounds(); double boundWidth = tickLabelBounds.getWidth(); if (boundWidth > maxTickLabelWidth) { @@ -98,7 +98,7 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> AffineTransform at = new AffineTransform(); double boundWidth = tickLabelBounds.getWidth(); double xPos; - switch (chart.getStyleManager().getYAxisLabelAlignment()) { + switch (chart.getStyler().getYAxisLabelAlignment()) { case Right: xPos = xOffset + maxTickLabelWidth - boundWidth; break; @@ -123,7 +123,7 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> } // X-Axis - else if (direction == Axis.Direction.X && chart.getStyleManager().isXAxisTicksVisible()) { + else if (direction == Axis.Direction.X && chart.getStyler().isXAxisTicksVisible()) { double xOffset = chart.getXAxis().getPaintZone().getX(); double yOffset = chart.getXAxis().getAxisTitle().getBounds().getY(); @@ -142,18 +142,18 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> if (tickLabel != null && shiftedTickLocation > xOffset && shiftedTickLocation < xOffset + width) { // some are null for logarithmic axes FontRenderContext frc = g.getFontRenderContext(); - TextLayout textLayout = new TextLayout(tickLabel, chart.getStyleManager().getAxisTickLabelsFont(), frc); + TextLayout textLayout = new TextLayout(tickLabel, chart.getStyler().getAxisTickLabelsFont(), frc); // System.out.println(textLayout.getOutline(null).getBounds().toString()); // Shape shape = v.getOutline(); - AffineTransform rot = AffineTransform.getRotateInstance(-1 * Math.toRadians(chart.getStyleManager().getXAxisLabelRotation()), 0, 0); + AffineTransform rot = AffineTransform.getRotateInstance(-1 * Math.toRadians(chart.getStyler().getXAxisLabelRotation()), 0, 0); Shape shape = textLayout.getOutline(rot); Rectangle2D tickLabelBounds = shape.getBounds2D(); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); double xPos; - switch (chart.getStyleManager().getXAxisLabelAlignment()) { + switch (chart.getStyler().getXAxisLabelAlignment()) { case Left: xPos = shiftedTickLocation; break; @@ -165,7 +165,7 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> xPos = shiftedTickLocation - tickLabelBounds.getWidth() / 2.0; } // System.out.println("tickLabelBounds: " + tickLabelBounds.toString()); - double shiftX = -1 * tickLabelBounds.getX() * Math.sin(Math.toRadians(chart.getStyleManager().getXAxisLabelRotation())); + double shiftX = -1 * tickLabelBounds.getX() * Math.sin(Math.toRadians(chart.getStyler().getXAxisLabelRotation())); double shiftY = -1 * (tickLabelBounds.getY() + tickLabelBounds.getHeight()); // System.out.println(shiftX); // System.out.println("shiftY: " + shiftY); @@ -178,7 +178,7 @@ public class AxisTickLabels<SM extends StyleManagerAxesChart, S extends Series> // // debug box // g.setColor(Color.MAGENTA); // g.draw(new Rectangle2D.Double(xPos, yOffset - tickLabelBounds.getHeight(), tickLabelBounds.getWidth(), tickLabelBounds.getHeight())); - // g.setColor(getChartPainter().getStyleManager().getAxisTickLabelsColor()); + // g.setColor(getChartPainter().getstyler().getAxisTickLabelsColor()); if (tickLabelBounds.getHeight() > maxTickLabelHeight) { maxTickLabelHeight = tickLabelBounds.getHeight(); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickMarks.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickMarks.java index e419708cc4a3672c88e417e69d5da170042245f0..3dee366837b046462b9938ea05926352113201ac 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickMarks.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTickMarks.java @@ -24,14 +24,14 @@ import java.awt.geom.Rectangle2D; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Series_AxesChart; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * Axis tick marks. This includes the little tick marks and the line that hugs the plot area. */ -public class AxisTickMarks<SM extends StyleManagerAxesChart, S extends Series> implements ChartPart { +public class AxisTickMarks<ST extends Styler_AxesChart, S extends Series> implements ChartPart { - private final Chart<StyleManagerAxesChart, Series_AxesChart> chart; + private final Chart<Styler_AxesChart, Series_AxesChart> chart; private Rectangle2D bounds; private final Direction direction; @@ -41,7 +41,7 @@ public class AxisTickMarks<SM extends StyleManagerAxesChart, S extends Series> i * @param chart * @param direction */ - protected AxisTickMarks(Chart<StyleManagerAxesChart, Series_AxesChart> chart, Direction direction) { + protected AxisTickMarks(Chart<Styler_AxesChart, Series_AxesChart> chart, Direction direction) { this.chart = chart; this.direction = direction; @@ -50,22 +50,22 @@ public class AxisTickMarks<SM extends StyleManagerAxesChart, S extends Series> i @Override public void paint(Graphics2D g) { - g.setColor(chart.getStyleManager().getAxisTickMarksColor()); - g.setStroke(chart.getStyleManager().getAxisTickMarksStroke()); + g.setColor(chart.getStyler().getAxisTickMarksColor()); + g.setStroke(chart.getStyler().getAxisTickMarksStroke()); - if (direction == Axis.Direction.Y && chart.getStyleManager().isYAxisTicksVisible()) { // Y-Axis + if (direction == Axis.Direction.Y && chart.getStyler().isYAxisTicksVisible()) { // Y-Axis - double xOffset = chart.getYAxis().getAxisTick().getAxisTickLabels().getBounds().getX() + chart.getYAxis().getAxisTick().getAxisTickLabels().getBounds().getWidth() + chart.getStyleManager() + double xOffset = chart.getYAxis().getAxisTick().getAxisTickLabels().getBounds().getX() + chart.getYAxis().getAxisTick().getAxisTickLabels().getBounds().getWidth() + chart.getStyler() .getAxisTickPadding(); double yOffset = chart.getYAxis().getPaintZone().getY(); // bounds - bounds = new Rectangle2D.Double(xOffset, yOffset, chart.getStyleManager().getAxisTickMarkLength(), chart.getYAxis().getPaintZone().getHeight()); + bounds = new Rectangle2D.Double(xOffset, yOffset, chart.getStyler().getAxisTickMarkLength(), chart.getYAxis().getPaintZone().getHeight()); // g.setColor(Color.yellow); // g.draw(bounds); // tick marks - if (chart.getStyleManager().isAxisTicksMarksVisible()) { + if (chart.getStyler().isAxisTicksMarksVisible()) { for (int i = 0; i < chart.getYAxis().getAxisTickCalculator().getTickLabels().size(); i++) { @@ -73,16 +73,16 @@ public class AxisTickMarks<SM extends StyleManagerAxesChart, S extends Series> i double flippedTickLocation = yOffset + chart.getYAxis().getPaintZone().getHeight() - tickLocation; if (flippedTickLocation > bounds.getY() && flippedTickLocation < bounds.getY() + bounds.getHeight()) { - Shape line = new Line2D.Double(xOffset, flippedTickLocation, xOffset + chart.getStyleManager().getAxisTickMarkLength(), flippedTickLocation); + Shape line = new Line2D.Double(xOffset, flippedTickLocation, xOffset + chart.getStyler().getAxisTickMarkLength(), flippedTickLocation); g.draw(line); } } } // Line - if (chart.getStyleManager().isAxisTicksLineVisible()) { + if (chart.getStyler().isAxisTicksLineVisible()) { - Shape line = new Line2D.Double(xOffset + chart.getStyleManager().getAxisTickMarkLength(), yOffset, xOffset + chart.getStyleManager().getAxisTickMarkLength(), yOffset + chart.getYAxis() + Shape line = new Line2D.Double(xOffset + chart.getStyler().getAxisTickMarkLength(), yOffset, xOffset + chart.getStyler().getAxisTickMarkLength(), yOffset + chart.getYAxis() .getPaintZone().getHeight()); g.draw(line); @@ -90,18 +90,18 @@ public class AxisTickMarks<SM extends StyleManagerAxesChart, S extends Series> i } // X-Axis - else if (direction == Axis.Direction.X && chart.getStyleManager().isXAxisTicksVisible()) { + else if (direction == Axis.Direction.X && chart.getStyler().isXAxisTicksVisible()) { double xOffset = chart.getXAxis().getPaintZone().getX(); - double yOffset = chart.getXAxis().getAxisTick().getAxisTickLabels().getBounds().getY() - chart.getStyleManager().getAxisTickPadding(); + double yOffset = chart.getXAxis().getAxisTick().getAxisTickLabels().getBounds().getY() - chart.getStyler().getAxisTickPadding(); // bounds - bounds = new Rectangle2D.Double(xOffset, yOffset - chart.getStyleManager().getAxisTickMarkLength(), chart.getXAxis().getPaintZone().getWidth(), chart.getStyleManager().getAxisTickMarkLength()); + bounds = new Rectangle2D.Double(xOffset, yOffset - chart.getStyler().getAxisTickMarkLength(), chart.getXAxis().getPaintZone().getWidth(), chart.getStyler().getAxisTickMarkLength()); // g.setColor(Color.yellow); // g.draw(bounds); // tick marks - if (chart.getStyleManager().isAxisTicksMarksVisible()) { + if (chart.getStyler().isAxisTicksMarksVisible()) { for (int i = 0; i < chart.getXAxis().getAxisTickCalculator().getTickLabels().size(); i++) { @@ -110,18 +110,18 @@ public class AxisTickMarks<SM extends StyleManagerAxesChart, S extends Series> i if (shiftedTickLocation > bounds.getX() && shiftedTickLocation < bounds.getX() + bounds.getWidth()) { - Shape line = new Line2D.Double(shiftedTickLocation, yOffset, xOffset + tickLocation, yOffset - chart.getStyleManager().getAxisTickMarkLength()); + Shape line = new Line2D.Double(shiftedTickLocation, yOffset, xOffset + tickLocation, yOffset - chart.getStyler().getAxisTickMarkLength()); g.draw(line); } } } // Line - if (chart.getStyleManager().isAxisTicksLineVisible()) { + if (chart.getStyler().isAxisTicksLineVisible()) { - g.setStroke(chart.getStyleManager().getAxisTickMarksStroke()); - g.drawLine((int) xOffset, (int) (yOffset - chart.getStyleManager().getAxisTickMarkLength()), (int) (xOffset + chart.getXAxis().getPaintZone().getWidth()), (int) (yOffset - chart - .getStyleManager().getAxisTickMarkLength())); + g.setStroke(chart.getStyler().getAxisTickMarksStroke()); + g.drawLine((int) xOffset, (int) (yOffset - chart.getStyler().getAxisTickMarkLength()), (int) (xOffset + chart.getXAxis().getPaintZone().getWidth()), (int) (yOffset - chart + .getStyler().getAxisTickMarkLength())); } } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTitle.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTitle.java index 4b31db04526be26e39ef089cc7cf2a965d3ea9e0..acd8f464bac615a2f2a1745cbdc147cbaf7dbdc4 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTitle.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/AxisTitle.java @@ -26,14 +26,14 @@ import java.awt.geom.Rectangle2D; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Series_AxesChart; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * AxisTitle */ -public class AxisTitle<SM extends StyleManagerAxesChart, S extends Series> implements ChartPart { +public class AxisTitle<ST extends Styler_AxesChart, S extends Series> implements ChartPart { - private final Chart<StyleManagerAxesChart, Series_AxesChart> chart; + private final Chart<Styler_AxesChart, Series_AxesChart> chart; private Rectangle2D bounds; private final Direction direction; @@ -43,7 +43,7 @@ public class AxisTitle<SM extends StyleManagerAxesChart, S extends Series> imple * @param chart the Chart * @param direction the Direction */ - protected AxisTitle(Chart<StyleManagerAxesChart, Series_AxesChart> chart, Direction direction) { + protected AxisTitle(Chart<Styler_AxesChart, Series_AxesChart> chart, Direction direction) { this.chart = chart; this.direction = direction; @@ -54,15 +54,15 @@ public class AxisTitle<SM extends StyleManagerAxesChart, S extends Series> imple bounds = new Rectangle2D.Double(); - g.setColor(chart.getStyleManager().getChartFontColor()); - g.setFont(chart.getStyleManager().getAxisTitleFont()); + g.setColor(chart.getStyler().getChartFontColor()); + g.setFont(chart.getStyler().getAxisTitleFont()); if (direction == Axis.Direction.Y) { - if (chart.getyYAxisTitle() != null && !chart.getyYAxisTitle().trim().equalsIgnoreCase("") && chart.getStyleManager().isYAxisTitleVisible()) { + if (chart.getyYAxisTitle() != null && !chart.getyYAxisTitle().trim().equalsIgnoreCase("") && chart.getStyler().isYAxisTitleVisible()) { FontRenderContext frc = g.getFontRenderContext(); - TextLayout nonRotatedTextLayout = new TextLayout(chart.getyYAxisTitle(), chart.getStyleManager().getAxisTitleFont(), frc); + TextLayout nonRotatedTextLayout = new TextLayout(chart.getyYAxisTitle(), chart.getStyler().getAxisTitleFont(), frc); Rectangle2D nonRotatedRectangle = nonRotatedTextLayout.getBounds(); // /////////////////////////////////////////////// @@ -85,7 +85,7 @@ public class AxisTitle<SM extends StyleManagerAxesChart, S extends Series> imple // System.out.println(nonRotatedRectangle.getHeight()); // bounds - bounds = new Rectangle2D.Double(xOffset - nonRotatedRectangle.getHeight(), yOffset - nonRotatedRectangle.getWidth(), nonRotatedRectangle.getHeight() + chart.getStyleManager() + bounds = new Rectangle2D.Double(xOffset - nonRotatedRectangle.getHeight(), yOffset - nonRotatedRectangle.getWidth(), nonRotatedRectangle.getHeight() + chart.getStyler() .getAxisTitlePadding(), nonRotatedRectangle.getWidth()); // g.setColor(Color.blue); // g.draw(bounds); @@ -97,10 +97,10 @@ public class AxisTitle<SM extends StyleManagerAxesChart, S extends Series> imple } else { - if (chart.getXAxisTitle() != null && !chart.getXAxisTitle().trim().equalsIgnoreCase("") && chart.getStyleManager().isXAxisTitleVisible()) { + if (chart.getXAxisTitle() != null && !chart.getXAxisTitle().trim().equalsIgnoreCase("") && chart.getStyler().isXAxisTitleVisible()) { FontRenderContext frc = g.getFontRenderContext(); - TextLayout textLayout = new TextLayout(chart.getXAxisTitle(), chart.getStyleManager().getAxisTitleFont(), frc); + TextLayout textLayout = new TextLayout(chart.getXAxisTitle(), chart.getStyler().getAxisTitleFont(), frc); Rectangle2D rectangle = textLayout.getBounds(); // System.out.println(rectangle); @@ -116,7 +116,7 @@ public class AxisTitle<SM extends StyleManagerAxesChart, S extends Series> imple g.fill(shape); g.setTransform(orig); - bounds = new Rectangle2D.Double(xOffset, yOffset - chart.getStyleManager().getAxisTitlePadding(), rectangle.getWidth(), rectangle.getHeight() + chart.getStyleManager().getAxisTitlePadding()); + bounds = new Rectangle2D.Double(xOffset, yOffset - chart.getStyler().getAxisTitlePadding(), rectangle.getWidth(), rectangle.getHeight() + chart.getStyler().getAxisTitlePadding()); // g.setColor(Color.blue); // g.draw(bounds); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java index f522bde982878693cf93661c60fcd6318bcbbff7..1bc015436607f227e2fc52af30c271e808b79f6c 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Chart.java @@ -24,29 +24,29 @@ import java.util.List; import java.util.Map; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; /** * An XChart Chart * * @author timmolter */ -public abstract class Chart<SM extends StyleManager, S extends Series> implements ChartPart { +public abstract class Chart<ST extends Styler, S extends Series> implements ChartPart { public abstract void paint(Graphics2D g, int width, int height); - protected SM styleManager; + protected ST styler; /** Meta Data */ private int width; private int height; - private String title; - private String xAxisTitle; - private String yAxisTitle; + private String title = ""; + private String xAxisTitle = ""; + private String yAxisTitle = ""; /** Chart Parts */ protected ChartTitle chartTitle; - protected Legend chartLegend; + protected Legend_ legend; protected Plot_ plot; protected AxisPair axisPair; @@ -57,13 +57,13 @@ public abstract class Chart<SM extends StyleManager, S extends Series> implement * * @param width * @param height - * @param styleManager + * @param styler */ - public Chart(int width, int height, SM styleManager) { + public Chart(int width, int height, ST styler) { this.width = width; this.height = height; - this.styleManager = styleManager; + this.styler = styler; this.chartTitle = new ChartTitle(this); } @@ -167,9 +167,9 @@ public abstract class Chart<SM extends StyleManager, S extends Series> implement return chartTitle; } - protected Legend getChartLegend() { + protected Legend_ getLegend() { - return chartLegend; + return legend; } protected Plot_ getPlot() { @@ -198,13 +198,13 @@ public abstract class Chart<SM extends StyleManager, S extends Series> implement } /** - * Gets the Chart's style manager, which can be used to customize the Chart's appearance + * Gets the Chart's styler, which can be used to customize the Chart's appearance * - * @return the style manager + * @return the styler */ - public SM getStyleManager() { + public ST getStyler() { - return styleManager; + return styler; } @Override diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/ChartTitle.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/ChartTitle.java index a42526967a45bf6bb74f3ff6056d7b9ead2153ad..eee78f115b3010857267d4346f2f10f402561db0 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/ChartTitle.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/ChartTitle.java @@ -17,6 +17,7 @@ package org.knowm.xchart.internal.chartpart; import java.awt.BasicStroke; +import java.awt.Color; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.font.FontRenderContext; @@ -45,46 +46,40 @@ public class ChartTitle implements ChartPart { @Override public void paint(Graphics2D g) { - g.setFont(chart.getStyleManager().getChartTitleFont()); + g.setFont(chart.getStyler().getChartTitleFont()); - if (!chart.getStyleManager().isChartTitleVisible() || chart.getTitle().length() == 0) { + if (!chart.getStyler().isChartTitleVisible() || chart.getTitle().length() == 0) { return; } // create rectangle first for sizing FontRenderContext frc = g.getFontRenderContext(); - TextLayout textLayout = new TextLayout(chart.getTitle(), chart.getStyleManager().getChartTitleFont(), frc); + TextLayout textLayout = new TextLayout(chart.getTitle(), chart.getStyler().getChartTitleFont(), frc); Rectangle2D textBounds = textLayout.getBounds(); double xOffset = chart.getPlot().getBounds().getX(); // of plot left edge - double yOffset = chart.getStyleManager().getChartPadding(); + double yOffset = chart.getStyler().getChartPadding(); // title box - if (chart.getStyleManager().isChartTitleBoxVisible()) { + if (chart.getStyler().isChartTitleBoxVisible()) { // paint the chart title box double chartTitleBoxWidth = chart.getPlot().getBounds().getWidth(); - double chartTitleBoxHeight = textBounds.getHeight() + 2 * chart.getStyleManager().getChartTitlePadding(); + double chartTitleBoxHeight = textBounds.getHeight() + 2 * chart.getStyler().getChartTitlePadding(); g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); Shape rect = new Rectangle2D.Double(xOffset, yOffset, chartTitleBoxWidth, chartTitleBoxHeight); - g.setColor(chart.getStyleManager().getChartTitleBoxBackgroundColor()); + g.setColor(chart.getStyler().getChartTitleBoxBackgroundColor()); g.fill(rect); - g.setColor(chart.getStyleManager().getChartTitleBoxBorderColor()); + g.setColor(chart.getStyler().getChartTitleBoxBorderColor()); g.draw(rect); } // paint title xOffset = chart.getPlot().getBounds().getX() + (chart.getPlot().getBounds().getWidth() - textBounds.getWidth()) / 2.0; - yOffset = chart.getStyleManager().getChartPadding() - textBounds.getY() + chart.getStyleManager().getChartTitlePadding(); - - bounds = new Rectangle2D.Double(xOffset, yOffset + textBounds.getY(), textBounds.getWidth(), textBounds.getHeight()); - // g.setColor(Color.green); - // g.draw(bounds); - - g.setColor(chart.getStyleManager().getChartFontColor()); - // textLayout.draw(g, xOffset, yOffset); + yOffset = chart.getStyler().getChartPadding() + textBounds.getHeight() + chart.getStyler().getChartTitlePadding(); + g.setColor(chart.getStyler().getChartFontColor()); Shape shape = textLayout.getOutline(null); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); @@ -93,26 +88,31 @@ public class ChartTitle implements ChartPart { g.fill(shape); g.setTransform(orig); + double width = 2 * chart.getStyler().getChartTitlePadding() + textBounds.getWidth(); + double height = 2 * chart.getStyler().getChartTitlePadding() + textBounds.getHeight(); + bounds = new Rectangle2D.Double(xOffset - chart.getStyler().getChartTitlePadding(), yOffset - textBounds.getHeight() - chart.getStyler().getChartTitlePadding(), width, height); + g.setColor(Color.green); + g.draw(bounds); + } /** - * get the height of the chart title including the chart padding + * get the height of the chart title including the chart title padding * * @return */ private Rectangle2D getBoundsHint() { - if (chart.getStyleManager().isChartTitleVisible() && chart.getTitle().length() > 0) { + if (chart.getStyler().isChartTitleVisible() && chart.getTitle().length() > 0) { - TextLayout textLayout = new TextLayout(chart.getTitle(), chart.getStyleManager().getChartTitleFont(), new FontRenderContext(null, true, false)); + TextLayout textLayout = new TextLayout(chart.getTitle(), chart.getStyler().getChartTitleFont(), new FontRenderContext(null, true, false)); Rectangle2D rectangle = textLayout.getBounds(); - double width = 2 * chart.getStyleManager().getChartTitlePadding() + rectangle.getWidth(); - double height = 2 * chart.getStyleManager().getChartTitlePadding() + rectangle.getHeight(); + double width = 2 * chart.getStyler().getChartTitlePadding() + rectangle.getWidth(); + double height = 2 * chart.getStyler().getChartTitlePadding() + rectangle.getHeight(); + return new Rectangle2D.Double(Double.NaN, Double.NaN, width, height); // Double.NaN indicates not sure yet. } else { - // TODO make this zero, need to account for null bounds then when laying out plot - // return chart.getStyleManager().getChartPadding(); return new Rectangle2D.Double(); // Constructs a new Rectangle2D, initialized to location (0, 0) and size (0, 0). } } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_.java similarity index 85% rename from xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend.java rename to xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_.java index 284f0f821c0d5eff51578b631f80fb2191941953..71f7d58a0c14b67c8868b02ee09210eb16731eec 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_.java @@ -27,12 +27,12 @@ import java.util.Map; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.chartpart.RenderableSeries.LegendRenderType; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; /** * @author timmolter */ -public abstract class Legend<SM extends StyleManager, S extends Series> implements ChartPart { +public abstract class Legend_<ST extends Styler, S extends Series> implements ChartPart { public abstract double getSeriesLegendRenderGraphicHeight(Series series); @@ -40,7 +40,7 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen protected static final int BOX_SIZE = 20; protected static final int MULTI_LINE_SPACE = 3; - protected Chart<SM, S> chart; + protected Chart<ST, S> chart; protected Rectangle2D bounds = null; protected double xOffset = 0; @@ -51,7 +51,7 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen * * @param chart */ - public Legend(Chart<SM, S> chart) { + public Legend_(Chart<ST, S> chart) { this.chart = chart; @@ -60,6 +60,10 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen @Override public void paint(Graphics2D g) { + if (chart.getSeriesMap().isEmpty()) { + return; + } + // if the area to draw a chart on is so small, don't even bother if (chart.getPlot().getBounds().getWidth() < 30) { return; @@ -73,9 +77,9 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen // legend draw position - switch (chart.getStyleManager().getLegendPosition()) { + switch (chart.getStyler().getLegendPosition()) { case OutsideE: - xOffset = chart.getWidth() - bounds.getWidth() - chart.getStyleManager().getChartPadding(); + xOffset = chart.getWidth() - bounds.getWidth() - chart.getStyler().getChartPadding(); yOffset = chart.getPlot().getBounds().getY() + (chart.getPlot().getBounds().getHeight() - bounds.getHeight()) / 2.0; break; case InsideNW: @@ -105,10 +109,10 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen // draw legend box background and border Shape rect = new Rectangle2D.Double(xOffset, yOffset, bounds.getWidth(), bounds.getHeight()); - g.setColor(chart.getStyleManager().getLegendBackgroundColor()); + g.setColor(chart.getStyler().getLegendBackgroundColor()); g.fill(rect); g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 0.0f }, 0.0f)); - g.setColor(chart.getStyleManager().getLegendBorderColor()); + g.setColor(chart.getStyler().getLegendBorderColor()); g.draw(rect); } @@ -117,7 +121,7 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen */ public Rectangle2D getBoundsHint() { - if (!chart.getStyleManager().isLegendVisible()) { + if (!chart.getStyler().isLegendVisible()) { return new Rectangle2D.Double(); // Constructs a new Rectangle2D, initialized to location (0, 0) and size (0, 0). } @@ -143,7 +147,7 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen legendEntryHeight -= MULTI_LINE_SPACE; // subtract away the bottom MULTI_LINE_SPACE legendEntryHeight = Math.max(legendEntryHeight, (getSeriesLegendRenderGraphicHeight(series))); - legendContentHeight += legendEntryHeight + chart.getStyleManager().getLegendPadding(); + legendContentHeight += legendEntryHeight + chart.getStyler().getLegendPadding(); if (series.getLegendRenderType() == LegendRenderType.Box) { containsBox = true; @@ -153,15 +157,15 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen // determine legend content width double legendContentWidth = 0; if (!containsBox) { - legendContentWidth = chart.getStyleManager().getLegendSeriesLineLength() + chart.getStyleManager().getLegendPadding() + legendTextContentMaxWidth; + legendContentWidth = chart.getStyler().getLegendSeriesLineLength() + chart.getStyler().getLegendPadding() + legendTextContentMaxWidth; } else { - legendContentWidth = BOX_SIZE + chart.getStyleManager().getLegendPadding() + legendTextContentMaxWidth; + legendContentWidth = BOX_SIZE + chart.getStyler().getLegendPadding() + legendTextContentMaxWidth; } // Legend Box - double width = legendContentWidth + 2 * chart.getStyleManager().getLegendPadding(); - double height = legendContentHeight + 1 * chart.getStyleManager().getLegendPadding(); + double width = legendContentWidth + 2 * chart.getStyler().getLegendPadding(); + double height = legendContentHeight + 1 * chart.getStyler().getLegendPadding(); return new Rectangle2D.Double(Double.NaN, Double.NaN, width, height); // Double.NaN indicates not sure yet. } @@ -176,13 +180,13 @@ public abstract class Legend<SM extends StyleManager, S extends Series> implemen */ protected Map<String, Rectangle2D> getSeriesTextBounds(Series series) { - // FontMetrics fontMetrics = g.getFontMetrics(getChartPainter().getStyleManager().getLegendFont()); + // FontMetrics fontMetrics = g.getFontMetrics(getChartPainter().getstyler().getLegendFont()); // float fontDescent = fontMetrics.getDescent(); String lines[] = series.getName().split("\\n"); Map<String, Rectangle2D> seriesTextBounds = new LinkedHashMap<String, Rectangle2D>(lines.length); for (String line : lines) { - TextLayout textLayout = new TextLayout(line, chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false)); + TextLayout textLayout = new TextLayout(line, chart.getStyler().getLegendFont(), new FontRenderContext(null, true, false)); Shape shape = textLayout.getOutline(null); Rectangle2D bounds = shape.getBounds2D(); // System.out.println(tl.getAscent()); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/LegendAxesChart.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_AxesChart.java similarity index 79% rename from xchart/src/main/java/org/knowm/xchart/internal/chartpart/LegendAxesChart.java rename to xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_AxesChart.java index 5d6e5a1790dd199219a57860259c4881cea67811..39ce97fe6c682c8ba9eb6031c16b390eb87af4b9 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/LegendAxesChart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_AxesChart.java @@ -30,31 +30,31 @@ import org.knowm.xchart.Series_XY; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Series_AxesChart; import org.knowm.xchart.internal.chartpart.RenderableSeries.LegendRenderType; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; import org.knowm.xchart.internal.style.lines.SeriesLines; /** * @author timmolter */ -public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> extends Legend { +public class Legend_AxesChart<ST extends Styler_AxesChart, S extends Series> extends Legend_ { - StyleManagerAxesChart styleManagerAxesChart; + Styler_AxesChart stylerAxesChart; /** * Constructor * * @param chart */ - public LegendAxesChart(Chart<StyleManagerAxesChart, Series_XY> chart) { + public Legend_AxesChart(Chart<Styler_AxesChart, Series_XY> chart) { super(chart); - styleManagerAxesChart = chart.getStyleManager(); + stylerAxesChart = chart.getStyler(); } @Override public void paint(Graphics2D g) { - if (!chart.getStyleManager().isLegendVisible()) { + if (!chart.getStyler().isLegendVisible()) { return; } @@ -63,8 +63,8 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 0.0f }, 0.0f)); // Draw legend content inside legend box - double startx = xOffset + chart.getStyleManager().getLegendPadding(); - double starty = yOffset + chart.getStyleManager().getLegendPadding(); + double startx = xOffset + chart.getStyler().getLegendPadding(); + double starty = yOffset + chart.getStyler().getLegendPadding(); Map<String, Series_AxesChart> map = chart.getSeriesMap(); for (Series_AxesChart series : map.values()) { @@ -79,7 +79,7 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> } legendEntryHeight -= MULTI_LINE_SPACE; - legendEntryHeight = Math.max(legendEntryHeight, (series.getLegendRenderType() == LegendRenderType.Box ? BOX_SIZE : styleManagerAxesChart.getMarkerSize())); + legendEntryHeight = Math.max(legendEntryHeight, (series.getLegendRenderType() == LegendRenderType.Box ? BOX_SIZE : stylerAxesChart.getMarkerSize())); // ////// paint series render graphic ///////// @@ -90,12 +90,12 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> if (series.getLegendRenderType() == LegendRenderType.Line && series.getLineStyle() != SeriesLines.NONE) { g.setColor(series.getLineColor()); g.setStroke(series.getLineStyle()); - Shape line = new Line2D.Double(startx, starty + legendEntryHeight / 2.0, startx + chart.getStyleManager().getLegendSeriesLineLength(), starty + legendEntryHeight / 2.0); + Shape line = new Line2D.Double(startx, starty + legendEntryHeight / 2.0, startx + chart.getStyler().getLegendSeriesLineLength(), starty + legendEntryHeight / 2.0); g.draw(line); } // // debug box - // Rectangle2D boundsTemp = new Rectangle2D.Double(startx, starty, styleManager.getLegendSeriesLineLength(), blockHeight); + // Rectangle2D boundsTemp = new Rectangle2D.Double(startx, starty, styler.getLegendSeriesLineLength(), blockHeight); // g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); // g.setColor(Color.red); // g.draw(boundsTemp); @@ -103,7 +103,7 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> // paint marker if (series.getMarker() != null) { g.setColor(series.getMarkerColor()); - series.getMarker().paint(g, startx + chart.getStyleManager().getLegendSeriesLineLength() / 2.0, starty + legendEntryHeight / 2.0, styleManagerAxesChart.getMarkerSize()); + series.getMarker().paint(g, startx + chart.getStyler().getLegendSeriesLineLength() / 2.0, starty + legendEntryHeight / 2.0, stylerAxesChart.getMarkerSize()); } } @@ -111,7 +111,7 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> // paint little box Shape rectSmall = new Rectangle2D.Double(startx, starty, BOX_SIZE, BOX_SIZE); - if (styleManagerAxesChart.isBarFilled()) { + if (stylerAxesChart.isBarFilled()) { g.setColor(series.getFillColor()); g.fill(rectSmall); } @@ -128,20 +128,20 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> // // ////// paint series text ///////// - g.setColor(chart.getStyleManager().getChartFontColor()); + g.setColor(chart.getStyler().getChartFontColor()); double multiLineOffset = 0.0; if (series.getLegendRenderType() != LegendRenderType.Box) { - double x = startx + chart.getStyleManager().getLegendSeriesLineLength() + chart.getStyleManager().getLegendPadding(); + double x = startx + chart.getStyler().getLegendSeriesLineLength() + chart.getStyler().getLegendPadding(); for (Map.Entry<String, Rectangle2D> entry : seriesTextBounds.entrySet()) { double height = entry.getValue().getHeight(); - double centerOffsetY = (Math.max(styleManagerAxesChart.getMarkerSize(), height) - height) / 2.0; + double centerOffsetY = (Math.max(stylerAxesChart.getMarkerSize(), height) - height) / 2.0; FontRenderContext frc = g.getFontRenderContext(); - TextLayout tl = new TextLayout(entry.getKey(), chart.getStyleManager().getLegendFont(), frc); + TextLayout tl = new TextLayout(entry.getKey(), chart.getStyler().getLegendFont(), frc); Shape shape = tl.getOutline(null); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); @@ -161,14 +161,14 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> } else { // bar/pie type series - final double x = startx + BOX_SIZE + chart.getStyleManager().getLegendPadding(); + final double x = startx + BOX_SIZE + chart.getStyler().getLegendPadding(); for (Map.Entry<String, Rectangle2D> entry : seriesTextBounds.entrySet()) { double height = entry.getValue().getHeight(); double centerOffsetY = (Math.max(BOX_SIZE, height) - height) / 2.0; FontRenderContext frc = g.getFontRenderContext(); - TextLayout tl = new TextLayout(entry.getKey(), chart.getStyleManager().getLegendFont(), frc); + TextLayout tl = new TextLayout(entry.getKey(), chart.getStyler().getLegendFont(), frc); Shape shape = tl.getOutline(null); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); @@ -185,7 +185,7 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> } } - starty += legendEntryHeight + chart.getStyleManager().getLegendPadding(); + starty += legendEntryHeight + chart.getStyler().getLegendPadding(); } @@ -209,6 +209,6 @@ public class LegendAxesChart<SM extends StyleManagerAxesChart, S extends Series> @Override public double getSeriesLegendRenderGraphicHeight(Series series) { - return series.getLegendRenderType() == LegendRenderType.Box ? BOX_SIZE : styleManagerAxesChart.getMarkerSize(); + return series.getLegendRenderType() == LegendRenderType.Box ? BOX_SIZE : stylerAxesChart.getMarkerSize(); } } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/LegendPie.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_Pie.java similarity index 85% rename from xchart/src/main/java/org/knowm/xchart/internal/chartpart/LegendPie.java rename to xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_Pie.java index dfa351c7c750768df78c065209933528e01987d8..6257b92d6e9f0a420b184cf8e7ee6bb4820bf9e4 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/LegendPie.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Legend_Pie.java @@ -28,30 +28,30 @@ import java.util.Map; import org.knowm.xchart.Series_Pie; import org.knowm.xchart.Styler_Pie; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * @author timmolter */ -public class LegendPie<SM extends StyleManagerAxesChart, S extends Series> extends Legend { +public class Legend_Pie<ST extends Styler_AxesChart, S extends Series> extends Legend_ { - Styler_Pie styleManagerPie; + Styler_Pie stylerPie; /** * Constructor * * @param chart */ - public LegendPie(Chart<Styler_Pie, Series_Pie> chart) { + public Legend_Pie(Chart<Styler_Pie, Series_Pie> chart) { super(chart); - styleManagerPie = chart.getStyleManager(); + stylerPie = chart.getStyler(); } @Override public void paint(Graphics2D g) { - if (!chart.getStyleManager().isLegendVisible()) { + if (!chart.getStyler().isLegendVisible()) { return; } @@ -60,8 +60,8 @@ public class LegendPie<SM extends StyleManagerAxesChart, S extends Series> exten g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 0.0f }, 0.0f)); // Draw legend content inside legend box - double startx = xOffset + chart.getStyleManager().getLegendPadding(); - double starty = yOffset + chart.getStyleManager().getLegendPadding(); + double startx = xOffset + chart.getStyler().getLegendPadding(); + double starty = yOffset + chart.getStyler().getLegendPadding(); Map<String, Series> map = chart.getSeriesMap(); for (Series series : map.values()) { @@ -97,20 +97,20 @@ public class LegendPie<SM extends StyleManagerAxesChart, S extends Series> exten // // ////// paint series text ///////// - g.setColor(chart.getStyleManager().getChartFontColor()); + g.setColor(chart.getStyler().getChartFontColor()); double multiLineOffset = 0.0; // bar/pie type series - final double x = startx + BOX_SIZE + chart.getStyleManager().getLegendPadding(); + final double x = startx + BOX_SIZE + chart.getStyler().getLegendPadding(); for (Map.Entry<String, Rectangle2D> entry : seriesTextBounds.entrySet()) { double height = entry.getValue().getHeight(); double centerOffsetY = (Math.max(BOX_SIZE, height) - height) / 2.0; FontRenderContext frc = g.getFontRenderContext(); - TextLayout tl = new TextLayout(entry.getKey(), chart.getStyleManager().getLegendFont(), frc); + TextLayout tl = new TextLayout(entry.getKey(), chart.getStyler().getLegendFont(), frc); Shape shape = tl.getOutline(null); AffineTransform orig = g.getTransform(); AffineTransform at = new AffineTransform(); @@ -126,7 +126,7 @@ public class LegendPie<SM extends StyleManagerAxesChart, S extends Series> exten multiLineOffset += height + MULTI_LINE_SPACE; } - starty += legendEntryHeight + chart.getStyleManager().getLegendPadding(); + starty += legendEntryHeight + chart.getStyler().getLegendPadding(); } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/NumberFormatter.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/NumberFormatter.java index 223add217a69fdb908379348530076b67e62110c..6784fdf18bad0dec2477b05213d9833e3998679a 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/NumberFormatter.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/NumberFormatter.java @@ -21,21 +21,21 @@ import java.text.DecimalFormat; import java.text.NumberFormat; import org.knowm.xchart.internal.chartpart.Axis.Direction; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * @author timmolter */ public class NumberFormatter { - private final StyleManagerAxesChart styleManager; + private final Styler_AxesChart styler; /** * Constructor */ - public NumberFormatter(StyleManagerAxesChart styleManager) { + public NumberFormatter(Styler_AxesChart styler) { - this.styleManager = styleManager; + this.styler = styler; } public String getFormatPattern(BigDecimal value, double min, double max) { @@ -121,20 +121,20 @@ public class NumberFormatter { */ public String formatNumber(BigDecimal value, double min, double max, Direction axisDirection) { - NumberFormat numberFormat = NumberFormat.getNumberInstance(styleManager.getLocale()); + NumberFormat numberFormat = NumberFormat.getNumberInstance(styler.getLocale()); String decimalPattern; - if (axisDirection == Direction.X && styleManager.getXAxisDecimalPattern() != null) { + if (axisDirection == Direction.X && styler.getXAxisDecimalPattern() != null) { - decimalPattern = styleManager.getXAxisDecimalPattern(); + decimalPattern = styler.getXAxisDecimalPattern(); } - else if (axisDirection == Direction.Y && styleManager.getYAxisDecimalPattern() != null) { - decimalPattern = styleManager.getYAxisDecimalPattern(); + else if (axisDirection == Direction.Y && styler.getYAxisDecimalPattern() != null) { + decimalPattern = styler.getYAxisDecimalPattern(); } - else if (styleManager.getDecimalPattern() != null) { + else if (styler.getDecimalPattern() != null) { - decimalPattern = styleManager.getDecimalPattern(); + decimalPattern = styler.getDecimalPattern(); } else { decimalPattern = getFormatPattern(value, min, max); @@ -155,20 +155,20 @@ public class NumberFormatter { */ public String formatLogNumber(double value, Direction axisDirection) { - NumberFormat numberFormat = NumberFormat.getNumberInstance(styleManager.getLocale()); + NumberFormat numberFormat = NumberFormat.getNumberInstance(styler.getLocale()); String decimalPattern; - if (axisDirection == Direction.X && styleManager.getXAxisDecimalPattern() != null) { + if (axisDirection == Direction.X && styler.getXAxisDecimalPattern() != null) { - decimalPattern = styleManager.getXAxisDecimalPattern(); + decimalPattern = styler.getXAxisDecimalPattern(); } - else if (axisDirection == Direction.Y && styleManager.getYAxisDecimalPattern() != null) { - decimalPattern = styleManager.getYAxisDecimalPattern(); + else if (axisDirection == Direction.Y && styler.getYAxisDecimalPattern() != null) { + decimalPattern = styler.getYAxisDecimalPattern(); } - else if (styleManager.getDecimalPattern() != null) { + else if (styler.getDecimalPattern() != null) { - decimalPattern = styleManager.getDecimalPattern(); + decimalPattern = styler.getDecimalPattern(); } else { if (Math.abs(value) > 1000.0 || Math.abs(value) < 0.001) { diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_.java index 0f506b5c6ff7c622e687365d3da18576a9129f85..8a9dca34e3ac779506bbc646ba44853fe2b93992 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_.java @@ -21,14 +21,14 @@ import java.awt.Stroke; import java.awt.geom.Rectangle2D; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * @author timmolter */ -public abstract class PlotContent_<SM extends StyleManagerAxesChart, S extends Series> implements ChartPart { +public abstract class PlotContent_<ST extends Styler_AxesChart, S extends Series> implements ChartPart { - protected final Chart<SM, S> chart; + protected final Chart<ST, S> chart; protected final Stroke errorBarStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); @@ -37,7 +37,7 @@ public abstract class PlotContent_<SM extends StyleManagerAxesChart, S extends S * * @param chart - The Chart */ - protected PlotContent_(Chart<SM, S> chart) { + protected PlotContent_(Chart<ST, S> chart) { this.chart = chart; } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Bar.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Bar.java index e0becf60d60da772a1c6690ad26a059814276a63..6020bcfd857369d73c6ea5570ce014126ae2cf80 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Bar.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Bar.java @@ -30,15 +30,15 @@ import org.knowm.xchart.Series_Category.ChartCategorySeriesRenderStyle; import org.knowm.xchart.Styler_Category; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Utils; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; import org.knowm.xchart.internal.style.lines.SeriesLines; /** * @author timmolter */ -public class PlotContent_Category_Bar<SM extends StyleManager, S extends Series> extends PlotContent_ { +public class PlotContent_Category_Bar<ST extends Styler, S extends Series> extends PlotContent_ { - Styler_Category styleManagerCategory; + Styler_Category stylerCategory; /** * Constructor @@ -48,7 +48,7 @@ public class PlotContent_Category_Bar<SM extends StyleManager, S extends Series> protected PlotContent_Category_Bar(Chart<Styler_Category, Series_Category> chart) { super(chart); - this.styleManagerCategory = chart.getStyleManager(); + this.stylerCategory = chart.getStyler(); } @Override @@ -67,11 +67,11 @@ public class PlotContent_Category_Bar<SM extends StyleManager, S extends Series> g.setClip(bounds.createIntersection(rectangle)); // X-Axis - double xTickSpace = styleManagerCategory.getAxisTickSpacePercentage() * bounds.getWidth(); + double xTickSpace = stylerCategory.getAxisTickSpacePercentage() * bounds.getWidth(); double xLeftMargin = Utils.getTickStartOffset(bounds.getWidth(), xTickSpace); // Y-Axis - double yTickSpace = styleManagerCategory.getAxisTickSpacePercentage() * bounds.getHeight(); + double yTickSpace = stylerCategory.getAxisTickSpacePercentage() * bounds.getHeight(); double yTopMargin = Utils.getTickStartOffset(bounds.getHeight(), yTickSpace); Map<String, Series_Category> seriesMap = chart.getSeriesMap(); @@ -169,14 +169,14 @@ public class PlotContent_Category_Bar<SM extends StyleManager, S extends Series> double xOffset; double barWidth; - if (styleManagerCategory.isBarsOverlapped()) { - double barWidthPercentage = styleManagerCategory.getBarWidthPercentage(); + if (stylerCategory.isBarsOverlapped()) { + double barWidthPercentage = stylerCategory.getBarWidthPercentage(); barWidth = gridStep * barWidthPercentage; double barMargin = gridStep * (1 - barWidthPercentage) / 2; xOffset = bounds.getX() + xLeftMargin + gridStep * categoryCounter++ + barMargin; } else { - double barWidthPercentage = styleManagerCategory.getBarWidthPercentage(); + double barWidthPercentage = stylerCategory.getBarWidthPercentage(); barWidth = gridStep / chart.getSeriesMap().size() * barWidthPercentage; double barMargin = gridStep * (1 - barWidthPercentage) / 2; xOffset = bounds.getX() + xLeftMargin + gridStep * categoryCounter++ + seriesCounter * barWidth + barMargin; @@ -193,7 +193,7 @@ public class PlotContent_Category_Bar<SM extends StyleManager, S extends Series> path.lineTo(xOffset, zeroOffset); path.closePath(); g.setStroke(series.getLineStyle()); - if (styleManagerCategory.isBarFilled()) { + if (stylerCategory.isBarFilled()) { g.fill(path); } else { @@ -221,7 +221,7 @@ public class PlotContent_Category_Bar<SM extends StyleManager, S extends Series> // paint marker if (series.getMarker() != null) { g.setColor(series.getMarkerColor()); - series.getMarker().paint(g, previousX, previousY, styleManagerCategory.getMarkerSize()); + series.getMarker().paint(g, previousX, previousY, stylerCategory.getMarkerSize()); } } @@ -233,11 +233,11 @@ public class PlotContent_Category_Bar<SM extends StyleManager, S extends Series> double eb = ebItr.next().doubleValue(); // set error bar style - if (styleManagerCategory.isErrorBarsColorSeriesColor()) { + if (stylerCategory.isErrorBarsColorSeriesColor()) { g.setColor(series.getLineColor()); } else { - g.setColor(styleManagerCategory.getErrorBarsColor()); + g.setColor(stylerCategory.getErrorBarsColor()); } g.setStroke(errorBarStroke); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Line_Area_Scatter.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Line_Area_Scatter.java index 2beadc36eac85299cf2dfd27c8e17db12c29ebed..9d9db5d851341e2b27890ea68054b208f6b4957d 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Line_Area_Scatter.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Category_Line_Area_Scatter.java @@ -30,15 +30,15 @@ import org.knowm.xchart.Series_Category.ChartCategorySeriesRenderStyle; import org.knowm.xchart.Styler_Category; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Utils; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; import org.knowm.xchart.internal.style.lines.SeriesLines; /** * @author timmolter */ -public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S extends Series> extends PlotContent_ { +public class PlotContent_Category_Line_Area_Scatter<ST extends Styler, S extends Series> extends PlotContent_ { - Styler_Category styleManagerCategory; + Styler_Category stylerCategory; /** * Constructor @@ -48,14 +48,14 @@ public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S e protected PlotContent_Category_Line_Area_Scatter(Chart<Styler_Category, Series_Category> chart) { super(chart); - this.styleManagerCategory = styleManagerCategory; + this.stylerCategory = stylerCategory; } @Override public void paint(Graphics2D g) { // logarithmic - // if (styleManagerCategory.isYAxisLogarithmic()) { + // if (stylerCategory.isYAxisLogarithmic()) { // throw new IllegalArgumentException("Category Charts cannot have logarithmic axes!!! (Not Yet Implemented)"); // } @@ -85,11 +85,11 @@ public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S e // g.setClip(bounds.createIntersection(g.getClipBounds())); // X-Axis - double xTickSpace = styleManagerCategory.getAxisTickSpacePercentage() * bounds.getWidth(); + double xTickSpace = stylerCategory.getAxisTickSpacePercentage() * bounds.getWidth(); double xLeftMargin = Utils.getTickStartOffset((int) bounds.getWidth(), xTickSpace); // Y-Axis - double yTickSpace = styleManagerCategory.getAxisTickSpacePercentage() * bounds.getHeight(); + double yTickSpace = stylerCategory.getAxisTickSpacePercentage() * bounds.getHeight(); double yTopMargin = Utils.getTickStartOffset((int) bounds.getHeight(), yTickSpace); double xMin = chart.getAxisPair().getXAxis().getMin(); @@ -98,11 +98,11 @@ public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S e double yMax = chart.getAxisPair().getYAxis().getMax(); // logarithmic - if (styleManagerCategory.isXAxisLogarithmic()) { + if (stylerCategory.isXAxisLogarithmic()) { xMin = Math.log10(xMin); xMax = Math.log10(xMax); } - if (styleManagerCategory.isYAxisLogarithmic()) { + if (stylerCategory.isYAxisLogarithmic()) { yMin = Math.log10(yMin); yMax = Math.log10(yMax); } @@ -148,7 +148,7 @@ public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S e double y = 0.0; // System.out.println(y); - if (styleManagerCategory.isYAxisLogarithmic()) { + if (stylerCategory.isYAxisLogarithmic()) { y = Math.log10(yOrig); } else { @@ -211,7 +211,7 @@ public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S e // paint marker if (series.getMarker() != null) { g.setColor(series.getMarkerColor()); - series.getMarker().paint(g, xOffset, yOffset, styleManagerCategory.getMarkerSize()); + series.getMarker().paint(g, xOffset, yOffset, stylerCategory.getMarkerSize()); } // paint error bars @@ -220,17 +220,17 @@ public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S e double eb = ebItr.next().doubleValue(); // set error bar style - if (styleManagerCategory.isErrorBarsColorSeriesColor()) { + if (stylerCategory.isErrorBarsColorSeriesColor()) { g.setColor(series.getLineColor()); } else { - g.setColor(styleManagerCategory.getErrorBarsColor()); + g.setColor(stylerCategory.getErrorBarsColor()); } g.setStroke(errorBarStroke); // Top value double topValue = 0.0; - if (styleManagerCategory.isYAxisLogarithmic()) { + if (stylerCategory.isYAxisLogarithmic()) { topValue = yOrig + eb; topValue = Math.log10(topValue); } @@ -242,7 +242,7 @@ public class PlotContent_Category_Line_Area_Scatter<SM extends StyleManager, S e // Bottom value double bottomValue = 0.0; - if (styleManagerCategory.isYAxisLogarithmic()) { + if (stylerCategory.isYAxisLogarithmic()) { bottomValue = yOrig - eb; // System.out.println(bottomValue); bottomValue = Math.log10(bottomValue); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java index ad7c9f8fb04670c7b0784ca62b894d75740d4c34..d6accee1402ce0d08b526611f542df4a53257958 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_Pie.java @@ -29,14 +29,14 @@ import java.util.Map; import org.knowm.xchart.Series_Pie; import org.knowm.xchart.Styler_Pie; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; /** * @author timmolter */ -public class PlotContent_Pie<SM extends StyleManager, S extends Series> extends PlotContent_ { +public class PlotContent_Pie<ST extends Styler, S extends Series> extends PlotContent_ { - Styler_Pie styleManagerPie; + Styler_Pie stylerPie; DecimalFormat df = new DecimalFormat("#.0"); /** @@ -47,7 +47,7 @@ public class PlotContent_Pie<SM extends StyleManager, S extends Series> extends protected PlotContent_Pie(Chart<Styler_Pie, Series_Pie> chart) { super(chart); - styleManagerPie = chart.getStyleManager(); + stylerPie = chart.getStyler(); } @Override @@ -72,16 +72,16 @@ public class PlotContent_Pie<SM extends StyleManager, S extends Series> extends g.setClip(bounds.createIntersection(rectangle)); // pie bounds - double pieFillPercentage = styleManagerPie.getPieFillPercentage(); + double pieFillPercentage = stylerPie.getPieFillPercentage(); - // if (styleManagerPie.isCircular()) { + // if (stylerPie.isCircular()) { // // double pieDiameter = Math.min(bounds.getWidth(), bounds.getHeight()); // } double halfBorderPercentage = (1 - pieFillPercentage) / 2.0; - double width = styleManagerPie.isCircular() ? Math.min(bounds.getWidth(), bounds.getHeight()) : bounds.getWidth(); - double height = styleManagerPie.isCircular() ? Math.min(bounds.getWidth(), bounds.getHeight()) : bounds.getHeight(); + double width = stylerPie.isCircular() ? Math.min(bounds.getWidth(), bounds.getHeight()) : bounds.getWidth(); + double height = stylerPie.isCircular() ? Math.min(bounds.getWidth(), bounds.getHeight()) : bounds.getHeight(); Rectangle2D pieBounds = new Rectangle2D.Double( @@ -109,7 +109,7 @@ public class PlotContent_Pie<SM extends StyleManager, S extends Series> extends // draw pie slices // double curValue = 0.0; // double curValue = 0.0; - double startAngle = styleManagerPie.getStartAngleInDegrees() + 90; + double startAngle = stylerPie.getStartAngleInDegrees() + 90; map = chart.getSeriesMap(); for (Series_Pie series : map.values()) { @@ -120,14 +120,14 @@ public class PlotContent_Pie<SM extends StyleManager, S extends Series> extends double arcAngle = (y.doubleValue() * 360 / total); g.setColor(series.getFillColor()); g.fill(new Arc2D.Double(pieBounds.getX(), pieBounds.getY(), pieBounds.getWidth(), pieBounds.getHeight(), startAngle, arcAngle, Arc2D.PIE)); - g.setColor(styleManagerPie.getPlotBackgroundColor()); + g.setColor(stylerPie.getPlotBackgroundColor()); g.draw(new Arc2D.Double(pieBounds.getX(), pieBounds.getY(), pieBounds.getWidth(), pieBounds.getHeight(), startAngle, arcAngle, Arc2D.PIE)); // curValue += y.doubleValue(); // draw percentage on slice double percentage = y.doubleValue() / total * 100; - TextLayout textLayout = new TextLayout(df.format(percentage) + "%", chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false)); + TextLayout textLayout = new TextLayout(df.format(percentage) + "%", chart.getStyler().getLegendFont(), new FontRenderContext(null, true, false)); Rectangle2D percentageRectangle = textLayout.getBounds(); double xCenter = pieBounds.getX() + pieBounds.getWidth() / 2 - percentageRectangle.getWidth() / 2; @@ -136,8 +136,8 @@ public class PlotContent_Pie<SM extends StyleManager, S extends Series> extends double xOffset = xCenter + Math.cos(Math.toRadians(angle)) * (pieBounds.getWidth() / 3.33); double yOffset = yCenter - Math.sin(Math.toRadians(angle)) * (pieBounds.getHeight() / 3.33); - g.setColor(styleManagerPie.getChartFontColor()); - g.setFont(styleManagerPie.getChartTitleFont()); + g.setColor(stylerPie.getChartFontColor()); + g.setFont(stylerPie.getChartTitleFont()); Shape shape = textLayout.getOutline(null); AffineTransform orig = g.getTransform(); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_XY.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_XY.java index 05b516643c0ea11303f0a4465fb2e6c17440000a..0c6e08d51d2cdfac8d7cdd5f0536e2d9334efd84 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_XY.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotContent_XY.java @@ -32,15 +32,15 @@ import org.knowm.xchart.Styler_XY; import org.knowm.xchart.internal.Series; import org.knowm.xchart.internal.Utils; import org.knowm.xchart.internal.chartpart.Axis.AxisDataType; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; import org.knowm.xchart.internal.style.lines.SeriesLines; /** * @author timmolter */ -public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> extends PlotContent_ { +public class PlotContent_XY<ST extends Styler_AxesChart, S extends Series> extends PlotContent_ { - Styler_XY styleManagerXY; + Styler_XY stylerXY; /** * Constructor @@ -50,7 +50,7 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> protected PlotContent_XY(Chart<Styler_XY, Series_XY> chart) { super(chart); - styleManagerXY = chart.getStyleManager(); + stylerXY = chart.getStyler(); } @Override @@ -82,11 +82,11 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> // g.setClip(bounds.createIntersection(g.getClipBounds())); // X-Axis - double xTickSpace = styleManagerXY.getAxisTickSpacePercentage() * bounds.getWidth(); + double xTickSpace = stylerXY.getAxisTickSpacePercentage() * bounds.getWidth(); double xLeftMargin = Utils.getTickStartOffset((int) bounds.getWidth(), xTickSpace); // Y-Axis - double yTickSpace = styleManagerXY.getAxisTickSpacePercentage() * bounds.getHeight(); + double yTickSpace = stylerXY.getAxisTickSpacePercentage() * bounds.getHeight(); double yTopMargin = Utils.getTickStartOffset((int) bounds.getHeight(), yTickSpace); double xMin = chart.getXAxis().getMin(); @@ -95,11 +95,11 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> double yMax = chart.getYAxis().getMax(); // logarithmic - if (styleManagerXY.isXAxisLogarithmic()) { + if (stylerXY.isXAxisLogarithmic()) { xMin = Math.log10(xMin); xMax = Math.log10(xMax); } - if (styleManagerXY.isYAxisLogarithmic()) { + if (stylerXY.isYAxisLogarithmic()) { yMin = Math.log10(yMin); yMax = Math.log10(yMax); } @@ -133,7 +133,7 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> x = ((Date) xItr.next()).getTime(); } // System.out.println(x); - if (styleManagerXY.isXAxisLogarithmic()) { + if (stylerXY.isXAxisLogarithmic()) { x = Math.log10(x); } // System.out.println(x); @@ -155,7 +155,7 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> double y = 0.0; // System.out.println(y); - if (styleManagerXY.isYAxisLogarithmic()) { + if (stylerXY.isYAxisLogarithmic()) { y = Math.log10(yOrig); } else { @@ -226,7 +226,7 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> // paint marker if (series.getMarker() != null) { // if set to Marker.NONE, the marker is null g.setColor(series.getMarkerColor()); - series.getMarker().paint(g, xOffset, yOffset, styleManagerXY.getMarkerSize()); + series.getMarker().paint(g, xOffset, yOffset, stylerXY.getMarkerSize()); } // paint error bars @@ -235,17 +235,17 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> double eb = ebItr.next().doubleValue(); // set error bar style - if (styleManagerXY.isErrorBarsColorSeriesColor()) { + if (stylerXY.isErrorBarsColorSeriesColor()) { g.setColor(series.getLineColor()); } else { - g.setColor(styleManagerXY.getErrorBarsColor()); + g.setColor(stylerXY.getErrorBarsColor()); } g.setStroke(errorBarStroke); // Top value double topValue = 0.0; - if (styleManagerXY.isYAxisLogarithmic()) { + if (stylerXY.isYAxisLogarithmic()) { topValue = yOrig + eb; topValue = Math.log10(topValue); } @@ -257,7 +257,7 @@ public class PlotContent_XY<SM extends StyleManagerAxesChart, S extends Series> // Bottom value double bottomValue = 0.0; - if (styleManagerXY.isYAxisLogarithmic()) { + if (stylerXY.isYAxisLogarithmic()) { bottomValue = yOrig - eb; // System.out.println(bottomValue); bottomValue = Math.log10(bottomValue); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_.java similarity index 81% rename from xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface.java rename to xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_.java index bbbf0dee6d76f3ef34c7c21be0599e4c34ae324f..56c1b2cd4b3886286e840852ef654a0dc41d81e0 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_.java @@ -19,21 +19,21 @@ package org.knowm.xchart.internal.chartpart; import java.awt.geom.Rectangle2D; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; /** * @author timmolter */ -public abstract class PlotSurface<SM extends StyleManager, S extends Series> implements ChartPart { +public abstract class PlotSurface_<ST extends Styler, S extends Series> implements ChartPart { - protected final Chart<SM, S> chart; + protected final Chart<ST, S> chart; /** * Constructor * * @param chart */ - protected PlotSurface(Chart<SM, S> chart) { + protected PlotSurface_(Chart<ST, S> chart) { this.chart = chart; } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurfaceAxesChart.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_AxesChart.java similarity index 60% rename from xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurfaceAxesChart.java rename to xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_AxesChart.java index e17923cc12034f190c3d7935bb196697f50e9005..cdace49391cc73051721954970354aadd473ed69 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurfaceAxesChart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_AxesChart.java @@ -24,27 +24,27 @@ import java.util.List; import org.knowm.xchart.Series_XY; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * Draws the plot background, the plot border and the horizontal and vertical grid lines * * @author timmolter */ -public class PlotSurfaceAxesChart<SM extends StyleManager, S extends Series> extends PlotSurface { +public class PlotSurface_AxesChart<ST extends Styler, S extends Series> extends PlotSurface_ { - private final StyleManagerAxesChart styleManagerAxesChart; + private final Styler_AxesChart stylerAxesChart; /** * Constructor * * @param chart */ - protected PlotSurfaceAxesChart(Chart<StyleManagerAxesChart, Series_XY> chart) { + protected PlotSurface_AxesChart(Chart<Styler_AxesChart, Series_XY> chart) { super(chart); - this.styleManagerAxesChart = chart.getStyleManager(); + this.stylerAxesChart = chart.getStyler(); } @Override @@ -54,20 +54,20 @@ public class PlotSurfaceAxesChart<SM extends StyleManager, S extends Series> ext // paint plot background Shape rect = new Rectangle2D.Double(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); - g.setColor(styleManagerAxesChart.getPlotBackgroundColor()); + g.setColor(stylerAxesChart.getPlotBackgroundColor()); g.fill(rect); // paint plot border - if (styleManagerAxesChart.isPlotBorderVisible()) { - g.setColor(styleManagerAxesChart.getPlotBorderColor()); - // g.setStroke(getChartPainter().getStyleManager().getAxisTickMarksStroke()); + if (stylerAxesChart.isPlotBorderVisible()) { + g.setColor(stylerAxesChart.getPlotBorderColor()); + // g.setStroke(getChartPainter().getstyler().getAxisTickMarksStroke()); g.draw(rect); } // paint grid lines and/or inner plot ticks // horizontal - if (styleManagerAxesChart.isPlotGridHorizontalLinesVisible() || styleManagerAxesChart.isPlotTicksMarksVisible()) { + if (stylerAxesChart.isPlotGridHorizontalLinesVisible() || stylerAxesChart.isPlotTicksMarksVisible()) { List<Double> yAxisTickLocations = chart.getYAxis().getAxisTickCalculator().getTickLocations(); for (int i = 0; i < yAxisTickLocations.size(); i++) { @@ -77,22 +77,22 @@ public class PlotSurfaceAxesChart<SM extends StyleManager, S extends Series> ext if (yOffset > bounds.getY() && yOffset < bounds.getY() + bounds.getHeight()) { // draw lines - if (styleManagerAxesChart.isPlotGridHorizontalLinesVisible()) { + if (stylerAxesChart.isPlotGridHorizontalLinesVisible()) { - g.setColor(styleManagerAxesChart.getPlotGridLinesColor()); - g.setStroke(styleManagerAxesChart.getPlotGridLinesStroke()); + g.setColor(stylerAxesChart.getPlotGridLinesColor()); + g.setStroke(stylerAxesChart.getPlotGridLinesStroke()); Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + bounds.getWidth(), yOffset); g.draw(line); } // tick marks - if (styleManagerAxesChart.isPlotTicksMarksVisible()) { + if (stylerAxesChart.isPlotTicksMarksVisible()) { - g.setColor(styleManagerAxesChart.getAxisTickMarksColor()); - g.setStroke(styleManagerAxesChart.getAxisTickMarksStroke()); - Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + styleManagerAxesChart.getAxisTickMarkLength(), yOffset); + g.setColor(stylerAxesChart.getAxisTickMarksColor()); + g.setStroke(stylerAxesChart.getAxisTickMarksStroke()); + Shape line = new Line2D.Double(bounds.getX(), yOffset, bounds.getX() + stylerAxesChart.getAxisTickMarkLength(), yOffset); g.draw(line); - line = new Line2D.Double(bounds.getX() + bounds.getWidth(), yOffset, bounds.getX() + bounds.getWidth() - styleManagerAxesChart.getAxisTickMarkLength(), yOffset); + line = new Line2D.Double(bounds.getX() + bounds.getWidth(), yOffset, bounds.getX() + bounds.getWidth() - stylerAxesChart.getAxisTickMarkLength(), yOffset); g.draw(line); } } @@ -101,7 +101,7 @@ public class PlotSurfaceAxesChart<SM extends StyleManager, S extends Series> ext // vertical - if ((styleManagerAxesChart.isPlotGridVerticalLinesVisible() || styleManagerAxesChart.isPlotTicksMarksVisible())) { + if ((stylerAxesChart.isPlotGridVerticalLinesVisible() || stylerAxesChart.isPlotTicksMarksVisible())) { List<Double> xAxisTickLocations = chart.getXAxis().getAxisTickCalculator().getTickLocations(); for (int i = 0; i < xAxisTickLocations.size(); i++) { @@ -112,22 +112,22 @@ public class PlotSurfaceAxesChart<SM extends StyleManager, S extends Series> ext if (xOffset > bounds.getX() && xOffset < bounds.getX() + bounds.getWidth()) { // draw lines - if (styleManagerAxesChart.isPlotGridVerticalLinesVisible()) { - g.setColor(styleManagerAxesChart.getPlotGridLinesColor()); - g.setStroke(styleManagerAxesChart.getPlotGridLinesStroke()); + if (stylerAxesChart.isPlotGridVerticalLinesVisible()) { + g.setColor(stylerAxesChart.getPlotGridLinesColor()); + g.setStroke(stylerAxesChart.getPlotGridLinesStroke()); Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + bounds.getHeight()); g.draw(line); } // tick marks - if (styleManagerAxesChart.isPlotTicksMarksVisible()) { + if (stylerAxesChart.isPlotTicksMarksVisible()) { - g.setColor(styleManagerAxesChart.getAxisTickMarksColor()); - g.setStroke(styleManagerAxesChart.getAxisTickMarksStroke()); + g.setColor(stylerAxesChart.getAxisTickMarksColor()); + g.setStroke(stylerAxesChart.getAxisTickMarksStroke()); - Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + styleManagerAxesChart.getAxisTickMarkLength()); + Shape line = new Line2D.Double(xOffset, bounds.getY(), xOffset, bounds.getY() + stylerAxesChart.getAxisTickMarkLength()); g.draw(line); - line = new Line2D.Double(xOffset, bounds.getY() + bounds.getHeight(), xOffset, bounds.getY() + bounds.getHeight() - styleManagerAxesChart.getAxisTickMarkLength()); + line = new Line2D.Double(xOffset, bounds.getY() + bounds.getHeight(), xOffset, bounds.getY() + bounds.getHeight() - stylerAxesChart.getAxisTickMarkLength()); g.draw(line); } } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurfacePie.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_Pie.java similarity index 71% rename from xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurfacePie.java rename to xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_Pie.java index d9251453d59393a5c9154e814a13507e42b6f9f2..48fc244e314e15bdd525d96b3ae5f46d5dc5cff2 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurfacePie.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/PlotSurface_Pie.java @@ -23,26 +23,26 @@ import java.awt.geom.Rectangle2D; import org.knowm.xchart.Series_Pie; import org.knowm.xchart.Styler_Pie; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; /** * Draws the plot background and the plot border * * @author timmolter */ -public class PlotSurfacePie<SM extends StyleManager, S extends Series> extends PlotSurface { +public class PlotSurface_Pie<ST extends Styler, S extends Series> extends PlotSurface_ { - private final Styler_Pie styleManagerPie; + private final Styler_Pie stylerPie; /** * Constructor * * @param chart */ - protected PlotSurfacePie(Chart<Styler_Pie, Series_Pie> chart) { + protected PlotSurface_Pie(Chart<Styler_Pie, Series_Pie> chart) { super(chart); - this.styleManagerPie = chart.getStyleManager(); + this.stylerPie = chart.getStyler(); } @Override @@ -52,13 +52,13 @@ public class PlotSurfacePie<SM extends StyleManager, S extends Series> extends P // paint plot background Shape rect = new Rectangle2D.Double(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); - g.setColor(styleManagerPie.getPlotBackgroundColor()); + g.setColor(stylerPie.getPlotBackgroundColor()); g.fill(rect); // paint plot border - if (styleManagerPie.isPlotBorderVisible()) { - g.setColor(styleManagerPie.getPlotBorderColor()); - // g.setStroke(getChartPainter().getStyleManager().getAxisTickMarksStroke()); + if (stylerPie.isPlotBorderVisible()) { + g.setColor(stylerPie.getPlotBorderColor()); + // g.setStroke(getChartPainter().getstyler().getAxisTickMarksStroke()); g.draw(rect); } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_.java index eea3f4848ad941f289740c6bda9ec3d5d51176cd..4ae95fd20c3eeb739e3c9d4c00ebb3ed237dc13f 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_.java @@ -20,17 +20,17 @@ import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; +import org.knowm.xchart.internal.style.Styler; /** * @author timmolter */ -public class Plot_<SM extends StyleManager, S extends Series> implements ChartPart { +public class Plot_<ST extends Styler, S extends Series> implements ChartPart { - protected final Chart<SM, S> chart; + protected final Chart<ST, S> chart; protected Rectangle2D bounds; - protected PlotSurface plotSurface; + protected PlotSurface_ plotSurface; protected PlotContent_ plotContent; /** @@ -38,7 +38,7 @@ public class Plot_<SM extends StyleManager, S extends Series> implements ChartPa * * @param chart */ - public Plot_(Chart<SM, S> chart) { + public Plot_(Chart<ST, S> chart) { this.chart = chart; } @@ -50,25 +50,11 @@ public class Plot_<SM extends StyleManager, S extends Series> implements ChartPa // g.draw(bounds); plotSurface.paint(g); + if (chart.getSeriesMap().isEmpty()) { + return; + } plotContent.paint(g); - // if (chart.getChartType() == Chart.ChartType.Category) { - // if (((StyleManagerCategory) chart.getStyleManager()).getChartCategorySeriesType() == ChartCategorySeriesType.Bar) { - // this.plotContent = new PlotContentCategoricalChart_Bar(this); - // } - // - // else { - // this.plotContent = new PlotContentCategoricalChart_Line_Area_Scatter(this); - // } - // } - // else if (chart.getChartType() == Chart.ChartType.Pie) { - // this.plotContent = new PlotContentCategoricalChart_Pie(this); - // } - // else { - // this.plotContent = new PlotContentXYChart(chart); - // } - // plotContent.paint(g); - } @Override diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_AxesChart.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_AxesChart.java index a099890119fef1d8665c78b7be982eb2fd8a5b9f..bd17c2501a108637e33042859bd2dfbca1853a61 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_AxesChart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_AxesChart.java @@ -21,26 +21,26 @@ import java.awt.geom.Rectangle2D; import org.knowm.xchart.Series_XY; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * @author timmolter */ -public class Plot_AxesChart<SM extends StyleManager, S extends Series> extends Plot_ { +public class Plot_AxesChart<ST extends Styler, S extends Series> extends Plot_ { - StyleManagerAxesChart styleManagerAxesChart; + Styler_AxesChart stylerAxesChart; /** * Constructor * * @param chart */ - public Plot_AxesChart(Chart<StyleManagerAxesChart, Series_XY> chart) { + public Plot_AxesChart(Chart<Styler_AxesChart, Series_XY> chart) { super(chart); - styleManagerAxesChart = chart.getStyleManager(); - this.plotSurface = new PlotSurfaceAxesChart<StyleManagerAxesChart, Series_XY>(chart); + stylerAxesChart = chart.getStyler(); + this.plotSurface = new PlotSurface_AxesChart<Styler_AxesChart, Series_XY>(chart); } @Override @@ -49,12 +49,12 @@ public class Plot_AxesChart<SM extends StyleManager, S extends Series> extends P // calculate bounds double xOffset = chart.getYAxis().getBounds().getX() + chart.getYAxis().getBounds().getWidth() - + (styleManagerAxesChart.isYAxisTicksVisible() ? styleManagerAxesChart.getPlotPadding() : 0); + + (stylerAxesChart.isYAxisTicksVisible() ? stylerAxesChart.getPlotPadding() : 0); double yOffset = chart.getYAxis().getBounds().getY(); double width = chart.getXAxis().getBounds().getWidth(); double height = chart.getYAxis().getBounds().getHeight(); - bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); + this.bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); super.paint(g); } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Category.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Category.java index fe5838da97e192fea346cab181455738b9f11001..19754072d807971d7dfb6f87fe52223906aacd03 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Category.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Category.java @@ -19,13 +19,13 @@ package org.knowm.xchart.internal.chartpart; import org.knowm.xchart.Series_Category; import org.knowm.xchart.Series_Category.ChartCategorySeriesRenderStyle; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; import org.knowm.xchart.Styler_Category; /** * @author timmolter */ -public class Plot_Category<SM extends StyleManagerAxesChart, S extends Series> extends Plot_AxesChart { +public class Plot_Category<ST extends Styler_AxesChart, S extends Series> extends Plot_AxesChart { /** * Constructor @@ -36,9 +36,9 @@ public class Plot_Category<SM extends StyleManagerAxesChart, S extends Series> e super(chart); - Styler_Category styleManagerCategory = chart.getStyleManager(); + Styler_Category stylerCategory = chart.getStyler(); - if (ChartCategorySeriesRenderStyle.Bar.equals(styleManagerCategory.getChartCategorySeriesRenderStyle())) { + if (ChartCategorySeriesRenderStyle.Bar.equals(stylerCategory.getChartCategorySeriesRenderStyle())) { this.plotContent = new PlotContent_Category_Bar<Styler_Category, Series_Category>(chart); diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Pie.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Pie.java index 4c06cf228cde14eaf757eed98809cd1023fbcd97..6c4fe3a45c23ac39c228ce0e29ce9eed306c9426 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Pie.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_Pie.java @@ -22,13 +22,13 @@ import java.awt.geom.Rectangle2D; import org.knowm.xchart.Series_Pie; import org.knowm.xchart.Styler_Pie; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManager; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler; +import org.knowm.xchart.internal.style.Styler.LegendPosition; /** * @author timmolter */ -public class Plot_Pie<SM extends StyleManager, S extends Series> extends Plot_ { +public class Plot_Pie<ST extends Styler, S extends Series> extends Plot_ { /** * Constructor @@ -39,30 +39,30 @@ public class Plot_Pie<SM extends StyleManager, S extends Series> extends Plot_ { super(chart); this.plotContent = new PlotContent_Pie<Styler_Pie, Series_Pie>(chart); - this.plotSurface = new PlotSurfacePie<Styler_Pie, Series_Pie>(chart); + this.plotSurface = new PlotSurface_Pie<Styler_Pie, Series_Pie>(chart); } @Override public void paint(Graphics2D g) { // calculate bounds - double xOffset = chart.getStyleManager().getChartPadding(); + double xOffset = chart.getStyler().getChartPadding(); - double yOffset = chart.getChartTitle().getBounds().getY() + chart.getStyleManager().getChartPadding(); + double yOffset = chart.getChartTitle().getBounds().getHeight() + 2 * chart.getStyler().getChartPadding(); double width = chart.getWidth() - - (chart.getStyleManager().getLegendPosition() == LegendPosition.OutsideE ? chart.getChartLegend().getBounds().getWidth() : 0) + - (chart.getStyler().getLegendPosition() == LegendPosition.OutsideE ? chart.getLegend().getBounds().getWidth() : 0) - - 2 * chart.getStyleManager().getChartPadding() + - 2 * chart.getStyler().getChartPadding() - - (chart.getStyleManager().getLegendPosition() == LegendPosition.OutsideE && chart.getStyleManager().isLegendVisible() ? chart.getStyleManager().getChartPadding() : 0); + - (chart.getStyler().getLegendPosition() == LegendPosition.OutsideE && chart.getStyler().isLegendVisible() ? chart.getStyler().getChartPadding() : 0); - double height = chart.getHeight() - chart.getChartTitle().getBounds().getHeight() - 2 * chart.getStyleManager().getChartPadding(); + double height = chart.getHeight() - chart.getChartTitle().getBounds().getHeight() - 2 * chart.getStyler().getChartPadding(); - bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); + this.bounds = new Rectangle2D.Double(xOffset, yOffset, width, height); super.paint(g); } diff --git a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_XY.java b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_XY.java index cb24c5126150a466d6bca0da18bbbe306746ea1d..f4cf136595417870e4dd53aac77972cc6220006a 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_XY.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/chartpart/Plot_XY.java @@ -19,12 +19,12 @@ package org.knowm.xchart.internal.chartpart; import org.knowm.xchart.Series_XY; import org.knowm.xchart.Styler_XY; import org.knowm.xchart.internal.Series; -import org.knowm.xchart.internal.style.StyleManagerAxesChart; +import org.knowm.xchart.internal.style.Styler_AxesChart; /** * @author timmolter */ -public class Plot_XY<SM extends StyleManagerAxesChart, S extends Series> extends Plot_AxesChart { +public class Plot_XY<ST extends Styler_AxesChart, S extends Series> extends Plot_AxesChart { /** * Constructor diff --git a/xchart/src/main/java/org/knowm/xchart/internal/style/StyleManager.java b/xchart/src/main/java/org/knowm/xchart/internal/style/Styler.java similarity index 96% rename from xchart/src/main/java/org/knowm/xchart/internal/style/StyleManager.java rename to xchart/src/main/java/org/knowm/xchart/internal/style/Styler.java index 9adf1c3ebfafc3ef324e6a4fe3cc94fc4809b3ca..d453049698a7c0506e83022331e89cc469ab1467 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/style/StyleManager.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/style/Styler.java @@ -23,11 +23,11 @@ import java.awt.Font; import org.knowm.xchart.internal.style.markers.Marker; /** - * The StyleManager is used to manage all things related to styling of the vast number of Chart components + * The styler is used to manage all things related to styling of the vast number of Chart components * * @author timmolter */ -public abstract class StyleManager { +public abstract class Styler { public enum LegendPosition { @@ -38,18 +38,18 @@ public abstract class StyleManager { XChart, GGPlot2, Matlab; - public Theme newInstance(ChartTheme chartTheme) { + public Theme_ newInstance(ChartTheme chartTheme) { switch (chartTheme) { case GGPlot2: - return new GGPlot2Theme(); + return new Theme_GGPlot2(); case Matlab: - return new MatlabTheme(); + return new Theme_Matlab(); case XChart: default: - return new XChartTheme(); + return new Theme_XChart(); } } } @@ -60,7 +60,7 @@ public abstract class StyleManager { } /** the default Theme */ - protected Theme theme = new XChartTheme(); + protected Theme_ theme = new Theme_XChart(); // Chart Style /////////////////////////////// private Color chartBackgroundColor; diff --git a/xchart/src/main/java/org/knowm/xchart/internal/style/StyleManagerAxesChart.java b/xchart/src/main/java/org/knowm/xchart/internal/style/Styler_AxesChart.java similarity index 99% rename from xchart/src/main/java/org/knowm/xchart/internal/style/StyleManagerAxesChart.java rename to xchart/src/main/java/org/knowm/xchart/internal/style/Styler_AxesChart.java index 61635c09e8839a90672a5dc18d1235bf348bf01f..78c19603f80aea31dbe1e6e52faad61cad7e56b1 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/style/StyleManagerAxesChart.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/style/Styler_AxesChart.java @@ -25,7 +25,7 @@ import java.util.TimeZone; /** * @author timmolter */ -public abstract class StyleManagerAxesChart extends StyleManager { +public abstract class Styler_AxesChart extends Styler { // Chart Axes /////////////////////////////// private boolean xAxisTitleVisible; diff --git a/xchart/src/main/java/org/knowm/xchart/internal/style/Theme.java b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_.java similarity index 96% rename from xchart/src/main/java/org/knowm/xchart/internal/style/Theme.java rename to xchart/src/main/java/org/knowm/xchart/internal/style/Theme_.java index 133fb521faa10782c818b154b426343a50abf1ac..d52ca4ab15762e1497a3873847d8d8687cf1af21 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/style/Theme.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_.java @@ -20,7 +20,7 @@ import java.awt.Color; import java.awt.Font; import java.awt.Stroke; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.colors.SeriesColors; import org.knowm.xchart.internal.style.lines.SeriesLines; import org.knowm.xchart.internal.style.markers.SeriesMarkers; @@ -28,7 +28,7 @@ import org.knowm.xchart.internal.style.markers.SeriesMarkers; /** * @author timmolter */ -public interface Theme extends SeriesMarkers, SeriesLines, SeriesColors { +public interface Theme_ extends SeriesMarkers, SeriesLines, SeriesColors { // Chart Style /////////////////////////////// diff --git a/xchart/src/main/java/org/knowm/xchart/internal/style/GGPlot2Theme.java b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_GGPlot2.java similarity index 98% rename from xchart/src/main/java/org/knowm/xchart/internal/style/GGPlot2Theme.java rename to xchart/src/main/java/org/knowm/xchart/internal/style/Theme_GGPlot2.java index bc254faa7eb7ad01c5b291ef643d1d10ec061c73..33b047d517e71623989848728155f5fa2510fe22 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/style/GGPlot2Theme.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_GGPlot2.java @@ -21,7 +21,7 @@ import java.awt.Color; import java.awt.Font; import java.awt.Stroke; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.colors.ChartColor; import org.knowm.xchart.internal.style.colors.GGPlot2SeriesColors; import org.knowm.xchart.internal.style.lines.GGPlot2SeriesLines; @@ -31,7 +31,7 @@ import org.knowm.xchart.internal.style.markers.Marker; /** * @author timmolter */ -public class GGPlot2Theme implements Theme { +public class Theme_GGPlot2 implements Theme_ { // Chart Style /////////////////////////////// @@ -82,7 +82,7 @@ public class GGPlot2Theme implements Theme { @Override public boolean isChartTitleVisible() { - return false; + return true; } @Override diff --git a/xchart/src/main/java/org/knowm/xchart/internal/style/MatlabTheme.java b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_Matlab.java similarity index 98% rename from xchart/src/main/java/org/knowm/xchart/internal/style/MatlabTheme.java rename to xchart/src/main/java/org/knowm/xchart/internal/style/Theme_Matlab.java index c7477fd63f16b0330fba6920365dbe5f2285c9ee..569d3486044eff41876a58f3f166ac84cf009831 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/style/MatlabTheme.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_Matlab.java @@ -21,7 +21,7 @@ import java.awt.Color; import java.awt.Font; import java.awt.Stroke; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.colors.ChartColor; import org.knowm.xchart.internal.style.colors.MatlabSeriesColors; import org.knowm.xchart.internal.style.lines.MatlabSeriesLines; @@ -31,7 +31,7 @@ import org.knowm.xchart.internal.style.markers.MatlabSeriesMarkers; /** * @author timmolter */ -public class MatlabTheme implements Theme { +public class Theme_Matlab implements Theme_ { // Chart Style /////////////////////////////// @@ -85,7 +85,7 @@ public class MatlabTheme implements Theme { @Override public boolean isChartTitleVisible() { - return false; + return true; } @Override diff --git a/xchart/src/main/java/org/knowm/xchart/internal/style/XChartTheme.java b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_XChart.java similarity index 98% rename from xchart/src/main/java/org/knowm/xchart/internal/style/XChartTheme.java rename to xchart/src/main/java/org/knowm/xchart/internal/style/Theme_XChart.java index 906d2f876aa8551f41334236ef16c4ca940cf3ec..8ea4902a1e8df19bef259c3543bb7630aae9c455 100644 --- a/xchart/src/main/java/org/knowm/xchart/internal/style/XChartTheme.java +++ b/xchart/src/main/java/org/knowm/xchart/internal/style/Theme_XChart.java @@ -21,7 +21,7 @@ import java.awt.Color; import java.awt.Font; import java.awt.Stroke; -import org.knowm.xchart.internal.style.StyleManager.LegendPosition; +import org.knowm.xchart.internal.style.Styler.LegendPosition; import org.knowm.xchart.internal.style.colors.ChartColor; import org.knowm.xchart.internal.style.colors.XChartSeriesColors; import org.knowm.xchart.internal.style.lines.XChartSeriesLines; @@ -31,7 +31,7 @@ import org.knowm.xchart.internal.style.markers.XChartSeriesMarkers; /** * @author timmolter */ -public class XChartTheme implements Theme { +public class Theme_XChart implements Theme_ { // Chart Style /////////////////////////////// @@ -82,7 +82,7 @@ public class XChartTheme implements Theme { @Override public boolean isChartTitleVisible() { - return false; + return true; } @Override