Search in sources :

Example 6 with TrackedParameter

use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackedParameter in project elki by elki-project.

the class ParameterTabPanel method setParameters.

/**
 * Do the actual setParameters invocation.
 *
 * @param config Parameterization
 */
public void setParameters(Parameterization config) {
    TrackParameters track = new TrackParameters(config);
    configureStep(track);
    // update parameter table
    {
        parameterTable.setEnabled(false);
        parameterTable.clear();
        for (TrackedParameter pair : track.getAllParameters()) {
            parameterTable.addParameter(pair.getOwner(), pair.getParameter(), track);
        }
        // parameters.updateFromTrackParameters(track);
        parameterTable.revalidate();
        parameterTable.setEnabled(true);
    }
    // Update status and notify observers
    updateStatus();
    firePanelUpdated();
}
Also used : TrackedParameter(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackedParameter) TrackParameters(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackParameters)

Example 7 with TrackedParameter

use of de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackedParameter in project elki by elki-project.

the class DynamicParameters method updateFromTrackParameters.

/**
 * Update the Parameter list from the collected options of an ELKI context
 *
 * @param track Tracked Parameters
 */
public synchronized void updateFromTrackParameters(TrackParameters track) {
    parameters.clear();
    for (TrackedParameter p : track.getAllParameters()) {
        Parameter<?> option = p.getParameter();
        String value = null;
        if (option.isDefined()) {
            if (option.tookDefaultValue()) {
                value = DynamicParameters.STRING_USE_DEFAULT + option.getDefaultValueAsString();
            } else {
                value = option.getValueAsString();
            }
        }
        if (value == null) {
            value = (option instanceof Flag) ? Flag.NOT_SET : "";
        }
        int bits = 0;
        if (option.isOptional()) {
            bits |= BIT_OPTIONAL;
        }
        if (option.hasDefaultValue() && option.tookDefaultValue()) {
            bits |= BIT_DEFAULT_VALUE;
        }
        if (value.length() <= 0) {
            if ((bits & BIT_DEFAULT_VALUE) == 0 && (bits & BIT_OPTIONAL) == 0) {
                bits |= BIT_INCOMPLETE;
            }
        } else {
            try {
                if (!option.tookDefaultValue() && !option.isValid(value)) {
                    bits |= BIT_INVALID;
                }
            } catch (ParameterException e) {
                bits |= BIT_INVALID;
            }
        }
        int depth = 0;
        {
            Object pos = track.getParent(option);
            while (pos != null) {
                pos = track.getParent(pos);
                depth += 1;
                if (depth > 10) {
                    break;
                }
            }
        }
        parameters.add(new Node(option, value, bits, depth));
    }
}
Also used : ParameterException(de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException) TrackedParameter(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackedParameter) Flag(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Flag)

Aggregations

TrackedParameter (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackedParameter)7 TrackParameters (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.TrackParameters)3 ClassParameter (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.ClassParameter)3 SettingsResult (de.lmu.ifi.dbs.elki.result.SettingsResult)2 ArrayList (java.util.ArrayList)2 ELKIServiceScanner (de.lmu.ifi.dbs.elki.utilities.ELKIServiceScanner)1 Reference (de.lmu.ifi.dbs.elki.utilities.documentation.Reference)1 OptionID (de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID)1 ParameterException (de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException)1 SerializedParameterization (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.SerializedParameterization)1 UnParameterization (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.UnParameterization)1 ClassListParameter (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.ClassListParameter)1 Flag (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Flag)1 Parameter (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter)1 RandomParameter (de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.RandomParameter)1 Pair (de.lmu.ifi.dbs.elki.utilities.pairs.Pair)1 StaticVisualizationInstance (de.lmu.ifi.dbs.elki.visualization.visualizers.StaticVisualizationInstance)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 List (java.util.List)1