void256/nifty-gui — pull request #257 by 3xp0n3nt (2014-07-30 16:30:21+00:00)
Title: Allow SizeValue floating point values.

Modify the internal storage of SizeValue to use a float rather than an
int to allow for floating point values in SizeValue strings.

Add SizeValue tests to verify that floating point strings are accepted
as valid values and are parsed correctly.

SizeValue.getValueAsInt now rounds the floating point pixel values to
the nearest integer using Math.round, which is the safest way to do it.
It is also consistent with the already existing behavior for floating
point percentage values, which already uses Math.round in the
getValueAsInt method (it was added to fix a subtle truncation bug
causing off-by-one pixel errors).

Fix failing tests in
nifty-core/src/main/test/java/de/lessvoid/nifty/layout package by
verifying resulting SizeValue strings as a decimal value instead of an
integer value. For example, new SizeValue("100px").toString() will now
equal "100.0px" instead of "100px".

The SizeValue.toString method is the only place where the extra ".0" in
(for example) "100.0px" as a string will come into play because even
though most of the time it will be a whole number, now there is the
chance that it could be something like "100.5px". It seems to be the
most reasonable behavior to always have the decimal and trailing zero
for "whole number" SizeValue.toString outputs, rather than only having
the decimal when it is not ".0". This could be considered a significant
change, but it doesn't break anything because only the output format is
changing - SizeValue still accepts "100px" (with no decimal) as a valid
value, it just converts it to "100.0px".

The SizeValue equals & hashcode methods were deleted and replaced by
auto-generated versions from IntelliJ, which are safe because they both
rely on the Float.floatToIntBits under the hood for the internally
stored float value. Tests have been added to SizeValueTest to verify
that equals is working correctly. For example, new SizeValue ("10.0px")
should be equal to new SizeValue ("10px"), but new SizeValue
("10.0001px") should not be equal to new SizeValue ("10px") nor new
SizeValue ("10.0002px").

Fixes #244.