Changeset 6149


Ignore:
Timestamp:
04/20/10 12:09:05 (10 years ago)
Author:
melissa
Message:

Added ROI population test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/ome-xml/test/ome/xml/utests/InOut201004Test.java

    r6147 r6149  
    6161import ome.xml.r201004.Pixels; 
    6262import ome.xml.r201004.Plate; 
     63import ome.xml.r201004.Rectangle; 
     64import ome.xml.r201004.ROI; 
     65import ome.xml.r201004.Shape; 
     66import ome.xml.r201004.Union; 
    6367import ome.xml.r201004.Well; 
    6468import ome.xml.r201004.enums.DimensionOrder; 
     
    96100  private static String PLATE_ID = "Plate:0"; 
    97101 
     102  private static String ROI_ID = "ROI:5"; 
     103 
    98104  private static DimensionOrder dimensionOrder = DimensionOrder.XYZCT; 
    99105 
     
    117123 
    118124  private static final NamingConvention WELL_COL = NamingConvention.NUMBER; 
     125 
     126  private static final Double RECTANGLE_X = 10.0; 
     127 
     128  private static final Double RECTANGLE_Y = 20.0; 
     129 
     130  private static final Double RECTANGLE_WIDTH = 128.0; 
     131 
     132  private static final Double RECTANGLE_HEIGHT = 256.0; 
    119133 
    120134  /** XML namespace. */ 
     
    149163    ome.addPlate(makePlate()); 
    150164    ome.addInstrument(makeInstrument()); 
     165    ome.addROI(makeROI()); 
    151166    // Produce a valid OME DOM element hierarchy 
    152167    Element root = ome.asXMLElement(document); 
     
    158173    // Produce string XML 
    159174    asString = asString(); 
     175    /* debug */ System.err.println(asString); 
    160176    // Read string XML in as a DOM tree and parse into the object hierarchy 
    161177    ome = OME.fromXMLElement(document.getDocumentElement()); 
     
    229245      } 
    230246    } 
     247  } 
     248 
     249  @Test(dependsOnMethods={"testValidOMENode"}) 
     250  public void testValidROINode() { 
     251    ROI roi = ome.getROI(0); 
     252    assertNotNull(roi); 
     253    assertEquals(ROI_ID, roi.getID()); 
     254 
     255    Union shapeUnion = roi.getUnion(); 
     256    assertNotNull(shapeUnion); 
     257    Shape s = shapeUnion.getShape(0); 
     258    assertNotNull(s); 
     259 
     260    Rectangle rect = s.getRectangle(); 
     261    assertNotNull(rect); 
     262    assertEquals(RECTANGLE_X, rect.getX()); 
     263    assertEquals(RECTANGLE_Y, rect.getY()); 
     264    assertEquals(RECTANGLE_WIDTH, rect.getWidth()); 
     265    assertEquals(RECTANGLE_HEIGHT, rect.getHeight()); 
     266 
     267    assertNull(s.getMask()); 
     268    assertNull(s.getEllipse()); 
     269    assertNull(s.getPoint()); 
     270    assertNull(s.getPolyline()); 
     271    assertNull(s.getLine()); 
     272    assertNull(s.getPath()); 
     273    assertNull(s.getText()); 
    231274  } 
    232275 
     
    293336  } 
    294337 
     338  private ROI makeROI() { 
     339    ROI roi = new ROI(); 
     340    roi.setID(ROI_ID); 
     341    Union shapeUnion = new Union(); 
     342    Shape s = new Shape(); 
     343    Rectangle rect = new Rectangle(); 
     344    rect.setX(RECTANGLE_X); 
     345    rect.setY(RECTANGLE_Y); 
     346    rect.setWidth(RECTANGLE_WIDTH); 
     347    rect.setHeight(RECTANGLE_HEIGHT); 
     348 
     349    s.setRectangle(rect); 
     350    shapeUnion.addShape(s); 
     351    roi.setUnion(shapeUnion); 
     352 
     353    return roi; 
     354  } 
     355 
    295356  private String asString() throws TransformerException { 
    296357    TransformerFactory transformerFactory = 
Note: See TracChangeset for help on using the changeset viewer.