teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.states; ingo@1625: ingo@1625: import org.apache.log4j.Logger; ingo@1625: teichmann@5831: import org.dive4elements.artifacts.Artifact; ingo@1630: teichmann@5831: import org.dive4elements.river.artifacts.access.RangeAccess; teichmann@5867: import org.dive4elements.river.artifacts.D4EArtifact; ingo@1630: ingo@1625: ingo@1625: public class DistanceOnlySelect extends DistanceSelect { ingo@1625: teichmann@8202: private static Logger log = Logger.getLogger(DistanceOnlySelect.class); ingo@1625: ingo@1625: @Override ingo@1625: protected String getUIProvider() { ingo@1625: return "distance_only_panel"; ingo@1625: } ingo@1630: ingo@1630: ingo@1630: @Override ingo@1630: public boolean validate(Artifact artifact) ingo@1630: throws IllegalArgumentException ingo@1630: { felix@4865: // TODO think about better hierarchy wrt RangeState#validate. teichmann@5867: D4EArtifact flys = (D4EArtifact) artifact; ingo@1630: ingo@1630: try { teichmann@6101: RangeAccess rangeAccess = new RangeAccess(flys); felix@4865: double from = rangeAccess.getFrom(); felix@4865: double to = rangeAccess.getTo(); ingo@1630: ingo@1630: double[] minmax = getMinMax(flys); ingo@1630: ingo@1630: return validateBounds(minmax[0], minmax[1], from, to); ingo@1630: } ingo@1630: catch (NumberFormatException nfe) { ingo@1630: throw new IllegalArgumentException("error_invalid_double_value"); ingo@1630: } felix@4865: catch (NullPointerException npe) { felix@4865: throw new IllegalArgumentException("error_empty_state"); felix@4865: } ingo@1630: } ingo@1625: } ingo@1625: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :