Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java @ 116:820238357bab
Added Horizontal-Profile-Support for Meshes.
Modify the Workflow for Horizontal-Profile-InstantaneousPoint
gnv-artifacts/trunk@169 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 02 Oct 2009 08:07:00 +0000 |
parents | a16f5267803e |
children | 7fb9441dd8af |
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 de.intevation.gnv.chart.exception.TechnicalChartException; import de.intevation.gnv.geobackend.base.Result; /** * * @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(); 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); try { double xValue=0; double yValue=0; double xStartCoord = 0; double yStartCoord = 0; int i = 0; Iterator<Result> resultIterator = resultSet.iterator(); while (resultIterator.hasNext()){ Result lRow = resultIterator.next(); if (i >= pStart && i <= pEnd ){ if (xStartCoord == 0 && yStartCoord == 0){ xStartCoord = lRow.getDouble("XORDINATE_XCOORD"); yStartCoord = lRow.getDouble("XORDINATE_YCOORD"); } double currentXCoord = lRow.getDouble("XORDINATE_XCOORD");; double currentYCoord = lRow.getDouble("XORDINATE_YCOORD"); xValue = this.calculateDistance(xStartCoord, yStartCoord, currentXCoord, currentYCoord); yValue = lRow.getDouble("YORDINATE"); series.add(xValue, yValue); sLogger.debug(seriesName+" Added Value "+xValue+" / "+yValue); }else if (i > pEnd){ return series; } i++; } } catch (OutOfMemoryError e) { sLogger.error(e.getMessage(), e); return series; } catch (Exception e) { //TechnicalChartException sLogger.error(e.getMessage(), e); } finally { } return series; } private double calculateDistance(double xStartCoord, double yStartCoord, double currentXCoord, double currentYCoord){ double dx = xStartCoord - currentXCoord; double dy = yStartCoord - currentYCoord; return Math.sqrt((dx*dx)+(dy*dy)); } }