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();
}
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));
}
}
Aggregations