Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthChartExtender.java @ 9602:6b2496d71936
Reimplemented baseline for tkh. Extended area-dataset to be able to draw baseline.
author | gernotbelger |
---|---|
date | Tue, 12 Feb 2019 14:08:16 +0100 |
parents | 8596f95673b1 |
children |
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * 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.artifacts.sinfo.flowdepth; import org.dive4elements.river.exports.ChartExtender; import org.dive4elements.river.exports.DiagramGenerator; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; /** * @author Gernot Belger */ public class FlowDepthChartExtender implements ChartExtender { private static final String TKH_AXIS = "tkhAxis"; private static final String FLOWDEPTH_AXIS = "flowdepthAxis"; @Override public void beforeAutoZoom(final DiagramGenerator generator) { final ValueAxis tkhAxis = generator.getAxis(TKH_AXIS); if (tkhAxis != null) { /* If tkh is not the only dataset, we push it to the bottom */ final int numYAxes = generator.getNumYAxes(); if (numYAxes > 1) tkhAxis.setUpperMargin(4.0); } } /** * Synchronizes the location of '0' on the flow-depth-axis with the tkh-axis, by extending the lower bound of the * flow-depth-axis. */ @Override public void afterAutoZoom(final DiagramGenerator generator) { final ValueAxis axis1 = generator.getAxis(FLOWDEPTH_AXIS); final ValueAxis axis2 = generator.getAxis(TKH_AXIS); if (axis1 == null || axis2 == null) return; final double axis2lb = axis2.getLowerBound(); final double axis1ub = axis1.getUpperBound(); final double axis2ub = axis2.getUpperBound(); final double ratio = axis2lb / (axis2ub - axis2lb); final double axis1lbNew = axis1ub / (1 / ratio + 1); axis1.setLowerBound(axis1lbNew); } @Override public void afterGenerateChart(final DiagramGenerator generator, final XYPlot plot) { /* nothing to do */ } }