Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixATExport.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 au.com.bytecode.opencsv.CSVWriter; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.FixAccess; import org.dive4elements.river.themes.ThemeDocument; import org.dive4elements.river.utils.RiverUtils; import org.dive4elements.river.artifacts.math.fitting.Function; import org.dive4elements.river.artifacts.math.fitting.FunctionFactory; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.Parameters; import org.dive4elements.river.artifacts.model.fixings.FixResult; import org.dive4elements.river.exports.AbstractExporter; import org.dive4elements.river.model.River; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import org.apache.log4j.Logger; import org.w3c.dom.NodeList; /** Export result of fixation analysis. */ public class FixATExport extends AbstractExporter { /** Private logger. */ private static Logger logger = Logger.getLogger(FixATExport.class); protected Function function; protected Parameters parameters; @Override public void doOut(ArtifactAndFacet bundle, ThemeDocument attr, boolean visible) { logger.debug("AT Export doOut()."); Object data = bundle.getData(context); if (data instanceof CalculationResult) { CalculationResult cr = (CalculationResult)data; Object resData = cr.getData(); if (resData instanceof FixResult) { this.parameters = ((FixResult)resData).getParameters(); } } else { logger.debug("No CalculationResult found for AT export."); return; } FixAccess access = new FixAccess((D4EArtifact)this.master); String f = access.getFunction(); if (f == null || f.length() == 0) { logger.debug("No function found for AT export."); return; } this.function = FunctionFactory.getInstance().getFunction(f); } @Override public void generate() throws IOException { if (this.function == null || this.parameters == null) { logger.debug("No function or paramters for AT export."); return; } Writer writer = new OutputStreamWriter(out, DEFAULT_CSV_CHARSET); FixATWriter atWriter = new FixATWriter(this.function, this.parameters); NodeList nodes = request.getElementsByTagName("km"); String km = nodes.item(0).getTextContent(); double dkm = Double.parseDouble(km); River river = RiverUtils.getRiver((D4EArtifact)master); atWriter.write(writer, context.getMeta(), river, dkm); writer.close(); } @Override protected void writeCSVData(CSVWriter writer) throws IOException { // The concrete writer is used to write csv data. } @Override protected void writePDF(OutputStream out) { // Implement me! } @Override protected void addData(Object data) { // Nothing to do here. } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :