Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java @ 196:60c61f323f16
Bugfix for TIMESERIESPOINT the first and the last value weren't used in the Query which was integrated from the
Prototyp to the Project ussue54
gnv-artifacts/trunk@249 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 20 Oct 2009 10:07:22 +0000 |
parents | 92a43d90a0b8 |
children | 3d6d89bcbf42 |
line wrap: on
line source
/** * Title: ChartFactory, $Header: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v 1.8 2007/12/21 12:31:15 blume Exp $ * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v $ * created by: Stefan Blume (blume) * erstellt am: 06.12.2007 * Copyright: con terra GmbH, 2005 * * modified by: $Author: blume $ * modified on: $Date: 2007/12/21 12:31:15 $ * Version: $Revision: 1.8 $ * TAG: $Name: $ * locked from: $Locker: $ * CVS State: $State: Exp $ * Project: $ProjectName$ */ package de.intevation.gnv.chart; import java.util.Collection; import java.util.Iterator; import org.apache.log4j.Logger; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.xy.XYSeries; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.io.WKTReader; import de.intevation.gnv.chart.exception.TechnicalChartException; import de.intevation.gnv.geobackend.base.Result; import de.intevation.gnv.transition.describedata.KeyValueDescibeData; import de.intevation.gnv.utils.DistanceCalculator; /** * * @author Tim Englich <tim.englich@intevation.de> * */ public class HorizontalProfileChartFactory extends VerticalProfileChartFactory { /** * Default Logging instance */ private static Logger sLogger = Logger .getLogger(HorizontalProfileChartFactory.class); private static boolean sDebug = sLogger.isDebugEnabled(); private WKTReader wktReader = new WKTReader(); public HorizontalProfileChartFactory() { super(); super.plotOrientation = PlotOrientation.VERTICAL; } /** * * @param seriesName * @param resultSet * @param lUpperCut * @param lLowerCut * @param pStart * @param pEnd * @return * @throws TechnicalChartException */ @Override protected XYSeries createXYSeries(String seriesName, Collection<Result> resultSet, int lUpperCut, int lLowerCut, int pStart, int pEnd) throws TechnicalChartException { if (sDebug) sLogger.debug("createXYSeries()"); XYSeries series = new XYSeries(seriesName); DistanceCalculator dc = new DistanceCalculator(); try { Point lastPoint = null; double distance = 0; int i = 0; Iterator<Result> resultIterator = resultSet.iterator(); while (resultIterator.hasNext()) { Result lRow = resultIterator.next(); if (i >= pStart && i <= pEnd) { Point p = (Point)wktReader.read(lRow.getString("SHAPE")); if (lastPoint != null) { distance = distance + dc.calculateDistance(lastPoint, p); } lastPoint = p; double yValue = lRow.getDouble("YORDINATE"); series.add(distance, yValue); sLogger.debug(seriesName + " Added Value " + distance + " / " + yValue); } else if (i > pEnd) { return series; } i++; } if (distance > 0){ double scaleDistance = distance * 0.05; series.add(-scaleDistance, null); series.add(distance+scaleDistance, null); } } catch (OutOfMemoryError e) { sLogger.error(e.getMessage(), e); return series; } catch (Exception e) { // TechnicalChartException sLogger.error(e.getMessage(), e); } finally { } return series; } /** * * @see de.intevation.gnv.chart.VerticalProfileChartFactory#createSeriesName(java.util.Collection, java.util.Collection, java.util.Collection, java.lang.String, java.lang.String, java.lang.String) */ @Override protected String createSeriesName( Collection<KeyValueDescibeData> break1Candidates, Collection<KeyValueDescibeData> break2Candidates, Collection<KeyValueDescibeData> break3Candidates, String break1, String break2, String break3) { String seriesName = super.createSeriesName(break1Candidates, break2Candidates, break3Candidates, break1, break2, break3) +" " + findValueTitle(break3Candidates, break3); return seriesName.trim(); } }