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: 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: { ingo@1630: FLYSArtifact flys = (FLYSArtifact) artifact; ingo@1630: ingo@1630: StateData dFrom = getData(flys, getLowerField()); ingo@1630: StateData dTo = getData(flys, getUpperField()); ingo@1630: ingo@1630: String fromStr = dFrom != null ? (String) dFrom.getValue() : null; ingo@1630: String toStr = dTo != null ? (String) dTo.getValue() : null; ingo@1630: ingo@1630: if (fromStr == null || toStr == null) { ingo@1630: throw new IllegalArgumentException("error_empty_state"); ingo@1630: } ingo@1630: ingo@1630: try { ingo@1630: double from = Double.parseDouble(fromStr); ingo@1630: double to = Double.parseDouble(toStr); 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: } ingo@1630: } ingo@1625: } ingo@1625: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :