This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 63bb4dba71dc8c14e80dcfe6dd8237fc545ddfb1 Author: Kevin Morin <morin@codelutin.com> Date: Fri Dec 12 17:29:57 2014 +0100 fixes #6290 [CAPTURE] si je modifie la valeur d'une classe de taille avec une classe de taille qui existe déjà dans le tableau... --- .../species/frequency/SpeciesFrequencyUIModel.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java index 969b816..74e996c 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java @@ -179,7 +179,7 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa * * @since 3.10 */ - protected Map<Float, MutableInt> nbOfRowsByLengthStep = new HashMap<Float, MutableInt>(); + protected Map<Integer, MutableInt> nbOfRowsByLengthStep = new HashMap<Integer, MutableInt>(); public SpeciesFrequencyUIModel(WeightUnit weightUnit, SampleCategoryModel sampleCategoryModel) { @@ -480,8 +480,10 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa } public int numberOfRows(float lengthStep) { + //convert the lengthstep into millimeter to avoid float inprecision in map equality + int mmLengthStep = Math.round(lengthStep * 10); int result = 0; - MutableInt mutableInt = nbOfRowsByLengthStep.get(lengthStep); + MutableInt mutableInt = nbOfRowsByLengthStep.get(mmLengthStep); if (mutableInt != null) { result = mutableInt.intValue(); } @@ -489,14 +491,16 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa } public void resetNumbersOfRows() { - nbOfRowsByLengthStep = new HashMap<Float, MutableInt>(); + nbOfRowsByLengthStep = new HashMap<Integer, MutableInt>(); } public int incNumberOfRows(float lengthStep) { - MutableInt mutableInt = nbOfRowsByLengthStep.get(lengthStep); + //convert the lengthstep into millimeter to avoid float inprecision in map equality + int mmLengthStep = Math.round(lengthStep * 10); + MutableInt mutableInt = nbOfRowsByLengthStep.get(mmLengthStep); if (mutableInt == null) { mutableInt = new MutableInt(1); - nbOfRowsByLengthStep.put(lengthStep, mutableInt); + nbOfRowsByLengthStep.put(mmLengthStep, mutableInt); } else { mutableInt.increment(); @@ -505,10 +509,14 @@ public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBa } public int decNumberOfRows(float lengthStep) { - MutableInt mutableInt = nbOfRowsByLengthStep.get(lengthStep); + //convert the lengthstep into millimeter to avoid float inprecision in map equality + int mmLengthStep = Math.round(lengthStep * 10); + + MutableInt mutableInt = nbOfRowsByLengthStep.get(mmLengthStep); Preconditions.checkNotNull(mutableInt); Preconditions.checkArgument(mutableInt.intValue() > 0); mutableInt.decrement(); return mutableInt.intValue(); } + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.