ingo@1625: package de.intevation.flys.artifacts.states; ingo@1625: ingo@1625: import org.apache.log4j.Logger; ingo@1625: ingo@1630: import de.intevation.artifacts.Artifact; ingo@1630: ingo@1630: import de.intevation.artifactdatabase.data.StateData; ingo@1630: felix@4865: import de.intevation.flys.artifacts.access.RangeAccess; ingo@1630: import de.intevation.flys.artifacts.FLYSArtifact; ingo@1630: ingo@1625: ingo@1625: public class DistanceOnlySelect extends DistanceSelect { ingo@1625: ingo@1625: private static Logger logger = 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. ingo@1630: FLYSArtifact flys = (FLYSArtifact) artifact; ingo@1630: ingo@1630: try { felix@4865: RangeAccess rangeAccess = new RangeAccess(flys, null); 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 :