* [#16525](https://bugzilla.scilab.org/16525): `soundsec(t,freq)` has the trivial equivalence `0 : 1/freq : t*(1-%eps)` and should be removed.
* [#16529](https://bugzilla.scilab.org/16529): `deff` could not return the created function as output argument, preventing to cretae and use anonymous functions. The function's headline and body had to be provided separately. For Simple functions, a one-string input (possibly console-oriented) definition was not supported.
* [#16530](https://bugzilla.scilab.org/16530): `mapsound` needed to be reforged.
+* [#16540](https://bugzilla.scilab.org/16540): uicontrol spinner did not "snaptoticks"
* [#16549](https://bugzilla.scilab.org/16549): simple script crashed Scilab in GUI mode.
* [#16551](https://bugzilla.scilab.org/16551): `num2cell` returned {} for any input array of empty strings.
* [#16552](https://bugzilla.scilab.org/16552): `mfile2sci`: conversion of `ispc` and `isunix` still used `MSDOS` removed far ago. Conversion of `ismac` was missing. Conversion of `exist` missed using `mtlb_exist`. Conversion of `dos` yielded some "operation +" warnings. Unit tests for the conversion of `cd`, `dir` and `ferror` overwrote some Scilab reserved keywords. Conversion of `return` yielded `mtlb(resume)`.
import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MAX__;
import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MIN__;
import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SLIDERSTEP__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SNAPTOTICKS__;
import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_VALUE__;
import java.awt.Color;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import javax.swing.JFormattedTextField;
+import javax.swing.text.NumberFormatter;
+
+
import org.scilab.modules.graphic_objects.graphicController.GraphicController;
import org.scilab.modules.gui.SwingViewObject;
addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
Double val = (Double)getValue();
+ double userMin = (double) GraphicController.getController().getProperty(uid, __GO_UI_MIN__);
+ double userMax = (double) GraphicController.getController().getProperty(uid, __GO_UI_MAX__);
+ Double[] userStep = (Double[]) GraphicController.getController().getProperty(uid, __GO_UI_SLIDERSTEP__);
+ val = Math.max(Math.min(userMax,val),userMin);
+ if ((boolean)GraphicController.getController().getProperty(uid, __GO_UI_SNAPTOTICKS__)) {
+ val = (userMin/userStep[0]+Math.round((val-userMin)/userStep[0]))*userStep[0];
+ }
+ setValue(val);
GraphicController.getController().setProperty(uid, __GO_UI_VALUE__, new Double[] {val});
if (callback != null) {
callback.actionPerformed(null);
Double[] step = (Double[]) controller.getProperty(getId(), __GO_UI_SLIDERSTEP__);
Double[] val = (Double[]) controller.getProperty(getId(), __GO_UI_VALUE__);
Double v = (val != null && val.length != 0) ? val[0] : 0.0;
- if (v > max) {
- v = max;
- }
- if (v < min) {
- v = min;
- }
-
- //adjust value to current step
+ //adjust value to current min,max,step
if (step[0] != 0) {
- v = Math.floor((v / step[0])) * step[0];
+ v = Math.min(max, min+Math.max(0,Math.round((v-min) / step[0])) * step[0]);
} else {
v = min;
}
controller.setProperty(uid, __GO_UI_VALUE__, new Double[] {v});
setModel(new SpinnerNumberModel(v, min, max, step[0]));
+ JFormattedTextField txt = ((JSpinner.NumberEditor) getEditor()).getTextField();
+ ((NumberFormatter) txt.getFormatter()).setAllowsInvalid(false);
+ ((NumberFormatter) txt.getFormatter()).setCommitsOnValidEdit(true);
+
break;
}
case __GO_UI_VALUE__: {