X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.history%2Fsrc%2Forg%2Fsimantics%2Fhistory%2Futil%2Fsubscription%2FSamplingFormat.java;h=1334cae5320b522c1ba623e293794a9b78342a87;hp=2db7ed3a6349f213fb40b1cc27c20d4eb7d5bf02;hb=f3617565a8ffe49d63016f0c1d78e0d4282214b0;hpb=f62bab9b78e60b94e055d51db98a03141415323e diff --git a/bundles/org.simantics.history/src/org/simantics/history/util/subscription/SamplingFormat.java b/bundles/org.simantics.history/src/org/simantics/history/util/subscription/SamplingFormat.java index 2db7ed3a6..1334cae53 100644 --- a/bundles/org.simantics.history/src/org/simantics/history/util/subscription/SamplingFormat.java +++ b/bundles/org.simantics.history/src/org/simantics/history/util/subscription/SamplingFormat.java @@ -38,19 +38,23 @@ import org.simantics.databoard.util.Range; public class SamplingFormat extends Bean { public static final SamplingFormat[] EMPTY = new SamplingFormat[0]; - + + public static int compareSamplingInterval(double i1, double i2) { + boolean nan1 = Double.isNaN( i1 ); + boolean nan2 = Double.isNaN( i2 ); + + if ( nan1 && nan2 ) return 0; + if ( nan1 && !nan2) return -1; + if ( !nan1 && nan2) return 1; + return i1 == i2 ? 0 : ( i1 < i2 ? -1 : 1 ); + } + public final static Comparator INTERVAL_COMPARATOR = new Comparator() { @Override public int compare(Bean o1, Bean o2) { double i1 = (Double) o1.getFieldUnchecked("interval"); double i2 = (Double) o2.getFieldUnchecked("interval"); - boolean nan1 = Double.isNaN( i1 ); - boolean nan2 = Double.isNaN( i2 ); - - if ( nan1 && nan2 ) return 0; - if ( nan1 && !nan2) return -1; - if ( !nan1 && nan2) return 1; - return i1 == i2 ? 0 : ( i1 < i2 ? -1 : 1 ); + return compareSamplingInterval(i1, i2); } };