use of org.polymap.core.style.model.feature.NumberRange in project polymap4-core by Polymap4.
the class ConstantNumberEditor method createContents.
@Override
public Composite createContents(Composite parent) {
Composite contents = super.createContents(parent);
Spinner s = new Spinner(contents, SWT.BORDER);
NumberRange nd = (NumberRange) prop.info().getAnnotation(NumberRange.class);
if (nd != null) {
int digits = nd.digits();
double currentValue = (double) prop.get().constantNumber.get();
double factorX = Math.pow(10, digits);
s.setDigits(digits);
s.setMinimum((int) (nd.from() * factorX));
s.setMaximum((int) (nd.to() * factorX));
s.setIncrement((int) (nd.increment() * factorX));
s.setPageIncrement((int) (nd.increment() * factorX * 10));
s.setSelection((int) (currentValue * factorX));
}
s.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int selection = s.getSelection();
int digits = s.getDigits();
prop.get().constantNumber.set(selection / Math.pow(10, digits));
}
});
return contents;
}
Aggregations