diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2236:c2b15d9c0f43

Refactoring: moved more base code from XYChartGenerator into its parent class ChartGenerator flys-artifacts/trunk@3883 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 02 Feb 2012 14:00:40 +0000
parents 46ec09c7f578
children 23c7c51df772
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Thu Feb 02 13:23:55 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Thu Feb 02 14:00:40 2012 +0000
@@ -11,7 +11,6 @@
 
 import java.awt.image.BufferedImage;
 
-import java.io.IOException;
 
 import java.text.NumberFormat;
 
@@ -46,13 +45,10 @@
 import org.jfree.ui.RectangleInsets;
 import org.jfree.ui.TextAnchor;
 
-import de.intevation.artifacts.CallContext;
 
 import de.intevation.artifactdatabase.state.Facet;
-import de.intevation.artifactdatabase.state.Settings;
 
 
-import de.intevation.flys.exports.ChartExportHelper;
 import de.intevation.flys.jfree.EnhancedLineAndShapeRenderer;
 import de.intevation.flys.jfree.FLYSAnnotation;
 import de.intevation.flys.jfree.StableXYDifferenceRenderer;
@@ -442,16 +438,6 @@
     }
 
 
-    /** Creates Font (Family and size) to use when creating Legend Items. */
-    protected Font createLegendLabelFont() {
-        return new Font(
-            DEFAULT_FONT_NAME,
-            Font.PLAIN,
-            getLegendFontSize()
-        );
-    }
-
-
     /**
      * If no data is visible, draw at least empty axis.
      */
@@ -632,50 +618,6 @@
     }
 
 
-    /**
-     * This method searches for a specific axis in the <i>settings</i> if
-     * <i>settings</i> is set. If the axis was found, this method returns the
-     * specified axis range if the axis range is fixed. Otherwise, this method
-     * returns null.
-     *
-     * @param axisId The identifier of an axis.
-     *
-     * @return the specified axis range from <i>settings</i> if the axis is
-     * fixed, otherwise null.
-     */
-    public Range getRangeForAxisFromSettings(String axisId) {
-        ChartSettings chartSettings = getChartSettings();
-        if (chartSettings == null) {
-            return null;
-        }
-
-        AxisSection as = chartSettings.getAxisSection(axisId);
-        Boolean  fixed = as.isFixed();
-
-        if (fixed != null && fixed) {
-            Double upper = as.getUpperRange();
-            Double lower = as.getLowerRange();
-
-            if (upper != null && lower != null) {
-                return lower < upper
-                    ? new Range(lower, upper)
-                    : new Range(upper, lower);
-            }
-        }
-
-        return null;
-    }
-
-    public LegendItem createLegendItem(Document theme, String name) {
-        // OPTIMIZE Pass font, parsed Theme items.
-        ThemeAccess themeAccess = new ThemeAccess(theme);
-        Color color = themeAccess.parseLineColorField();
-        LegendItem li = new LegendItem(name, color);
-        li.setLabelFont(createLegendLabelFont());
-        return li;
-    }
-
-
     /** Get color for hyk zones by their type (which is the name). */
     public Paint colorForHYKZone(String zoneName) {
         if (zoneName.startsWith("R")) {
@@ -950,12 +892,6 @@
     }
 
 
-    /** Override to handle subtitle adding. */
-    protected void addSubtitles(JFreeChart chart) {
-        // override this method in subclasses that need subtitles
-    }
-
-
     /**
      * This method walks over all axes (domain and range) of <i>plot</i> and
      * calls localizeDomainAxis() for domain axes or localizeRangeAxis() for
@@ -1154,152 +1090,6 @@
 
 
     /**
-     * Returns an instance of <i>ChartSettings</i> with a chart specific section
-     * but with no axes settings.
-     *
-     * @return an instance of <i>ChartSettings</i>.
-     */
-    public Settings getSettings() {
-        if (this.settings != null) {
-            return this.settings;
-        }
-
-        ChartSettings settings = new ChartSettings();
-
-        ChartSection  chartSection  = buildChartSection();
-        LegendSection legendSection = buildLegendSection();
-        ExportSection exportSection = buildExportSection();
-
-        settings.setChartSection(chartSection);
-        settings.setLegendSection(legendSection);
-        settings.setExportSection(exportSection);
-
-        List<AxisSection> axisSections = buildAxisSections();
-        for (AxisSection axisSection: axisSections) {
-            settings.addAxisSection(axisSection);
-        }
-
-        return settings;
-    }
-
-
-    /**
-     * Creates a new <i>ChartSection</i>.
-     *
-     * @return a new <i>ChartSection</i>.
-     */
-    protected ChartSection buildChartSection() {
-        ChartSection chartSection = new ChartSection();
-        chartSection.setTitle(getChartTitle());
-        chartSection.setSubtitle(getChartSubtitle());
-        chartSection.setDisplayGird(isGridVisible());
-        return chartSection;
-    }
-
-
-    /**
-     * Creates a new <i>LegendSection</i>.
-     *
-     * @return a new <i>LegendSection</i>.
-     */
-    protected LegendSection buildLegendSection() {
-        LegendSection legendSection = new LegendSection();
-        legendSection.setVisibility(isLegendVisible());
-        legendSection.setFontSize(getLegendFontSize());
-        return legendSection;
-    }
-
-
-    /**
-     * Creates a new <i>ExportSection</i> with default values <b>WIDTH=600</b>
-     * and <b>HEIGHT=400</b>.
-     *
-     * @return a new <i>ExportSection</i>.
-     */
-    protected ExportSection buildExportSection() {
-        ExportSection exportSection = new ExportSection();
-        exportSection.setWidth(600);
-        exportSection.setHeight(400);
-        return exportSection;
-    }
-
-
-    /**
-     * Creates a list of Sections that contains all axes of the chart (including
-     * X and Y axes).
-     *
-     * @return a list of Sections for each axis in this chart.
-     */
-    protected List<AxisSection> buildAxisSections() {
-        List<AxisSection> axisSections = new ArrayList<AxisSection>();
-
-        axisSections.addAll(buildXAxisSections());
-        axisSections.addAll(buildYAxisSections());
-
-        return axisSections;
-    }
-
-
-    /**
-     * Creates a new Section for chart's X axis.
-     *
-     * @return a List that contains a Section for the X axis.
-     */
-    protected List<AxisSection> buildXAxisSections() {
-        List<AxisSection> axisSections = new ArrayList<AxisSection>();
-
-        String identifier = "X";
-
-        AxisSection axisSection = new AxisSection();
-        axisSection.setIdentifier(identifier);
-        axisSection.setLabel(getXAxisLabel());
-        axisSection.setFontSize(14);
-        axisSection.setFixed(false);
-
-        // XXX We are able to find better default ranges that [0,0], but the Y
-        // axes currently have no better ranges set.
-        axisSection.setUpperRange(0d);
-        axisSection.setLowerRange(0d);
-
-        axisSections.add(axisSection);
-
-        return axisSections;
-    }
-
-
-    /**
-     * 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;
-    }
-
-
-    /**
      * Do Points out.
      */
     protected void doPoints(

http://dive4elements.wald.intevation.org