comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java @ 113:a16f5267803e

Added Basic-Support for HorizontalProfiles gnv-artifacts/trunk@163 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 30 Sep 2009 13:42:51 +0000
parents
children 820238357bab
comparison
equal deleted inserted replaced
112:b8dbf39ca935 113:a16f5267803e
1 /**
2 * 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 $
3 * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v $
4 * created by: Stefan Blume (blume)
5 * erstellt am: 06.12.2007
6 * Copyright: con terra GmbH, 2005
7 *
8 * modified by: $Author: blume $
9 * modified on: $Date: 2007/12/21 12:31:15 $
10 * Version: $Revision: 1.8 $
11 * TAG: $Name: $
12 * locked from: $Locker: $
13 * CVS State: $State: Exp $
14 * Project: $ProjectName$
15 */
16 package de.intevation.gnv.chart;
17
18 import java.util.Collection;
19 import java.util.Iterator;
20
21 import org.apache.log4j.Logger;
22 import org.jfree.chart.plot.PlotOrientation;
23 import org.jfree.data.xy.XYSeries;
24
25 import de.intevation.gnv.chart.exception.TechnicalChartException;
26 import de.intevation.gnv.geobackend.base.Result;
27
28 /**
29 *
30 * @author Tim Englich <tim.englich@intevation.de>
31 *
32 */
33 public class HorizontalProfileChartFactory extends VerticalProfileChartFactory {
34
35 /**
36 * Default Logging instance
37 */
38 private static Logger sLogger = Logger.getLogger(HorizontalProfileChartFactory.class);
39 private static boolean sDebug = sLogger.isDebugEnabled();
40
41
42 public HorizontalProfileChartFactory(){
43 super();
44 super.plotOrientation = PlotOrientation.HORIZONTAL;
45 }
46
47
48 /**
49 *
50 * @param seriesName
51 * @param resultSet
52 * @param lUpperCut
53 * @param lLowerCut
54 * @param pStart
55 * @param pEnd
56 * @return
57 * @throws TechnicalChartException
58 */
59 @Override
60 protected XYSeries createXYSeries(String seriesName, Collection<Result> resultSet,
61 int lUpperCut, int lLowerCut,int pStart,int pEnd) throws TechnicalChartException{
62 if (sDebug)
63 sLogger.debug("createXYSeries()");
64 XYSeries series = new XYSeries(seriesName);
65 try {
66 double xValue=0;
67 double yValue=0;
68 double xStartCoord = 0;
69 double yStartCoord = 0;
70 int i = 0;
71 Iterator<Result> resultIterator = resultSet.iterator();
72 while (resultIterator.hasNext()){
73 Result lRow = resultIterator.next();
74 if (i >= pStart && i <= pEnd ){
75 if (xStartCoord == 0 && yStartCoord == 0){
76 xStartCoord = lRow.getDouble("XORDINATE_XCOORD");
77 yStartCoord = lRow.getDouble("XORDINATE_YCOORD");
78 }
79
80 double currentXCoord = lRow.getDouble("XORDINATE_XCOORD");;
81 double currentYCoord = lRow.getDouble("XORDINATE_YCOORD");
82
83 xValue = this.calculateDistance(xStartCoord, yStartCoord, currentXCoord, currentYCoord);
84
85 yValue = lRow.getDouble("YORDINATE");
86 series.add(xValue, yValue);
87 sLogger.debug(seriesName+" Added Value "+xValue+" / "+yValue);
88
89 }else if (i > pEnd){
90 return series;
91 }
92 i++;
93 }
94 } catch (OutOfMemoryError e) {
95 sLogger.error(e.getMessage(), e);
96 return series;
97
98 } catch (Exception e) { //TechnicalChartException
99 sLogger.error(e.getMessage(), e);
100 }
101 finally {
102 }
103
104 return series;
105 }
106
107 private double calculateDistance(double xStartCoord, double yStartCoord, double currentXCoord, double currentYCoord){
108 double dx = xStartCoord - currentXCoord;
109 double dy = yStartCoord - currentYCoord;
110 return Math.sqrt((dx*dx)+(dy*dy));
111 }
112 }

http://dive4elements.wald.intevation.org