Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java @ 7068:726d998dce29 generator-refactoring
Remove Axis Walker, unabstract Diagram generator
Diagram generator can now be used as an instance configured
in the out-generators config
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 20 Sep 2013 14:55:44 +0200 |
parents | 06a9a241faac |
children | 0a337f0005c2 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Fri Sep 20 14:54:26 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Fri Sep 20 14:55:44 2013 +0200 @@ -126,16 +126,7 @@ /** List of annotations to insert in plot. */ protected List<RiverAnnotation> annotations = new ArrayList<RiverAnnotation>(); - /** - * A mini interface that allows to walk over the YAXIS enums defined in - * subclasses. - */ - public interface YAxisWalker { - - int length(); - - String getId(int idx); - } // end of YAxisWalker interface + protected abstract List<AxisSection> buildYAxisSections(); /** * Default constructor that initializes internal data structures. @@ -169,8 +160,6 @@ boolean visible); - protected abstract YAxisWalker getYAxisWalker(); - protected abstract Series getSeriesOf(XYDataset dataset, int idx); @@ -181,6 +170,13 @@ */ protected abstract String getDefaultChartTitle(); + /** + * Returns the default Y-Axis label of a chart. + * + * @return the default Y-Axis label of a chart. + */ + protected abstract String getDefaultYAxisLabel(int index); + /** * Returns the default X-Axis label of a chart. @@ -189,18 +185,6 @@ */ protected abstract String getDefaultXAxisLabel(); - - /** - * This method is called to retrieve the default label for an Y axis at - * position <i>pos</i>. - * - * @param pos The position of an Y axis. - * - * @return the default Y axis label at position <i>pos</i>. - */ - protected abstract String getDefaultYAxisLabel(int pos); - - /** * This method is used to create new AxisDataset instances which may differ * in concrete subclasses. @@ -481,38 +465,6 @@ /** - * Creates a list of Section for the chart's Y axes. This method makes use - * of <i>getYAxisWalker</i> to be able to access all Y axes defined in - * subclasses. - * - * @return a list of Y axis sections. - */ - protected List<AxisSection> buildYAxisSections() { - List<AxisSection> axisSections = new ArrayList<AxisSection>(); - - YAxisWalker walker = getYAxisWalker(); - for (int i = 0, n = walker.length(); i < n; i++) { - AxisSection ySection = new AxisSection(); - ySection.setIdentifier(walker.getId(i)); - ySection.setLabel(getYAxisLabel(i)); - ySection.setFontSize(14); - ySection.setFixed(false); - - // XXX We are able to find better default ranges that [0,0], the - // only problem is, that we do NOT have a better range than [0,0] - // for each axis, because the initial chart will not have a dataset - // for each axis set! - ySection.setUpperRange(0d); - ySection.setLowerRange(0d); - - axisSections.add(ySection); - } - - return axisSections; - } - - - /** * Returns the <i>settings</i> as <i>ChartSettings</i>. * * @return the <i>settings</i> as <i>ChartSettings</i> or null, if @@ -804,6 +756,10 @@ return fontSize != null ? fontSize : DEFAULT_FONT_SIZE; } + /** + * Glue between axis names and index. + */ + protected abstract String axisIndexToName(int index); /** * This method returns the font size for an Y axis. If the font size is @@ -812,15 +768,13 @@ * * @return the font size for the x axis. */ - protected int getYAxisFontSize(int pos) { + protected int getYAxisFontSize(int index) { ChartSettings chartSettings = getChartSettings(); if (chartSettings == null) { return DEFAULT_FONT_SIZE; } - YAxisWalker walker = getYAxisWalker(); - - AxisSection as = chartSettings.getAxisSection(walker.getId(pos)); + AxisSection as = chartSettings.getAxisSection(axisIndexToName(index)); if (as == null) { return DEFAULT_FONT_SIZE; } @@ -829,7 +783,6 @@ return fontSize != null ? fontSize : DEFAULT_FONT_SIZE; } - /** * This method returns the export dimension specified in ChartSettings as * int array [width,height]. @@ -860,6 +813,8 @@ * @return the Y-Axis label of a chart at position <i>0</i>. */ protected String getYAxisLabel(int pos) { + return "TODO lalal"; + /* ChartSettings chartSettings = getChartSettings(); if (chartSettings == null) { return getDefaultYAxisLabel(pos); @@ -875,7 +830,7 @@ } } - return getDefaultYAxisLabel(pos); + return getDefaultYAxisLabel(pos);*/ } @@ -1417,9 +1372,7 @@ * @return an instance of IdentifiableNumberAxis. */ protected NumberAxis createNumberAxis(int idx, String label) { - YAxisWalker walker = getYAxisWalker(); - - return new IdentifiableNumberAxis(walker.getId(idx), label); + return new IdentifiableNumberAxis(axisIndexToName(idx), label); } @@ -1428,7 +1381,6 @@ * Shall be overriden by subclasses. */ protected NumberAxis createYAxis(int index) { - YAxisWalker walker = getYAxisWalker(); Font labelFont = new Font( DEFAULT_FONT_NAME, @@ -1436,7 +1388,7 @@ getYAxisFontSize(index)); IdentifiableNumberAxis axis = new IdentifiableNumberAxis( - walker.getId(index), + axisIndexToName(index), getYAxisLabel(index)); axis.setAutoRangeIncludesZero(false);