Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/charts/CrossSectionApp.java @ 1884:4ae9c92feb8c
StableXYDifferenceRenderer: Make rendering work with definition holes.
flys-artifacts/trunk@3243 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 13 Nov 2011 14:02:35 +0000 |
parents | eb671699fbc2 |
children | e384d78ff78b |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/charts/CrossSectionApp.java Sat Nov 12 22:26:27 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/charts/CrossSectionApp.java Sun Nov 13 14:02:35 2011 +0000 @@ -83,7 +83,11 @@ { public static final String RIVER = System.getProperty("river", "Saar"); - public static final double EPSILON = 1e-4; + public static final String WATER_LEVEL = System.getProperty("waterlevel"); + + public static final String KM = System.getProperty("km"); + + public static final double EPSILON = 1e-4; protected Session session; @@ -171,9 +175,9 @@ public Class<?> getColumnClass(int columnIndex) { switch (columnIndex) { case 0: return String.class; - case 1: return Boolean.class; - case 2: return Boolean.class; - case 3: return Boolean.class; + case 1: + case 2: + case 3: case 4: return Boolean.class; } return null; @@ -238,16 +242,16 @@ return query.list(); } - protected Map<Double, List<Pair<CrossSection, CrossSectionLine>>> loadAllLines( - List<CrossSection> crossSections - ) { + protected Map<Double, List<Pair<CrossSection, CrossSectionLine>>> + loadAllLines(List<CrossSection> crossSections) { Map<Double, List<Pair<CrossSection, CrossSectionLine>>> km2lines = new TreeMap<Double, List<Pair<CrossSection, CrossSectionLine>>>(); for (CrossSection cs: crossSections) { List<CrossSectionLine> lines = cs.getLines(); for (CrossSectionLine csl: lines) { Double km = Math.round(csl.getKm().doubleValue() * 1000d)/1000d; - List<Pair<CrossSection, CrossSectionLine>> ls = km2lines.get(km); + List<Pair<CrossSection, CrossSectionLine>> ls + = km2lines.get(km); if (ls == null) { ls = new ArrayList<Pair<CrossSection, CrossSectionLine>>(2); km2lines.put(km, ls); @@ -279,6 +283,30 @@ crossSectionLinesCB = new JComboBox(dcbm); + if (KM != null) { + try { + double km = Double.parseDouble(KM); + + CrossSectionLineItem found = null; + + for (Object o: clis) { + CrossSectionLineItem csli = (CrossSectionLineItem)o; + if (Math.abs(csli.km - km) < EPSILON) { + found = csli; + break; + } + } + + if (found != null) { + crossSectionLinesCB.setSelectedItem(found); + } + } + catch (NumberFormatException nfe) { + System.err.println("km is not a number: " + + nfe.getMessage()); + } + } + nav.add(crossSectionLinesCB); crossSectionLinesCB.addItemListener(new ItemListener() { @@ -292,6 +320,17 @@ waterlevelTF = new JTextField(5); + if (WATER_LEVEL != null) { + try { + waterlevelTF.setText( + (lastWaterLevel = Double.valueOf(WATER_LEVEL)).toString()); + } + catch (NumberFormatException nfe) { + System.err.println("Water level not a number: " + + nfe.getMessage()); + } + } + waterlevelTF.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { @@ -343,7 +382,7 @@ protected void waterLevelChanged() { String value = waterlevelTF.getText(); try { - lastWaterLevel = Double.parseDouble(value); + lastWaterLevel = Double.valueOf(value); } catch (NumberFormatException nfe) { waterlevelTF.setText( @@ -528,6 +567,21 @@ List<Point2D> points = null; CrossSection cs = crossSections.get(i); + if (drawGround[i]) { + for (Pair<CrossSection, CrossSectionLine> csl: csli.lines) { + if (csl.getA() == cs) { + if (points == null) { + points = csl.getB().fetchCrossSectionLinesPoints(); + } + generateGround( + points, + cs.getDescription() + "/Boden", + datasets); + break; + } + } + } + if (drawFill[i]) { for (Pair<CrossSection, CrossSectionLine> csl: csli.lines) { if (csl.getA() == cs) { @@ -568,20 +622,6 @@ } } - if (drawGround[i]) { - for (Pair<CrossSection, CrossSectionLine> csl: csli.lines) { - if (csl.getA() == cs) { - if (points == null) { - points = csl.getB().fetchCrossSectionLinesPoints(); - } - generateGround( - points, - cs.getDescription() + "/Boden", - datasets); - break; - } - } - } } return datasets;