From 0873fd1ab406be7ef121f466c7b53e4b6315bbca Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 23 Jul 2015 11:26:11 +0100 Subject: [PATCH] JAL-1819 use Float.isNaN() to check for NaNs! --- src/jalview/analysis/AlignmentSorter.java | 2 +- src/jalview/appletgui/IdPanel.java | 2 +- src/jalview/datamodel/Annotation.java | 2 +- src/jalview/io/AnnotationFile.java | 4 ++-- src/jalview/io/FeaturesFile.java | 2 +- src/jalview/io/SequenceAnnotationReport.java | 2 +- src/jalview/io/vamsas/Sequencefeature.java | 2 +- src/jalview/renderer/seqfeatures/FeatureRenderer.java | 2 +- src/jalview/schemes/GraduatedColor.java | 6 +++--- src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java | 2 +- src/jalview/ws/jws2/AADisorderClient.java | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index 2fad332..0022af6 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -820,7 +820,7 @@ public class AlignmentSorter else { // or, also take a look at the scores if necessary. - if (!ignoreScore && sf[f].getScore() != Float.NaN) + if (!ignoreScore && !Float.isNaN(sf[f].getScore())) { if (seqScores[i] == 0) { diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index 258b8b6..72f94ec 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -142,7 +142,7 @@ public class IdPanel extends Panel implements MouseListener, nl = true; } ; - if (sf[sl].getScore() != Float.NaN && sf[sl].getScore() != 0f) + if (!Float.isNaN(sf[sl].getScore()) && sf[sl].getScore() != 0f) { tooltiptext.append(" Score = "); tooltiptext.append(sf[sl].getScore()); diff --git a/src/jalview/datamodel/Annotation.java b/src/jalview/datamodel/Annotation.java index dae81ef..0230e7a 100755 --- a/src/jalview/datamodel/Annotation.java +++ b/src/jalview/datamodel/Annotation.java @@ -168,7 +168,7 @@ public class Annotation { sb.append(","); } - if (value != Float.NaN) + if (!Float.isNaN(value)) { sb.append(value); } diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index 88cb46e..937826a 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -241,7 +241,7 @@ public class AnnotationFile && row.annotations[j].displayCharacter.length() > 0 && !row.annotations[j].displayCharacter .equals(" ")); hasGlyphs |= (row.annotations[j].secondaryStructure != 0 && row.annotations[j].secondaryStructure != ' '); - hasValues |= (row.annotations[j].value != Float.NaN); // NaNs can't + hasValues |= (!Float.isNaN(row.annotations[j].value)); // NaNs can't // be // rendered.. hasText |= (row.annotations[j].description != null && row.annotations[j].description @@ -331,7 +331,7 @@ public class AnnotationFile } if (hasValues) { - if (row.annotations[j].value != Float.NaN) + if (!Float.isNaN(row.annotations[j].value)) { text.append(comma + row.annotations[j].value); } diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 57f6384..fbe871b 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -1384,7 +1384,7 @@ public class FeaturesFile extends AlignFile out.append(next[j].end); out.append("\t"); out.append(next[j].type); - if (next[j].score != Float.NaN) + if (!Float.isNaN(next[j].score)) { out.append("\t"); out.append(next[j].score); diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java index 7c96d45..6d8ce5f 100644 --- a/src/jalview/io/SequenceAnnotationReport.java +++ b/src/jalview/io/SequenceAnnotationReport.java @@ -152,7 +152,7 @@ public class SequenceAnnotationReport } } // check score should be shown - if (feature.getScore() != Float.NaN) + if (!Float.isNaN(feature.getScore())) { float[][] rng = (minmax == null) ? null : ((float[][]) minmax .get(feature.getType())); diff --git a/src/jalview/io/vamsas/Sequencefeature.java b/src/jalview/io/vamsas/Sequencefeature.java index 3d598d2..d1af2cf 100644 --- a/src/jalview/io/vamsas/Sequencefeature.java +++ b/src/jalview/io/vamsas/Sequencefeature.java @@ -220,7 +220,7 @@ public class Sequencefeature extends Rangetype } } dsa.setGroup(feature.getFeatureGroup()); - if (feature.getScore() != Float.NaN) + if (!Float.isNaN(feature.getScore())) { Score fscore = new Score(); dsa.setScore(new Score[] diff --git a/src/jalview/renderer/seqfeatures/FeatureRenderer.java b/src/jalview/renderer/seqfeatures/FeatureRenderer.java index 7eda2f7..0f2a49c 100644 --- a/src/jalview/renderer/seqfeatures/FeatureRenderer.java +++ b/src/jalview/renderer/seqfeatures/FeatureRenderer.java @@ -349,7 +349,7 @@ public class FeatureRenderer extends else if (showFeature(sequenceFeature)) { if (av_isShowSeqFeatureHeight - && sequenceFeature.score != Float.NaN) + && !Float.isNaN(sequenceFeature.score)) { renderScoreFeature(g, seq, seq.findIndex(sequenceFeature.begin) - 1, diff --git a/src/jalview/schemes/GraduatedColor.java b/src/jalview/schemes/GraduatedColor.java index 4f1cb58..8a55f79 100644 --- a/src/jalview/schemes/GraduatedColor.java +++ b/src/jalview/schemes/GraduatedColor.java @@ -145,7 +145,7 @@ public class GraduatedColor public boolean isColored(SequenceFeature feature) { float val = feature.getScore(); - if (val == Float.NaN) + if (Float.isNaN(val)) { return true; } @@ -153,7 +153,7 @@ public class GraduatedColor { return true; } - if (this.thrsh == Float.NaN) + if (Float.isNaN(this.thrsh)) { return true; } @@ -211,7 +211,7 @@ public class GraduatedColor return getMaxColor(); } float scr = feature.getScore(); - if (scr == Float.NaN) + if (Float.isNaN(scr)) { return getMinColor(); } diff --git a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java index 674f3d1..19c6ca8 100644 --- a/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java +++ b/src/jalview/viewmodel/seqfeatures/FeatureRendererModel.java @@ -369,7 +369,7 @@ public abstract class FeatureRendererModel implements { allfeatures.add(features[index].getType()); } - if (features[index].score != Float.NaN) + if (!Float.isNaN(features[index].score)) { int nonpos = features[index].getBegin() >= 1 ? 0 : 1; float[][] mm = (float[][]) minmax.get(features[index].getType()); diff --git a/src/jalview/ws/jws2/AADisorderClient.java b/src/jalview/ws/jws2/AADisorderClient.java index dfb13a6..91be2e6 100644 --- a/src/jalview/ws/jws2/AADisorderClient.java +++ b/src/jalview/ws/jws2/AADisorderClient.java @@ -265,7 +265,7 @@ public class AADisorderClient extends JabawsCalcWorker implements + rn.from, base + rn.to, methodName); } dseq.addSequenceFeature(sf); - if (last != val && last != Float.NaN) + if (last != val && !Float.isNaN(last)) { fc.put(sf.getType(), sf); } -- 1.7.10.2