Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDerivedCurveGenerator.java @ 7691:fa4fbd66e752
(issue1579) Fix axes syncronisation at Gauges
The SyncNumberAxis was completely broken. It only synced
in one direction and even that did not work correctly when
data was added to the axis (and the syncAxis rescaled but
forgot the old axis) then there were lots of ways to bypass
that scaling. And i also think the trans calculation was wrong.
It has been replaced by a "mostly" simple method to just keep
the W in M and W in CM+Datum axes in sync. I say "Mostly" because
it had to deal with the Bounds interface.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 13 Dec 2013 19:03:00 +0100 |
parents | 1b35b2ddfc28 |
children | e4606eae8ea5 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.exports.fixings; import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.fixings.FixDerivateFacet; import org.dive4elements.river.artifacts.model.fixings.FixFunction; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.ChartGenerator; import org.dive4elements.river.jfree.JFreeUtil; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; /** * Generator for fixation derived function curve. * * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a> */ public class FixDerivedCurveGenerator extends FixChartGenerator implements FacetTypes { /** Private logger. */ private static Logger logger = Logger.getLogger(FixDerivedCurveGenerator.class); public static final String I18N_CHART_TITLE = "chart.fixings.derivedcurve.title"; public static final String I18N_CHART_SUBTITLE = "chart.fixings.derivedcurve.subtitle"; public static final String I18N_XAXIS_LABEL = "chart.fixings.derivedcurve.xaxis.label"; public static final String I18N_YAXIS_LABEL = "chart.fixings.derivedcurve.yaxis.label"; public static final String I18N_CHART_TITLE_DEFAULT = "Ableitungskurve"; public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00B3/s]"; public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; public static enum YAXIS { W(0), Q(1); public int idx; private YAXIS(int c) { idx = c; } } @Override public void doOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) { logger.debug("doOut"); if (FacetTypes.IS.MANUALPOINTS(aaf.getFacetName())) { doPoints(aaf.getData(context), aaf, doc, visible, YAXIS.W.idx); } else { FixDerivateFacet facet = (FixDerivateFacet)aaf.getFacet(); FixFunction func = (FixFunction)facet.getData( aaf.getArtifact(), context); if (func == null) { logger.warn("doOut: Facet does not contain FixFunction"); return; } double maxQ = func.getMaxQ(); if (maxQ > 0) { StyledXYSeries series = JFreeUtil.sampleFunction2D( func.getFunction(), doc, aaf.getFacetDescription(), 500, // number of samples 0.0 , // start maxQ); // end addAxisSeries(series, 0, visible); } } } @Override protected String getDefaultChartTitle() { return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); } @Override protected String getChartTitle() { return Resources.format( context.getMeta(), I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, context.getContextValue(CURRENT_KM)); } @Override protected String getDefaultXAxisLabel() { return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); } @Override protected String getDefaultYAxisLabel(int pos) { return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); } @Override protected ChartGenerator.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 :