ingo@137: package de.intevation.flys.artifacts.states; ingo@137: ingo@1743: import java.text.NumberFormat; ingo@1743: ingo@379: import gnu.trove.TDoubleArrayList; ingo@379: ingo@137: import org.apache.log4j.Logger; ingo@137: ingo@137: import org.w3c.dom.Element; ingo@137: ingo@313: import de.intevation.artifacts.Artifact; ingo@137: import de.intevation.artifacts.CallContext; ingo@137: ingo@137: import de.intevation.artifacts.common.utils.XMLUtils; ingo@1743: import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; ingo@137: ingo@137: import de.intevation.artifactdatabase.ProtocolUtils; ingo@137: import de.intevation.artifactdatabase.data.StateData; ingo@137: ingo@319: import de.intevation.flys.model.Gauge; ingo@319: import de.intevation.flys.model.River; ingo@319: import de.intevation.flys.model.Wst; ingo@319: ingo@1743: import de.intevation.flys.artifacts.FLYSArtifact; sascha@1055: import de.intevation.flys.artifacts.WINFOArtifact; sascha@1055: ingo@319: import de.intevation.flys.artifacts.model.WstFactory; ingo@137: import de.intevation.flys.artifacts.resources.Resources; ingo@137: felix@1103: import de.intevation.flys.utils.FLYSUtils; felix@1103: felix@1103: ingo@137: /** ingo@137: * @author Ingo Weinzierl ingo@137: */ ingo@921: public class WQSelect extends DefaultState { ingo@137: felix@1691: /** The logger used in this class. */ ingo@137: private static Logger logger = Logger.getLogger(WQSelect.class); ingo@137: felix@1691: /** The default step width for Qs. */ ingo@137: public static final String DEFAULT_STEP_Q = "50"; ingo@137: felix@1691: /** The default step width for Qs. */ ingo@137: public static final String DEFAULT_STEP_W = "30"; ingo@137: ingo@2059: /** The max number of steps for Qs and Ws. */ ingo@2059: public static final int MAX_STEPS = 30; ingo@2059: ingo@322: /** The name of the 'mode' field. */ raimund@2556: public static final String WQ_MODE = "wq_isq"; ingo@322: ingo@1743: /** Them name fo the 'free' field. */ raimund@2556: public static final String WQ_FREE = "wq_isfree"; ingo@1743: felix@1691: /** The name of the 'selection' field. */ raimund@2556: public static final String WQ_SELECTION = "wq_isrange"; ingo@379: ingo@322: /** The name of the 'from' field. */ ingo@322: public static final String WQ_FROM = "wq_from"; ingo@322: ingo@322: /** The name of the 'to' field. */ ingo@322: public static final String WQ_TO = "wq_to"; ingo@322: ingo@322: /** The name of the 'step' field. */ ingo@322: public static final String WQ_STEP = "wq_step"; ingo@322: ingo@379: /** The name of the 'single' field. */ ingo@379: public static final String WQ_SINGLE = "wq_single"; ingo@379: ingo@379: ingo@137: /** ingo@137: * The default constructor that initializes an empty State object. ingo@137: */ ingo@137: public WQSelect() { ingo@137: } ingo@137: ingo@1743: ingo@1743: @Override ingo@1743: protected Element createStaticData( ingo@1743: FLYSArtifact flys, ingo@1743: ElementCreator creator, ingo@1743: CallContext cc, ingo@1743: String name, ingo@1743: String value, ingo@1743: String type ingo@1743: ) { ingo@1743: if (!name.equals(WQ_SINGLE)) { ingo@1743: return super.createStaticData(flys, creator, cc, name, value, type); ingo@1743: } ingo@1743: raimund@2556: Boolean isQ = flys.getDataAsBoolean(WQ_MODE); raimund@2556: Boolean isFree = flys.getDataAsBoolean(WQ_FREE); ingo@1743: ingo@1743: WINFOArtifact winfo = (WINFOArtifact) flys; ingo@1743: ingo@1743: Element dataElement = creator.create("data"); ingo@1743: creator.addAttr(dataElement, "name", name, true); ingo@1743: creator.addAttr(dataElement, "type", type, true); ingo@1743: ingo@1743: Element itemElement = creator.create("item"); ingo@1743: creator.addAttr(itemElement, "value", value, true); ingo@2025: sascha@2164: String label; ingo@2025: raimund@2552: if (!isQ || isFree) { ingo@2025: label = getLabel(winfo, cc, value); ingo@2025: } ingo@2025: else { ingo@2025: label = getSpecialLabel(winfo, cc, value); ingo@2025: } ingo@2025: ingo@2025: creator.addAttr(itemElement, "label", label, true); ingo@1743: ingo@1743: dataElement.appendChild(itemElement); ingo@1743: ingo@1743: return dataElement; ingo@1743: } ingo@1743: ingo@1743: ingo@1743: protected static String getLabel( ingo@1743: WINFOArtifact winfo, ingo@1743: CallContext cc, ingo@1743: String raw ingo@1743: ) { ingo@1743: String[] values = raw.split(" "); sascha@2164: sascha@2164: if (values.length < 1) { sascha@2164: return null; sascha@2164: } sascha@2164: sascha@2164: StringBuilder label = new StringBuilder(); ingo@1743: ingo@1743: NumberFormat nf = NumberFormat.getInstance( ingo@1743: Resources.getLocale(cc.getMeta())); ingo@1743: ingo@1743: for (String value: values) { ingo@1743: try { sascha@2164: double v = Double.parseDouble(value.trim()); ingo@1743: ingo@2025: String formatted = nf.format(v); ingo@2025: sascha@2164: if (label.length() > 0) { sascha@2164: label.append(';'); sascha@2164: } sascha@2164: label.append(formatted); ingo@2025: } ingo@2025: catch (NumberFormatException nfe) { ingo@2025: // do nothing here ingo@2025: } ingo@2025: } ingo@2025: sascha@2164: return label.toString(); ingo@2025: } ingo@2025: ingo@2025: ingo@2025: protected static String getSpecialLabel( ingo@2025: WINFOArtifact winfo, ingo@2025: CallContext cc, ingo@2025: String raw ingo@2025: ) { ingo@2025: String[] values = raw.split(" "); sascha@2164: sascha@2164: if (values.length < 1) { sascha@2164: return null; sascha@2164: } ingo@2025: ingo@2025: NumberFormat nf = NumberFormat.getInstance( ingo@2025: Resources.getLocale(cc.getMeta())); ingo@2025: sascha@2164: Gauge gauge = winfo.getGauge(); sascha@2164: sascha@2164: boolean debug = logger.isDebugEnabled(); sascha@2164: sascha@2164: StringBuilder label = new StringBuilder(); sascha@2164: ingo@2025: for (String value: values) { ingo@2025: try { sascha@2164: double v = Double.parseDouble(value.trim()); ingo@2025: ingo@1743: String tmp = nf.format(v); sascha@2164: String mv = FLYSUtils.getNamedMainValue(gauge, v); ingo@1743: ingo@1743: if (mv != null && mv.length() > 0) { sascha@2164: tmp = mv + ": " + tmp; sascha@2164: if (debug) { sascha@2164: logger.debug("Add main value: '" + mv + "'"); sascha@2164: } ingo@1743: } sascha@2164: if (label.length() > 0) { sascha@2164: label.append(';'); ingo@1743: } sascha@2164: label.append(tmp); ingo@1743: } ingo@1743: catch (NumberFormatException nfe) { ingo@1743: // do nothing here ingo@1743: } ingo@1743: } ingo@1743: sascha@2164: return label.toString(); ingo@1743: } ingo@1743: ingo@1743: felix@1691: @Override ingo@137: protected Element createData( ingo@137: XMLUtils.ElementCreator cr, ingo@313: Artifact artifact, ingo@137: StateData data, ingo@137: CallContext context) ingo@137: { ingo@137: Element select = ProtocolUtils.createArtNode( ingo@137: cr, "select", null, null); ingo@137: ingo@137: cr.addAttr(select, "name", data.getName(), true); ingo@137: ingo@137: Element label = ProtocolUtils.createArtNode( ingo@137: cr, "label", null, null); ingo@137: ingo@137: Element choices = ProtocolUtils.createArtNode( ingo@137: cr, "choices", null, null); ingo@137: ingo@137: label.setTextContent(Resources.getMsg( ingo@137: context.getMeta(), ingo@137: data.getName(), ingo@137: data.getName())); ingo@137: ingo@137: select.appendChild(label); ingo@137: ingo@137: return select; ingo@137: } ingo@137: ingo@137: sascha@660: @Override ingo@137: protected Element[] createItems( ingo@137: XMLUtils.ElementCreator cr, ingo@313: Artifact artifact, ingo@137: String name, ingo@137: CallContext context) ingo@137: { ingo@2062: double[] minmaxW = determineMinMaxW(artifact); ingo@2062: double[] minmaxQ = determineMinMaxQAtGauge(artifact); ingo@2062: double[] minmaxQFree = determineMinMaxQ(artifact); ingo@137: ingo@137: if (name.equals("wq_from")) { ingo@2062: Element minW = createItem(cr, new String[] { ingo@2062: "minW", ingo@2062: String.valueOf(minmaxW[0])}); ingo@2062: ingo@2062: Element minQ = createItem(cr, new String[] { ingo@2062: "minQ", ingo@2062: String.valueOf(minmaxQ[0])}); ingo@2062: ingo@2062: Element minQFree = createItem(cr, new String[] { ingo@2062: "minQFree", ingo@2062: String.valueOf(minmaxQFree[0])}); ingo@2062: ingo@2062: return new Element[] { minW, minQ, minQFree }; ingo@137: } ingo@137: else if (name.equals("wq_to")) { ingo@2062: Element maxW = createItem(cr, new String[] { ingo@2062: "maxW", ingo@2062: String.valueOf(minmaxW[1])}); ingo@2062: ingo@2062: Element maxQ = createItem(cr, new String[] { ingo@2062: "maxQ", ingo@2062: String.valueOf(minmaxQ[1])}); ingo@2062: ingo@2062: Element maxQFree = createItem(cr, new String[] { ingo@2062: "maxQFree", ingo@2062: String.valueOf(minmaxQFree[1])}); ingo@2062: ingo@2062: return new Element[] { maxW, maxQ, maxQFree }; ingo@137: } ingo@137: else { sascha@660: Element stepW = createItem( ingo@2059: cr, new String[] { ingo@2059: "stepW", ingo@2059: String.valueOf(getStepsW(minmaxW[0], minmaxW[1]))}); sascha@660: Element stepQ = createItem( ingo@2059: cr, new String[] { ingo@2059: "stepQ", ingo@2062: String.valueOf(getStepsQ(minmaxQ[0], minmaxQ[1]))}); ingo@2062: Element stepQFree = createItem( ingo@2062: cr, new String[] { ingo@2062: "stepQFree", ingo@2062: String.valueOf(getStepsQ(minmaxQFree[0], minmaxQFree[1]))}); ingo@2062: ingo@2062: return new Element[] { stepW, stepQ, stepQFree }; ingo@137: } ingo@137: } ingo@137: ingo@137: ingo@2059: protected static double getStepsW(double min, double max) { ingo@2059: double diff = min < max ? max - min : min - max; ingo@2059: double step = diff / MAX_STEPS; ingo@2059: ingo@2061: if (step < 10) { ingo@2061: return getSteps(step, 1); ingo@2059: } ingo@2059: else if (step < 100) { ingo@2059: return getSteps(step, 10); ingo@2059: } ingo@2061: else if (step < 1000) { ingo@2061: return getSteps(step, 100); ingo@2059: } ingo@2059: else { ingo@2059: return step; ingo@2059: } ingo@2059: } ingo@2059: ingo@2059: ingo@2059: protected static double getStepsQ(double min, double max) { ingo@2059: double diff = min < max ? max - min : min - max; ingo@2059: double step = diff / MAX_STEPS; ingo@2059: ingo@2061: if (step < 10) { ingo@2061: return getSteps(step, 1); ingo@2059: } ingo@2059: else if (step < 100) { ingo@2059: return getSteps(step, 10); ingo@2059: } ingo@2061: else if (step < 1000) { ingo@2061: return getSteps(step, 100); ingo@2059: } ingo@2059: else { ingo@2059: return step; ingo@2059: } ingo@2059: } ingo@2059: ingo@2059: ingo@2059: protected static double getSteps(double steps, double factor) { ingo@2059: int fac = (int) steps / 10; ingo@2059: double diff = steps - fac * 10; ingo@2059: ingo@2059: if (diff == 0) { ingo@2059: return steps; ingo@2059: } ingo@2059: ingo@2059: return 10d * (fac + 1); ingo@2059: } ingo@2059: ingo@2059: ingo@137: protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { ingo@137: Element item = ProtocolUtils.createArtNode(cr, "item", null, null); ingo@137: Element label = ProtocolUtils.createArtNode(cr, "label", null, null); ingo@137: Element value = ProtocolUtils.createArtNode(cr, "value", null, null); ingo@137: ingo@137: String[] arr = (String[]) obj; ingo@137: ingo@137: label.setTextContent(arr[0]); ingo@137: value.setTextContent(arr[1]); ingo@137: ingo@137: item.appendChild(label); ingo@137: item.appendChild(value); ingo@137: ingo@137: return item; ingo@137: } ingo@137: ingo@137: sascha@660: @Override ingo@137: protected String getUIProvider() { ingo@137: return "wq_panel"; ingo@137: } ingo@319: ingo@319: ingo@319: /** ingo@319: * Determines the min and max W value for the current gauge. If no min and ingo@319: * max values could be determined, this method will return ingo@319: * [Double.MIN_VALUE, Double.MAX_VALUE]. ingo@319: * ingo@319: * @param artifact The FLYSArtifact. ingo@319: * ingo@319: * @return the min and max W values for the current gauge. ingo@319: */ ingo@319: protected double[] determineMinMaxW(Artifact artifact) { ingo@319: logger.debug("WQSelect.determineCurrentGauge"); ingo@319: sascha@1055: Gauge gauge = ((WINFOArtifact) artifact).getGauge(); ingo@320: double[] minmaxW = gauge != null ? gauge.determineMinMaxW() : null; ingo@319: ingo@319: double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE; ingo@319: double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE; ingo@319: ingo@319: return new double[] { minW, maxW }; ingo@319: } ingo@319: ingo@319: ingo@319: /** ingo@319: * Determines the min and max Q value for the current gauge. If no min and ingo@319: * max values could be determined, this method will return ingo@319: * [Double.MIN_VALUE, Double.MAX_VALUE]. ingo@319: * ingo@319: * @param artifact The FLYSArtifact. ingo@319: * ingo@319: * @return the min and max Q values for the current gauge. ingo@319: */ ingo@2060: protected double[] determineMinMaxQAtGauge(Artifact artifact) { ingo@2060: logger.debug("WQSelect.determineMinMaxQAtGauge"); ingo@319: sascha@1055: WINFOArtifact flysArtifact = (WINFOArtifact) artifact; ingo@319: felix@1103: River river = FLYSUtils.getRiver(flysArtifact); felix@1103: Gauge gauge = flysArtifact.getGauge(); felix@1103: Wst wst = WstFactory.getWst(river); ingo@319: ingo@320: double[] minmaxQ = gauge != null ingo@320: ? wst.determineMinMaxQ(gauge.getRange()) ingo@320: : null; ingo@319: ingo@319: double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE; ingo@319: double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE; ingo@319: ingo@319: return new double[] { minQ, maxQ }; ingo@319: } ingo@322: ingo@322: ingo@2060: /** ingo@2060: * Determines the min and max Q value for the current kilometer range. If no ingo@2060: * min and max values could be determined, this method will return ingo@2060: * ingo@2060: * @param artifact The FLYSArtifact. ingo@2060: * ingo@2060: * @return the min and max Q values for the current kilometer range. ingo@2060: */ ingo@2060: protected double[] determineMinMaxQ(Artifact artifact) { ingo@2060: logger.debug("WQSelect.determineMinMaxQ"); ingo@2060: ingo@2060: FLYSArtifact flys = (FLYSArtifact) artifact; ingo@2060: double[] kms = FLYSUtils.getKmRange(flys); ingo@2060: ingo@2060: if (kms == null || kms.length == 0) { ingo@2060: return new double[] { Double.MIN_VALUE, Double.MAX_VALUE }; ingo@2060: } ingo@2060: ingo@2060: River river = FLYSUtils.getRiver(flys); ingo@2060: Wst wst = WstFactory.getWst(river); ingo@2060: ingo@2060: logger.debug("User defined KMs: " + kms[0] + " - " + kms[kms.length-1]); ingo@2060: ingo@2070: double[] minmaxQ = wst.determineMinMaxQFree(kms[0]); ingo@2060: ingo@2060: return minmaxQ != null ingo@2060: ? minmaxQ ingo@2060: : new double[] { Double.MIN_VALUE, Double.MAX_VALUE }; ingo@2060: } ingo@2060: ingo@2060: ingo@322: @Override sascha@1050: public boolean validate(Artifact artifact) ingo@322: throws IllegalArgumentException ingo@322: { ingo@322: logger.debug("WQSelect.validate"); ingo@322: sascha@1055: WINFOArtifact flys = (WINFOArtifact) artifact; ingo@322: ingo@624: StateData data = getData(flys, WQ_SELECTION); raimund@2556: boolean isRange = data != null raimund@2552: ? Boolean.valueOf((String) data.getValue()) raimund@2552: : false; ingo@379: raimund@2556: raimund@2556: raimund@2552: if (!isRange) { sascha@1050: return validateSingle(artifact); ingo@379: } ingo@379: else { sascha@1050: return validateRange(artifact); ingo@379: } ingo@379: } ingo@379: ingo@379: ingo@921: protected boolean validateBounds( ingo@921: double fromValid, double toValid, ingo@921: double from, double to, double step) ingo@921: throws IllegalArgumentException ingo@921: { ingo@921: logger.debug("RangeState.validateRange"); ingo@921: ingo@921: if (from < fromValid) { ingo@921: logger.error( ingo@921: "Invalid 'from'. " + from + " is smaller than " + fromValid); ingo@921: throw new IllegalArgumentException("error_feed_from_out_of_range"); ingo@921: } ingo@921: else if (to > toValid) { ingo@921: logger.error( ingo@921: "Invalid 'to'. " + to + " is bigger than " + toValid); ingo@921: throw new IllegalArgumentException("error_feed_to_out_of_range"); ingo@921: } ingo@921: ingo@921: return true; ingo@921: } ingo@921: ingo@921: sascha@1050: protected boolean validateSingle(Artifact artifact) ingo@379: throws IllegalArgumentException ingo@379: { ingo@379: logger.debug("WQSelect.validateSingle"); ingo@379: sascha@1055: WINFOArtifact flys = (WINFOArtifact) artifact; ingo@624: StateData data = getData(flys, WQ_SINGLE); ingo@624: ingo@624: String tmp = data != null ? (String) data.getValue() : null; ingo@379: ingo@379: if (tmp == null || tmp.length() == 0) { ingo@379: throw new IllegalArgumentException("error_empty_state"); ingo@379: } ingo@379: ingo@379: String[] strValues = tmp.split(" "); ingo@379: TDoubleArrayList all = new TDoubleArrayList(); ingo@379: ingo@379: for (String strValue: strValues) { ingo@379: try { ingo@379: all.add(Double.parseDouble(strValue)); ingo@379: } ingo@379: catch (NumberFormatException nfe) { ingo@379: logger.warn(nfe, nfe); ingo@379: } ingo@379: } ingo@379: ingo@379: all.sort(); ingo@379: ingo@2060: FLYSUtils.WQ_MODE mode = FLYSUtils.getWQMode(flys); ingo@624: ingo@379: logger.debug("WQ Mode: " + mode); ingo@379: ingo@379: double[] minmax = null; ingo@379: ingo@2060: if (mode == FLYSUtils.WQ_MODE.WGAUGE) { ingo@379: minmax = determineMinMaxW(artifact); ingo@379: } ingo@2060: else if (mode == FLYSUtils.WQ_MODE.QGAUGE) { ingo@2060: minmax = determineMinMaxQAtGauge(artifact); ingo@2060: } ingo@379: else { ingo@379: minmax = determineMinMaxQ(artifact); ingo@379: } ingo@379: ingo@379: double min = all.get(0); ingo@379: double max = all.get(all.size()-1); ingo@379: ingo@379: logger.debug("Inserted min value = " + min); ingo@379: logger.debug("Inserted max value = " + max); ingo@379: ingo@379: return validateBounds(minmax[0], minmax[1], min, max, 0d); ingo@379: } ingo@379: ingo@379: sascha@1050: protected boolean validateRange(Artifact artifact) ingo@379: throws IllegalArgumentException ingo@379: { ingo@379: logger.debug("WQSelect.validateRange"); ingo@379: ingo@2060: WINFOArtifact flys = (WINFOArtifact) artifact; ingo@2060: FLYSUtils.WQ_MODE mode = FLYSUtils.getWQMode(flys); ingo@322: ingo@2060: if (mode == null) { ingo@631: throw new IllegalArgumentException("error_feed_invalid_wq_mode"); ingo@631: } ingo@631: ingo@631: StateData dFrom = flys.getData(WQ_FROM); ingo@631: StateData dTo = flys.getData(WQ_TO); ingo@631: StateData dStep = flys.getData(WQ_STEP); ingo@631: ingo@631: String fromStr = dFrom != null ? (String) dFrom.getValue() : null; ingo@631: String toStr = dTo != null ? (String) dTo.getValue() : null; ingo@631: String stepStr = dStep != null ? (String) dStep.getValue() : null; ingo@322: ingo@352: if (fromStr == null || toStr == null || stepStr == null) { ingo@352: throw new IllegalArgumentException("error_empty_state"); ingo@352: } ingo@352: ingo@631: try { ingo@631: double from = Double.parseDouble(fromStr); ingo@631: double to = Double.parseDouble(toStr); ingo@631: double step = Double.parseDouble(stepStr); ingo@322: ingo@2060: if (mode == FLYSUtils.WQ_MODE.WGAUGE) { ingo@2060: return validateGaugeW(artifact, from, to, step); ingo@322: } ingo@2060: else if (mode == FLYSUtils.WQ_MODE.QGAUGE) { ingo@2060: return validateGaugeQ(artifact, from, to, step); ingo@2060: } ingo@2060: else if (mode == FLYSUtils.WQ_MODE.QFREE) { ingo@2060: return validateFreeQ(artifact, from, to, step); ingo@322: } ingo@322: else { sascha@660: throw new IllegalArgumentException( sascha@660: "error_feed_invalid_wq_mode"); ingo@322: } ingo@322: } ingo@322: catch (NumberFormatException nfe) { ingo@322: throw new IllegalArgumentException("error_feed_number_format"); ingo@322: } ingo@322: } ingo@322: ingo@322: ingo@322: /** ingo@322: * Validates the inserted W values. ingo@322: * ingo@322: * @param artifact The owner artifact. ingo@322: * @param from The lower value of the W range. ingo@322: * @param to The upper value of the W range. ingo@322: * @param step The step width. ingo@322: * ingo@322: * @return true, if everything was fine, otherwise an exception is thrown. ingo@322: */ ingo@2060: protected boolean validateGaugeW( ingo@322: Artifact artifact, ingo@322: double from, ingo@322: double to, ingo@322: double step) ingo@322: throws IllegalArgumentException ingo@322: { ingo@2060: logger.debug("WQSelect.validateGaugeW"); ingo@322: ingo@322: double[] minmaxW = determineMinMaxW(artifact); ingo@322: ingo@379: return validateBounds(minmaxW[0], minmaxW[1], from, to, step); ingo@322: } ingo@322: ingo@322: ingo@322: /** ingo@2060: * Validates the inserted Q values based on the Q range for the current ingo@2060: * gauge. ingo@322: * ingo@322: * @param artifact The owner artifact. ingo@322: * @param from The lower value of the Q range. ingo@322: * @param to The upper value of the Q range. ingo@322: * @param step The step width. ingo@322: * ingo@322: * @return true, if everything was fine, otherwise an exception is thrown. ingo@322: */ ingo@2060: protected boolean validateGaugeQ( ingo@2060: Artifact artifact, ingo@2060: double from, ingo@2060: double to, ingo@2060: double step) ingo@2060: throws IllegalArgumentException ingo@322: { ingo@2060: logger.debug("WQSelect.validateGaugeQ"); ingo@2060: ingo@2060: double[] minmaxQ = determineMinMaxQAtGauge(artifact); ingo@2060: ingo@2060: return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step); ingo@2060: } ingo@2060: ingo@2060: ingo@2060: /** ingo@2060: * Validates the inserted Q values based on the Q range for the current ingo@2060: * kilometer range. ingo@2060: * ingo@2060: * @param artifact The owner artifact. ingo@2060: * @param from The lower value of the Q range. ingo@2060: * @param to The upper value of the Q range. ingo@2060: * @param step The step width. ingo@2060: * ingo@2060: * @return true, if everything was fine, otherwise an exception is thrown. ingo@2060: */ ingo@2060: protected boolean validateFreeQ( ingo@2060: Artifact artifact, ingo@2060: double from, ingo@2060: double to, ingo@2060: double step) ingo@2060: throws IllegalArgumentException ingo@2060: { ingo@2060: logger.debug("WQSelect.validateFreeQ"); ingo@322: ingo@322: double[] minmaxQ = determineMinMaxQ(artifact); ingo@322: ingo@379: return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step); ingo@322: } ingo@137: } ingo@137: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :