@Test
 public void testEquivalence() {
   PositiveFloat a = new PositiveFloat(0.1);
   PositiveFloat b = new PositiveFloat(0.1);
   PositiveFloat c = new PositiveFloat(2.0);
   Double d = new Double(0.1);
   Double e = new Double(2.0);
   Double f = new Double(3.0);
   assertFalse(a == b);
   assertFalse(a == c);
   assertTrue(a.equals(b));
   assertFalse(a.equals(c));
   assertTrue(a.equals(d));
   assertFalse(a.equals(e));
   assertTrue(c.equals(e));
   assertFalse(a.equals(f));
 }
Beispiel #2
0
  /** Retrieves calibration for X,Y,Z,T * */
  private float[] getCalibration(final IFormatReader r, final int[] dimensions) {
    float[] calibration = new float[dimensions.length];
    for (int i = 0; i < calibration.length; ++i) calibration[i] = 1;

    try {
      final String dimOrder = r.getDimensionOrder().toUpperCase();
      final MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();

      PositiveFloat cal;

      final int posX = dimOrder.indexOf('X');
      cal = retrieve.getPixelsPhysicalSizeX(0);
      if (posX >= 0 && posX < calibration.length && cal != null && cal.getValue() != 0)
        calibration[posX] = cal.getValue().floatValue();

      final int posY = dimOrder.indexOf('Y');
      cal = retrieve.getPixelsPhysicalSizeY(0);
      if (posY >= 0 && posY < calibration.length && cal != null && cal.getValue() != 0)
        calibration[posY] = cal.getValue().floatValue();

      final int posZ = dimOrder.indexOf('Z');
      cal = retrieve.getPixelsPhysicalSizeZ(0);
      if (posZ >= 0 && posZ < calibration.length && cal != null && cal.getValue() != 0)
        calibration[posZ] = cal.getValue().floatValue();

      final int posT = dimOrder.indexOf('T');
      retrieve.getPixelsTimeIncrement(0);
      Double cal1 = retrieve.getPixelsTimeIncrement(0);
      if (posT >= 0 && posT < calibration.length && cal1 != null && cal1.floatValue() != 0)
        calibration[posT] = cal1.floatValue();
    } catch (Exception e) {
      // somehow an error occured reading the calibration
    }

    return calibration;
  }