Mercurial > dive4elements > river
changeset 2218:39933df6d0fe
Addes stub for ReferenceCurve*Generator
flys-artifacts/trunk@3857 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 01 Feb 2012 13:32:10 +0000 (2012-02-01) |
parents | 54422e31dc27 |
children | 4b6e9b377a84 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveInfoGenerator.java |
diffstat | 3 files changed, 212 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed Feb 01 12:24:05 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Feb 01 13:32:10 2012 +0000 @@ -1,3 +1,9 @@ +2012-02-01 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java, + src/main/java/de/intevation/flys/exports/ReferenceCurveInfoGenerator.java: + Added outline of a new chart-generator. + 2012-02-01 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/Timerange.java: New.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java Wed Feb 01 13:32:10 2012 +0000 @@ -0,0 +1,191 @@ +package de.intevation.flys.exports; + +import java.awt.Font; + +import org.w3c.dom.Document; + +import org.apache.log4j.Logger; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.Range; +import org.jfree.data.xy.XYSeries; + +import de.intevation.artifactdatabase.state.ArtifactAndFacet; + +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.WQDay; +import de.intevation.flys.artifacts.resources.Resources; + +import de.intevation.flys.jfree.FLYSAnnotation; +import de.intevation.flys.jfree.StyledXYSeries; + + +/** + * An OutGenerator that generates reference curves. + */ +public class ReferenceCurveGenerator +extends XYChartGenerator +implements FacetTypes +{ + public static enum YAXIS { + W(0); + public int idx; + private YAXIS(int c) { + idx = c; + } + } + + private static Logger logger = + Logger.getLogger(ReferenceCurveGenerator.class); + + /* + public static final String I18N_CHART_TITLE = + "chart.reference.curve.title"; + + public static final String I18N_CHART_SUBTITLE = + "chart.reference.curve.subtitle"; + + public static final String I18N_XAXIS_LABEL = + "chart.reference.curve.xaxis.label"; + + public static final String I18N_YAXIS_LABEL = + "chart.reference.curve.yaxis.label"; + + public static final String I18N_CHART_TITLE_DEFAULT = + "Bezugslinie"; + + public static final String I18N_XAXIS_LABEL_DEFAULT = + "W [NN+m]"; + + public static final String I18N_YAXIS_LABEL_DEFAULT = + "W [NN + m]"; + */ + + public ReferenceCurveGenerator() { + super(); + } + + + /** + * Create Axis for given index. + * @return axis with according internationalized label. + */ + @Override + protected NumberAxis createYAxis(int index) { + Font labelFont = new Font("Tahoma", Font.BOLD, 14); + String label = getYAxisLabel(index); + + NumberAxis axis = createNumberAxis(index, label); + if (index == YAXIS.W.idx) { + axis.setAutoRangeIncludesZero(false); + } + axis.setLabelFont(labelFont); + return axis; + } + + /** Get default chart title. */ + @Override + protected String getDefaultChartTitle() { + // TODO i18n return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); + return "Bezugslinien"; + } + + /* + // TODO i18n + @Override + protected String getDefaultChartSubtitle() { + double[] dist = getRange(); + + Object[] args = new Object[] { + getRiverName(), + dist[0] + }; + + return msg(I18N_CHART_SUBTITLE, "", args); + } + + + @Override + protected void addSubtitles(JFreeChart chart) { + String subtitle = getChartSubtitle(); + + if (subtitle != null && subtitle.length() > 0) { + chart.addSubtitle(new TextTitle(subtitle)); + } + } + */ + + + /** Get Label for X-axis (W). */ + @Override + protected String getDefaultXAxisLabel() { + // TODO i18nreturn msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); + return "W!"; + } + + + /** + * Get Label for primary and other Y Axes. + * @param index Axis-Index (0-based). + */ + @Override + protected String getDefaultYAxisLabel(int index) { + String label = "default"; + if (index == YAXIS.W.idx) { + //label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); + //TODO i18n + return "W over W over W"; + } + + return label; + } + + @Override + public void doOut( + ArtifactAndFacet artifactFacet, + Document attr, + boolean visible + ) { + String name = artifactFacet.getFacetName(); + + logger.debug("ReferenceCurveGenerator.doOut: " + name); + + if (name == null || name.length() == 0) { + logger.error("No facet given. Cannot create dataset."); + return; + } + + /* + if (name.equals(REFERENCE_W)) { + //doReference + } + */ + if (false) {} + else { + logger.warn("Unknown facet name: " + name); + return; + } + } + + + @Override + protected YAxisWalker getYAxisWalker() { + return new YAxisWalker() { + @Override + public int length() { + return YAXIS.values().length; + } + + @Override + public String getId(int idx) { + YAXIS[] yaxes = YAXIS.values(); + return yaxes[idx].toString(); + } + }; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveInfoGenerator.java Wed Feb 01 13:32:10 2012 +0000 @@ -0,0 +1,15 @@ +package de.intevation.flys.exports; + + +/** + * A ChartInfoGenerator that generates meta information for specific reference + * curves. + */ +public class ReferenceCurveInfoGenerator +extends ChartInfoGenerator +{ + public ReferenceCurveInfoGenerator() { + super(new ReferenceCurveGenerator()); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :