]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.history/src/org/simantics/history/util/subscription/SamplingFormat.java
Added another sampling method to HistorySampler
[simantics/platform.git] / bundles / org.simantics.history / src / org / simantics / history / util / subscription / SamplingFormat.java
index 2db7ed3a6349f213fb40b1cc27c20d4eb7d5bf02..1334cae5320b522c1ba623e293794a9b78342a87 100644 (file)
@@ -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<Bean> INTERVAL_COMPARATOR = new Comparator<Bean>() {
                @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);
                }
        };