Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java @ 4198:1cdbd8a0c994
Added two new tables ClickableQDTable and ClickableWTable and made Ws and Qs clickable in historical discharge calculation.
The new tables define listener interfaces (clicked lower or upper icon) to listen to user clicks.
In addition to this, there is an enum ClickMode with NONE, SINGLE and RANGE options, which allows to
specifiy, which icons are displayed in the tables. NONE means no icon for user clicks, SINGLE has 1
icon, RANGE 2 icons for lower and upper.
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 22 Oct 2012 13:31:25 +0200 |
parents | 7fa38f8bcd8d |
children | d5d2faf14522 |
line wrap: on
line source
package de.intevation.flys.artifacts.access; import java.util.Date; import java.util.LinkedList; import java.util.List; import org.apache.log4j.Logger; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.DateRange; public class BedQualityAccess extends RiverAccess { private static final Logger logger = Logger .getLogger(BedQualityAccess.class); private Double from; private Double to; private List<String> bedDiameter; private List<String> bedloadDiameter; private List<DateRange> ranges; public BedQualityAccess(FLYSArtifact artifact) { super(artifact); } public double getFrom() { if (from == null) { from = getDouble("ld_from"); } return from.doubleValue(); } public double getTo() { if (to == null) { to = getDouble("ld_to"); } return to.doubleValue(); } public List<DateRange> getDateRanges() { if (ranges == null) { ranges = extractRanges(getString("periods")); } return ranges; } public List<String> getBedDiameter() { String value = getString("bed_diameter"); if (bedDiameter == null && value != null) { bedDiameter = extractDiameter(value); } return bedDiameter; } public List<String> getBedloadDiameter() { String value = getString("load_diameter"); if (bedloadDiameter == null && value != null) { bedloadDiameter = extractDiameter(value); } return bedloadDiameter; } private List<DateRange> extractRanges(String dateString) { List<DateRange> list = new LinkedList<DateRange>(); String[] dates = dateString.split(";"); for (String s : dates) { String[] pair = s.split(","); try { long l1 = Long.parseLong(pair[0]); long l2 = Long.parseLong(pair[1]); Date first = new Date(l1); Date second = new Date(l2); DateRange dr = new DateRange(first, second); list.add(dr); } catch (NumberFormatException nfe) { continue; } } return list; } private List<String> extractDiameter(String value) { List<String> result = new LinkedList<String>(); String[] diameter = value.split(";"); for (String v : diameter) { logger.debug("diameter: " + v); String[] parts = v.split("\\."); result.add(parts[parts.length - 1]); logger.debug(parts[parts.length-1]); } return result; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :