Closed imagejan closed 3 years ago
This pull request has been mentioned on Image.sc Forum. There might be relevant details there:
https://forum.image.sc/t/save-one-tiff-projection-from-a-current-view-in-bdv/33965/28
@imagejan Quick question now that I managed to build it: currently is there a way to force / support scientific notation like 1.23e6
- at least in the display side ? I need it because for the same field, sometimes we can work in mm, sometimes in nm.
Hmm, this does not seem to work:
@Parameter(style = "format:%6.3e", persist = false)
private Double q = 0.0123;
But this works!
@Parameter(style = "format:0.#####E0", persist = false)
private Double q = 0.0123;
Ok, great!
Glad you found a working option!
See also: https://stackoverflow.com/a/2944856/1919049 and https://javadoc.scijava.org/Java8/index.html?java/text/DecimalFormat.html
As well as this related issue: https://github.com/scijava/scijava-ui-swing/issues/2
Ok, just one thing, I tried a few things which can probably be improved. For a Double field:
1E3
-> the display is modified into 1E3
, the output value is 1000 // Ok!1e3
-> the display is modified into 1E0
, the output value is 1 // sort of makes sense, the user realizes there's an issue with non capital E
GFP
-> the display is modified into GFP
, the output value is the previous value entered (default) // No error message. No modification in the displayDo you think we can at least get the display updated to the previous value when we type non valid characters ? Maybe it's a different issue than this PR ?
I updated the pull request to depend on scijava-common-2.87.0-SNAPSHOT
instead of a local 999
version, so that the CI build passes. We still need to remove the temporary version pin after a scijava-common-2.87.0
release gets cut.
There's one minor issue with the tests: on non-US locales, the test fails with:
[ERROR] Failures:
[ERROR] SwingNumberWidgetTest.test:97 Format (index 0) expected:<0[.]0000123> but was:<0[,]0000123>
@hinerm, @ctrueden: what's your opinion, should we always force a US locale in the Swing dialogs? That's how all the ImageJ 1.x dialogs do it, if I'm not mistaken. So it would help streamline the user experience...
@hinerm, @ctrueden: what's your opinion, should we always force a US locale in the Swing dialogs? That's how all the ImageJ 1.x dialogs do it, if I'm not mistaken. So it would help streamline the user experience...
Please do it !! Me and @tinevez (and many users) had terrible experiences with locale ... USA, USA! ;-)
@ctrueden, @hinerm This pull request is now ready for review. I removed the SNAPSHOT coupling and pinned to the newly released scijava-common-2.87.0
.
@NicoKiaru I tried forcing US locale in JSpinner.NumberEditor
in https://github.com/scijava/scijava-ui-swing/commit/e044d64138549d03d826c2f71732c303994de641, but the test still fails on a system with non-US default locale, maybe I misunderstood how it's supposed to work?
@NicoKiaru I tried forcing US locale in
JSpinner.NumberEditor
in e044d64, but the test still fails on a system with non-US default locale, maybe I misunderstood how it's supposed to work?
Ok, let's try to live with that, I couldn't find a way either. And anyway maybe it's better to set the "Locale" more globally than in some widgets here and there. This PR is already a great improvement!
This pull request depends on https://github.com/scijava/scijava-common/pull/405 and supersedes #52.
It includes the changes by @BoudewijnvanLangerak (in #52) as a squashed commit.
Changes can be tested with
SwingNumberWidgetDemo
added here, or with the following script:Here's a visual comparison before and after the changes in this commit:
(Fixes https://github.com/scijava/scijava-ui-swing/issues/45.)