Skip to content

Commit 4f9cbfe

Browse files
author
LeonYang5114
committed
Fix bug of ignoring the step size of a parameter
The step size attribute of a parameter is always ignored because there is no converter that converts String to Number. The bug is fixed by parsing the String to double. Similar bug exists in the script editor and has been fixed. See also: c0ffe39 #205
1 parent c0ffe39 commit 4f9cbfe

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎src/main/java/org/scijava/command/CommandModuleItem.java‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public Parameter getParameter() {
7575

7676
@Override
7777
public Class<T> getType() {
78-
final Class<?> type =
79-
GenericUtils.getFieldClasses(field, getDelegateClass()).get(0);
78+
final Class<?> type = GenericUtils.getFieldClasses(field,
79+
getDelegateClass()).get(0);
8080
@SuppressWarnings("unchecked")
8181
final Class<T> typedType = (Class<T>) type;
8282
return typedType;
@@ -104,8 +104,8 @@ public boolean isAutoFill() {
104104

105105
@Override
106106
public boolean isRequired() {
107-
return getParameter().required() &&
108-
!Optional.class.isAssignableFrom(getType());
107+
return getParameter().required() && !Optional.class.isAssignableFrom(
108+
getType());
109109
}
110110

111111
@Override
@@ -145,7 +145,14 @@ public T getMaximumValue() {
145145

146146
@Override
147147
public Number getStepSize() {
148-
return tValue(getParameter().stepSize(), Number.class);
148+
final String value = getParameter().stepSize();
149+
try {
150+
final double stepSize = Double.parseDouble(value);
151+
return stepSize;
152+
}
153+
catch (final NumberFormatException exc) {
154+
return tValue(value, Number.class);
155+
}
149156
}
150157

151158
@Override

0 commit comments

Comments
 (0)