Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java @ 171:7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 09 Oct 2009 07:54:48 +0000 |
parents | 820238357bab |
children | bff7bbb7c6f0 |
comparison
equal
deleted
inserted
replaced
170:7be22e76c270 | 171:7fb9441dd8af |
---|---|
26 import de.intevation.gnv.geobackend.base.Result; | 26 import de.intevation.gnv.geobackend.base.Result; |
27 | 27 |
28 /** | 28 /** |
29 * | 29 * |
30 * @author Tim Englich <tim.englich@intevation.de> | 30 * @author Tim Englich <tim.englich@intevation.de> |
31 * | 31 * |
32 */ | 32 */ |
33 public class HorizontalProfileChartFactory extends VerticalProfileChartFactory { | 33 public class HorizontalProfileChartFactory extends VerticalProfileChartFactory { |
34 | 34 |
35 /** | 35 /** |
36 * Default Logging instance | 36 * Default Logging instance |
37 */ | 37 */ |
38 private static Logger sLogger = Logger.getLogger(HorizontalProfileChartFactory.class); | 38 private static Logger sLogger = Logger |
39 private static boolean sDebug = sLogger.isDebugEnabled(); | 39 .getLogger(HorizontalProfileChartFactory.class); |
40 | 40 private static boolean sDebug = sLogger.isDebugEnabled(); |
41 | 41 |
42 public HorizontalProfileChartFactory(){ | 42 public HorizontalProfileChartFactory() { |
43 super(); | 43 super(); |
44 super.plotOrientation = PlotOrientation.VERTICAL; | 44 super.plotOrientation = PlotOrientation.VERTICAL; |
45 } | 45 } |
46 | 46 |
47 | 47 /** |
48 /** | 48 * |
49 * | 49 * @param seriesName |
50 * @param seriesName | 50 * @param resultSet |
51 * @param resultSet | 51 * @param lUpperCut |
52 * @param lUpperCut | 52 * @param lLowerCut |
53 * @param lLowerCut | 53 * @param pStart |
54 * @param pStart | 54 * @param pEnd |
55 * @param pEnd | 55 * @return |
56 * @return | 56 * @throws TechnicalChartException |
57 * @throws TechnicalChartException | 57 */ |
58 */ | 58 @Override |
59 @Override | 59 protected XYSeries createXYSeries(String seriesName, |
60 protected XYSeries createXYSeries(String seriesName, Collection<Result> resultSet, | 60 Collection<Result> resultSet, |
61 int lUpperCut, int lLowerCut,int pStart,int pEnd) throws TechnicalChartException{ | 61 int lUpperCut, int lLowerCut, int pStart, |
62 if (sDebug) | 62 int pEnd) throws TechnicalChartException { |
63 sLogger.debug("createXYSeries()"); | 63 if (sDebug) |
64 XYSeries series = new XYSeries(seriesName); | 64 sLogger.debug("createXYSeries()"); |
65 try { | 65 XYSeries series = new XYSeries(seriesName); |
66 double xValue=0; | 66 try { |
67 double yValue=0; | 67 double xValue = 0; |
68 double xStartCoord = 0; | 68 double yValue = 0; |
69 double yStartCoord = 0; | 69 double xStartCoord = 0; |
70 int i = 0; | 70 double yStartCoord = 0; |
71 Iterator<Result> resultIterator = resultSet.iterator(); | 71 int i = 0; |
72 while (resultIterator.hasNext()){ | 72 Iterator<Result> resultIterator = resultSet.iterator(); |
73 while (resultIterator.hasNext()) { | |
73 Result lRow = resultIterator.next(); | 74 Result lRow = resultIterator.next(); |
74 if (i >= pStart && i <= pEnd ){ | 75 if (i >= pStart && i <= pEnd) { |
75 if (xStartCoord == 0 && yStartCoord == 0){ | 76 if (xStartCoord == 0 && yStartCoord == 0) { |
76 xStartCoord = lRow.getDouble("XORDINATE_XCOORD"); | 77 xStartCoord = lRow.getDouble("XORDINATE_XCOORD"); |
77 yStartCoord = lRow.getDouble("XORDINATE_YCOORD"); | 78 yStartCoord = lRow.getDouble("XORDINATE_YCOORD"); |
78 } | 79 } |
79 | 80 |
80 double currentXCoord = lRow.getDouble("XORDINATE_XCOORD");; | 81 double currentXCoord = lRow.getDouble("XORDINATE_XCOORD"); |
82 ; | |
81 double currentYCoord = lRow.getDouble("XORDINATE_YCOORD"); | 83 double currentYCoord = lRow.getDouble("XORDINATE_YCOORD"); |
82 | 84 |
83 xValue = this.calculateDistance(xStartCoord, yStartCoord, currentXCoord, currentYCoord); | 85 xValue = this.calculateDistance(xStartCoord, yStartCoord, |
84 | 86 currentXCoord, currentYCoord); |
85 yValue = lRow.getDouble("YORDINATE"); | 87 |
86 series.add(xValue, yValue); | 88 yValue = lRow.getDouble("YORDINATE"); |
87 sLogger.debug(seriesName+" Added Value "+xValue+" / "+yValue); | 89 series.add(xValue, yValue); |
88 | 90 sLogger.debug(seriesName + " Added Value " + xValue + " / " |
89 }else if (i > pEnd){ | 91 + yValue); |
92 | |
93 } else if (i > pEnd) { | |
90 return series; | 94 return series; |
91 } | 95 } |
92 i++; | 96 i++; |
93 } | 97 } |
94 } catch (OutOfMemoryError e) { | 98 } catch (OutOfMemoryError e) { |
95 sLogger.error(e.getMessage(), e); | 99 sLogger.error(e.getMessage(), e); |
96 return series; | 100 return series; |
97 | 101 |
98 } catch (Exception e) { //TechnicalChartException | 102 } catch (Exception e) { // TechnicalChartException |
99 sLogger.error(e.getMessage(), e); | 103 sLogger.error(e.getMessage(), e); |
100 } | 104 } finally { |
101 finally { | 105 } |
102 } | 106 |
103 | 107 return series; |
104 return series; | 108 } |
105 } | 109 |
106 | 110 private double calculateDistance(double xStartCoord, double yStartCoord, |
107 private double calculateDistance(double xStartCoord, double yStartCoord, double currentXCoord, double currentYCoord){ | 111 double currentXCoord, double currentYCoord) { |
108 double dx = xStartCoord - currentXCoord; | 112 double dx = xStartCoord - currentXCoord; |
109 double dy = yStartCoord - currentYCoord; | 113 double dy = yStartCoord - currentYCoord; |
110 return Math.sqrt((dx*dx)+(dy*dy)); | 114 return Math.sqrt((dx * dx) + (dy * dy)); |
111 } | 115 } |
112 } | 116 } |