Repository navigation
FormulaParameters
Up | Previous | Next | Русский
Below is the full source of the class in documentation form. The comments inside the block explain the purpose of the parts of the class, but they are not stored in the working file FormulaParameters.java: the production code stays clean and the explanations live in the wiki.
package com.velitask.plugin.official.processing;
import com.velitask.sdk.properties.BooleanProperty;
import com.velitask.sdk.properties.DoubleSpinnerProperty;
import com.velitask.sdk.properties.IntegerProperty;
/* Factory of processing formula parameters: a single way to create numeric fields and step checkboxes. */
public final class FormulaParameters {
/* Conventional "no limit" for bounds: a very large number instead of infinity. */
public static final double NO_LIMIT = 1.0e9;
/* Utility class: no instances are created. */
private FormulaParameters() {
}
/* Integer field: the value and the default are the same. */
public static IntegerProperty integer(String name, String title, String description, int value) {
IntegerProperty property = new IntegerProperty(value, name, title);
property.setDefault(value);
property.setDescription(description);
return property;
}
/* Decimal field, not below zero (the default spinner range). */
public static DoubleSpinnerProperty decimal(String name, String title, String description, double value) {
DoubleSpinnerProperty property = new DoubleSpinnerProperty(value, name, title);
property.setDescription(description);
return property;
}
/* Signed decimal field: range from -NO_LIMIT to NO_LIMIT. */
public static DoubleSpinnerProperty signed(String name, String title, String description, double value) {
DoubleSpinnerProperty property = new DoubleSpinnerProperty(value, name, title);
property.setRange(-NO_LIMIT, NO_LIMIT);
property.setDescription(description);
return property;
}
/* Checkbox: on or off. */
public static BooleanProperty flag(String name, String title, String description, boolean value) {
BooleanProperty property = new BooleanProperty(value, name, title);
property.setDescription(description);
return property;
}
}FormulaParameters is a set of factory methods that the plugin's processing formulas (pauses, filters, compression) use to create their parameters. A formula declares its parameters through these methods instead of calling the constructors of IntegerProperty, DoubleSpinnerProperty and BooleanProperty directly. This way the default, the description and the range are set the same way for all steps. The title and the description come from the localization strings (keys like Plugin.ImportStep.gaps.minStepSec.title) and are passed to the methods as the title and description arguments.
Data. All methods take the same four arguments: name (a stable parameter name, the import plan passes the value by it), title (the title in the interface), description (a hint), value (the initial value, which is also the default). A ready SDK property is returned.
Settings. Four factories:
| Method | Property type | Notes |
|---|---|---|
integer(...) |
IntegerProperty |
the value and the default (setDefault) are set by one number |
decimal(...) |
DoubleSpinnerProperty |
the default spinner range: from 0 to Double.MAX_VALUE, step 0.1; the default is set by the constructor |
signed(...) |
DoubleSpinnerProperty |
the range from -NO_LIMIT to NO_LIMIT for values that can be negative |
flag(...) |
BooleanProperty |
on or off |
The NO_LIMIT constant equals 1.0e9. The DJI and DJI SRT import plans pass it as the speed "Upper limit", so that the limit check rejects only negative values.
Drawing. The class draws nothing: it creates properties, and the application builds their fields in the step settings.
Where it is used: decimal(...) in ToleranceCompress, AverageFilter, VectorAverageFilter, ExponentialFilter, DriftFilter, StayFilter, BadPointFilter, StepGaps, UnchangedGaps, StayGaps, ThresholdGaps; integer(...) in StepGaps; signed(...) in BadPointFilter (the lower and upper limits, the lower spike threshold) and ThresholdGaps (the stop and moving thresholds); flag(...) in BadPointFilter (the check checkboxes).
- The constructor is private and the class is
final: it is a set of static methods. -
decimal(...)does not allow negative values: usesigned(...)for them.decimal(...)has no upper limit. - An explicit
setDefaultis called only ininteger(...); for the other factories the default is set by the property constructor. - The description is set through
setDescription(...); the factory does not check for empty text. - The parameter names (
name) are part of the agreement with the import plans and the saved values: renaming makes the earlier values inapplicable.