Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/charts/CrossSectionApp.java @ 1123:be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
flys-artifacts/trunk@2632 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 01 Sep 2011 12:23:23 +0000 |
parents | 111794adf285 |
children | a7def20539fb |
rev | line source |
---|---|
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.charts; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.math.MathContext; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.awt.Dimension; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.awt.BorderLayout; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.awt.FlowLayout; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import javax.swing.JPanel; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import javax.swing.JButton; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import javax.swing.JComboBox; |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
12 import javax.swing.JTextField; |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import javax.swing.DefaultComboBoxModel; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import java.awt.event.ItemListener; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import java.awt.event.ItemEvent; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import java.awt.event.ActionListener; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import java.awt.event.ActionEvent; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
20 import java.awt.geom.Point2D; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
21 import java.awt.geom.Line2D; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
22 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 import java.util.ArrayList; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 import java.util.List; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 import java.util.Comparator; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 import java.util.Collections; |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
27 import java.util.Iterator; |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 import java.io.File; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 import java.io.IOException; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 import java.io.FileWriter; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 import java.io.PrintWriter; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 import org.jfree.ui.ApplicationFrame; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 import org.jfree.ui.RefineryUtilities; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 import org.jfree.chart.ChartFactory; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 import org.jfree.chart.plot.PlotOrientation; |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
40 import org.jfree.chart.plot.XYPlot; |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 import org.jfree.chart.ChartUtilities; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 import org.jfree.chart.JFreeChart; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 import org.jfree.chart.ChartPanel; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
46 import org.jfree.chart.axis.NumberAxis; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
47 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 import org.jfree.data.xy.XYDataset; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 import org.jfree.data.xy.DefaultXYDataset; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 import de.intevation.flys.model.CrossSection; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 import de.intevation.flys.model.CrossSectionLine; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 import de.intevation.flys.model.CrossSectionPoint; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
55 import de.intevation.flys.geom.Lines; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
56 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 import de.intevation.flys.backend.SessionFactoryProvider; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 import org.hibernate.Session; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 import org.hibernate.Query; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
62 import gnu.trove.TDoubleArrayList; |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 public class CrossSectionApp |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 extends ApplicationFrame |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 { |
1122
111794adf285
Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
938
diff
changeset
|
67 public static final String RIVER = System.getProperty("river", "Saar"); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 public static final double EPSILON = 1e-4; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 public static final double TOO_SMALL = 0.2; |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
72 public static final double TOO_BIG = 500; |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 public static final Comparator<CrossSectionPoint> COL_POS_CMP = |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 new Comparator<CrossSectionPoint>() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 @Override |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 public int compare(CrossSectionPoint a, CrossSectionPoint b) { |
1122
111794adf285
Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
938
diff
changeset
|
78 // TODO evaluate: isnt it enough to |
111794adf285
Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
938
diff
changeset
|
79 // return (|d| > |EPS|) ? d : diff |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 double xa = a.getX().doubleValue(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 double xb = b.getX().doubleValue(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 double d = xa - xb; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 if (d < -EPSILON) return -1; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 if (d > +EPSILON) return +1; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 int diff = a.getColPos() - b.getColPos(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 return diff < 0 ? -1 : diff > 0 ? +1 : 0; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 }; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 public static final boolean isValid(double x) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 x = Math.abs(x); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 return x > TOO_SMALL && x < TOO_BIG; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 protected Session session; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 protected JComboBox crossSectionsCB; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 protected JComboBox crossSectionLinesCB; |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
99 protected JTextField waterlevelTF; |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 protected ChartPanel chartPanel; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
103 protected Double lastWaterLevel; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
104 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 public static class CrossSectionItem { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 CrossSection crossSection; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 public CrossSectionItem(CrossSection crossSection) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 this.crossSection = crossSection; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 public String toString() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 return crossSection.getDescription(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 } // CrossSectionItem |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 public static class CrossSectionLineItem { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 CrossSectionLine line; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 public CrossSectionLineItem(CrossSectionLine line) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 this.line = line; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 public String toString() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 double v = line.getKm().doubleValue(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 return String.valueOf(Math.round(v * 1000.0)/1000d); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 } // CrossSectionLineItem |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 public CrossSectionApp(String title) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 super(title); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 session = SessionFactoryProvider |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 .createSessionFactory() |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 .openSession(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 JPanel content = createContent(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 content.setPreferredSize(new Dimension(640, 480)); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 setContentPane(content); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 public List<CrossSection> crossSections(String river) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 Query query = session.createQuery( |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 "from CrossSection where river.name = :river"); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 query.setParameter("river", river); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 return query.list(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 public JPanel createContent() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 JPanel panel = new JPanel(new BorderLayout()); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 JPanel nav = new JPanel(new FlowLayout()); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 Object [] csis = createCrossSectionItems(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 crossSectionsCB = new JComboBox(csis); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 DefaultComboBoxModel dcbm; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 if (csis.length > 0) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 Object [] cslis = |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 createCrossSectionLineItems( |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 ((CrossSectionItem)csis[0]).crossSection); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 dcbm = new DefaultComboBoxModel(cslis); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 if (cslis.length > 0) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 dcbm.setSelectedItem(cslis[0]); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 else { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 dcbm = new DefaultComboBoxModel(new Object[0]); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 crossSectionLinesCB = new JComboBox(dcbm); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 nav.add(crossSectionsCB); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 nav.add(crossSectionLinesCB); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 crossSectionsCB.addItemListener(new ItemListener() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 public void itemStateChanged(ItemEvent ie) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 if (ie.getStateChange() == ItemEvent.SELECTED) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 updateCrossSection( |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 ((CrossSectionItem)ie.getItem()).crossSection); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 }); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 crossSectionLinesCB.addItemListener(new ItemListener() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 public void itemStateChanged(ItemEvent ie) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 if (ie.getStateChange() == ItemEvent.SELECTED) { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
194 updateChart(); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 }); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
200 waterlevelTF = new JTextField(5); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
202 waterlevelTF.addActionListener(new ActionListener() { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
203 public void actionPerformed(ActionEvent ae) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
204 waterLevelChanged(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
205 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
206 }); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
207 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
208 nav.add(waterlevelTF); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
209 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 JButton dump = new JButton("dump"); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 dump.addActionListener(new ActionListener() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 public void actionPerformed(ActionEvent ae) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 dumpData(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 }); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
217 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
218 nav.add(dump); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
220 panel.add(nav, BorderLayout.SOUTH); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
221 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
222 chartPanel = createChartPanel(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
223 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
224 panel.add(chartPanel, BorderLayout.CENTER); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
225 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
226 return panel; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
229 protected void waterLevelChanged() { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
230 String value = waterlevelTF.getText(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
231 try { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
232 lastWaterLevel = Double.parseDouble(value); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
233 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
234 catch (NumberFormatException nfe) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
235 waterlevelTF.setText( |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
236 lastWaterLevel != null ? lastWaterLevel.toString() : ""); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
237 return; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
238 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
239 updateChart(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
240 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
241 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
242 protected void updateChart() { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
243 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
244 CrossSectionLineItem csli = |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
245 (CrossSectionLineItem)crossSectionLinesCB.getSelectedItem(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
246 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
247 JFreeChart chart = createChart(csli == null |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
248 ? new DefaultXYDataset() |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
249 : generateDataset(csli.line, lastWaterLevel)); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
250 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
251 chartPanel.setChart(chart); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
252 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
253 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 protected ChartPanel createChartPanel() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 CrossSectionLineItem csli = |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 (CrossSectionLineItem)crossSectionLinesCB.getSelectedItem(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
258 JFreeChart chart = createChart(csli == null |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
259 ? new DefaultXYDataset() |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
260 : generateDataset(csli.line, lastWaterLevel)); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 return new ChartPanel(chart); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
264 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
265 protected void dumpData() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
266 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
267 CrossSectionLineItem csli = |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
268 (CrossSectionLineItem)crossSectionLinesCB.getSelectedItem(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
269 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
270 if (csli == null) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
271 return; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
272 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
273 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
274 CrossSectionLine line = csli.line; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
275 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
276 double km = Math.round(line.getKm().doubleValue() * 1000d)/1000d; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
277 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
278 String kmS = String.valueOf(km).replace(".", "-"); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
279 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
280 int i = 1; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
281 File file = new File("cross-section-" + kmS + ".txt"); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
282 while (file.exists()) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
283 file = new File("cross-section-" + kmS + "[" + (i++) + "].txt"); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
284 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
285 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
286 System.err.println("dump points to file '" + file + "'"); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
287 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
288 List<CrossSectionPoint> points = line.getPoints(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
289 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
290 PrintWriter out = null; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
291 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
292 MathContext mc = new MathContext(3); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
293 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
294 try { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
295 out = |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
296 new PrintWriter( |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
297 new FileWriter(file)); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
298 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
299 for (CrossSectionPoint point: points) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
300 out.println( |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
301 point.getX().round(mc) + " " + |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
302 point.getY().round(mc)); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
303 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
304 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
305 out.flush(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
306 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
307 catch (IOException ioe) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
308 ioe.printStackTrace(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
309 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
310 finally { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
311 if (out != null) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
312 out.close(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
313 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
314 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
315 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
316 |
1122
111794adf285
Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
938
diff
changeset
|
317 public static XYDataset generateDataset( |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
318 CrossSectionLine line, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
319 Double waterlevel |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
320 ) { |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
321 DefaultXYDataset dataset = new DefaultXYDataset(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
322 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
323 List<CrossSectionPoint> ps = line.getPoints(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
324 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
325 if (ps.isEmpty()) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
326 return dataset; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
327 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
328 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
329 Collections.sort(ps, COL_POS_CMP); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
330 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
331 List<Point2D> points = new ArrayList<Point2D>(ps.size()); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
332 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
333 for (CrossSectionPoint p: ps) { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
334 double x = p.getX().doubleValue(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
335 double y = p.getY().doubleValue(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
336 if (isValid(x) && isValid(y)) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
337 points.add(new Point2D.Double(x, y)); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
338 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
339 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
340 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
341 if (points.isEmpty()) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
342 return dataset; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
343 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
344 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
345 double [] xs = new double[points.size()]; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
346 double [] ys = new double[xs.length]; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
347 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
348 xs[0] = points.get(0).getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
349 ys[0] = points.get(0).getY(); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
350 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
351 for (int i = 1; i < xs.length; ++i) { |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
352 Point2D p = points.get(i); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
353 double x = p.getX(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
354 double y = p.getY(); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
355 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
356 if (x <= xs[i-1]) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
357 x = xs[i-1] + EPSILON; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
358 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
359 xs[i] = x; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
360 ys[i] = y; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
361 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
362 |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
363 if (waterlevel != null) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
364 double [][] data = createWaterLines(points, waterlevel); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
365 dataset.addSeries(String.valueOf(waterlevel), data); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
366 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
367 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
368 CrossSection cs = line.getCrossSection(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
369 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
370 String legend = (cs != null ? cs.getDescription() : "???") |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
371 + " " + Math.round(line.getKm().doubleValue() * 1000d)/1000d; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
372 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
373 dataset.addSeries(legend, new double [][] { xs, ys }); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
374 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
375 return dataset; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
376 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
377 |
1122
111794adf285
Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
938
diff
changeset
|
378 public static double [][] createWaterLines( |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
379 List<Point2D> points, |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
380 double waterlevel |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
381 ) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
382 List<Line2D> lines = Lines.fillWater(points, waterlevel); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
383 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
384 TDoubleArrayList lxs = new TDoubleArrayList(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
385 TDoubleArrayList lys = new TDoubleArrayList(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
386 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
387 for (Iterator<Line2D> iter = lines.iterator(); iter.hasNext();) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
388 Line2D l = iter.next(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
389 Point2D p1 = l.getP1(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
390 Point2D p2 = l.getP2(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
391 lxs.add(p1.getX()); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
392 lys.add(p1.getY()); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
393 lxs.add(p2.getX()); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
394 lys.add(p2.getY()); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
395 if (iter.hasNext()) { |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
396 lxs.add(Double.NaN); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
397 lys.add(Double.NaN); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
398 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
399 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
400 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
401 return new double [][] { lxs.toNativeArray(), lys.toNativeArray() }; |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
402 } |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
403 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
404 protected void updateCrossSection(CrossSection crossSection) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
405 Object [] cslis = createCrossSectionLineItems(crossSection); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
406 DefaultComboBoxModel dcbm = new DefaultComboBoxModel(cslis); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
407 if (cslis.length > 0) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
408 dcbm.setSelectedItem(cslis[0]); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
409 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
410 crossSectionLinesCB.setModel(dcbm); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
411 if (cslis.length > 0) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
412 CrossSectionLine line = |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
413 ((CrossSectionLineItem)cslis[0]).line; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
414 } |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
415 updateChart(); |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
416 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
417 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
418 protected Object [] createCrossSectionLineItems(CrossSection cs) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
419 List<CrossSectionLine> lines = cs.getLines(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
420 Object [] result = new Object[lines.size()]; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
421 for (int i = 0; i < result.length; ++i) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
422 result[i] = new CrossSectionLineItem(lines.get(i)); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
423 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
424 return result; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
425 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
426 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
427 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
428 protected Object [] createCrossSectionItems() { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
429 List<CrossSection> crossSections = crossSections(RIVER); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
430 Object [] result = new Object[crossSections.size()]; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
431 for (int i = 0; i < result.length; ++i) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
432 result[i] = new CrossSectionItem(crossSections.get(i)); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
433 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
434 return result; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
435 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
436 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
437 public static JFreeChart createChart(XYDataset dataset) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
438 JFreeChart chart = ChartFactory.createXYLineChart( |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
439 null, |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
440 "Abstand [m]", |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
441 "H\u00f6he [m]", |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
442 dataset, |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
443 PlotOrientation.VERTICAL, |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
444 true, |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
445 true, |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
446 false); |
938
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
447 |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
448 XYPlot plot = chart.getXYPlot(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
449 NumberAxis yAxis = (NumberAxis)plot.getRangeAxis(); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
450 yAxis.setAutoRangeIncludesZero(false); |
bd3683453928
Debugged the water fill algorithm.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
936
diff
changeset
|
451 |
936
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
452 ChartUtilities.applyCurrentTheme(chart); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
453 return chart; |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
454 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
455 |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
456 public static void main(String [] args) { |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
457 CrossSectionApp csa = new CrossSectionApp("Querprofile"); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
458 csa.pack(); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
459 RefineryUtilities.centerFrameOnScreen(csa); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
460 csa.setVisible(true); |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
461 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
462 } |
759808931a2e
Add Swing standalone app to test/develope cross sections directly from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
463 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |