Search in sources :

Example 1 with Rectangle

use of ome.xml.model.Rectangle in project bioformats by openmicroscopy.

the class ObjectBasedOMEModelMock method makeROI.

private ROI makeROI() {
    ROI roi = new ROI();
    roi.setID(InOutCurrentTest.ROI_ID);
    CommentAnnotation roiAnnotation = new CommentAnnotation();
    roiAnnotation.setID(InOutCurrentTest.ROI_ANNOTATION_ID);
    roiAnnotation.setValue(InOutCurrentTest.ROI_ANNOTATION_VALUE);
    roiAnnotation.setNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE);
    roi.linkAnnotation(roiAnnotation);
    annotations.addCommentAnnotation(roiAnnotation);
    Union shapeUnion = new Union();
    Rectangle rect = new Rectangle();
    rect.setID(InOutCurrentTest.SHAPE_ID);
    rect.setX(InOutCurrentTest.RECTANGLE_X);
    rect.setY(InOutCurrentTest.RECTANGLE_Y);
    rect.setWidth(InOutCurrentTest.RECTANGLE_WIDTH);
    rect.setHeight(InOutCurrentTest.RECTANGLE_HEIGHT);
    shapeUnion.addShape(rect);
    roi.setUnion(shapeUnion);
    return roi;
}
Also used : CommentAnnotation(ome.xml.model.CommentAnnotation) Rectangle(ome.xml.model.Rectangle) ROI(ome.xml.model.ROI) Union(ome.xml.model.Union)

Example 2 with Rectangle

use of ome.xml.model.Rectangle in project bioformats by openmicroscopy.

the class PrintROIs method printShape.

/**
 * Print the given shape.
 */
public static void printShape(Shape shapeObject) {
    if (shapeObject instanceof Ellipse) {
        Ellipse ellipse = (Ellipse) shapeObject;
        System.out.println("    Ellipse:");
        System.out.println("      Text = " + ellipse.getText());
        System.out.println("      X = " + ellipse.getX());
        System.out.println("      Y = " + ellipse.getY());
        System.out.println("      Radius (X) = " + ellipse.getRadiusX());
        System.out.println("      Radius (Y) = " + ellipse.getRadiusY());
    } else if (shapeObject instanceof Line) {
        Line line = (Line) shapeObject;
        System.out.println("    Line:");
        System.out.println("      Text = " + line.getText());
        System.out.println("      X1 = " + line.getX1());
        System.out.println("      Y1 = " + line.getY1());
        System.out.println("      X2 = " + line.getX2());
        System.out.println("      Y2 = " + line.getY2());
    } else if (shapeObject instanceof Point) {
        Point point = (Point) shapeObject;
        System.out.println("    Point:");
        System.out.println("      Text = " + point.getText());
        System.out.println("      X = " + point.getX());
        System.out.println("      Y = " + point.getY());
    } else if (shapeObject instanceof Polyline) {
        Polyline polyline = (Polyline) shapeObject;
        System.out.println("    Polyline:");
        System.out.println("      Text = " + polyline.getText());
        System.out.println("      Points = " + polyline.getPoints());
    } else if (shapeObject instanceof Polygon) {
        Polygon polygon = (Polygon) shapeObject;
        System.out.println("    Polygon:");
        System.out.println("      Text = " + polygon.getText());
        System.out.println("      Points = " + polygon.getPoints());
    } else if (shapeObject instanceof Rectangle) {
        Rectangle rectangle = (Rectangle) shapeObject;
        System.out.println("    Rectangle:");
        System.out.println("      Text = " + rectangle.getText());
    } else if (shapeObject instanceof Mask) {
        Mask mask = (Mask) shapeObject;
        System.out.println("    Mask:");
        System.out.println("      Text = " + mask.getText());
        System.out.println("      X = " + mask.getX());
        System.out.println("      Y = " + mask.getY());
        System.out.println("      Width = " + mask.getWidth());
        System.out.println("      Height = " + mask.getHeight());
    } else if (shapeObject instanceof Label) {
        Label text = (Label) shapeObject;
        System.out.println("    Label:");
        System.out.println("      Text = " + text.getText());
        System.out.println("      X = " + text.getX());
        System.out.println("      Y = " + text.getY());
    }
}
Also used : Line(ome.xml.model.Line) Ellipse(ome.xml.model.Ellipse) Polyline(ome.xml.model.Polyline) Rectangle(ome.xml.model.Rectangle) Mask(ome.xml.model.Mask) Label(ome.xml.model.Label) Point(ome.xml.model.Point) Polygon(ome.xml.model.Polygon)

Example 3 with Rectangle

use of ome.xml.model.Rectangle in project bioformats by openmicroscopy.

the class Schema2011_06_File_Upgrade_Test method testShape2.

@Test(enabled = false, groups = { "11-06-u-roi" }, dependsOnMethods = { "testROI2AndUnion" })
public void testShape2() {
    Assert.assertNotNull(union2);
    shape2 = union2.getShape(0);
    Assert.assertEquals(Rectangle.class.getName(), shape2.getClass().getName());
    Rectangle rectangle2 = (Rectangle) shape2;
    Assert.assertEquals(ref.ROI2Shape2FillRule, rectangle2.getFillRule());
    Assert.assertEquals(ref.ROI2Shape2Label, rectangle2.getText());
    Assert.assertEquals(ref.ROI2Shape2RectangleX, rectangle2.getX());
    Assert.assertEquals(ref.ROI2Shape2RectangleY, rectangle2.getY());
    Assert.assertEquals(ref.ROI2Shape2RectangleWidth, rectangle2.getWidth());
    Assert.assertEquals(ref.ROI2Shape2RectangleHeight, rectangle2.getHeight());
    Assert.assertNotNull(rectangle2.getTransform());
    Assert.assertEquals(ref.ROI2Shape2TransformA00, rectangle2.getTransform().getA00());
    Assert.assertEquals(ref.ROI2Shape2TransformA01, rectangle2.getTransform().getA01());
    Assert.assertEquals(ref.ROI2Shape2TransformA02, rectangle2.getTransform().getA02());
    Assert.assertEquals(ref.ROI2Shape2TransformA10, rectangle2.getTransform().getA10());
    Assert.assertEquals(ref.ROI2Shape2TransformA11, rectangle2.getTransform().getA11());
    Assert.assertEquals(ref.ROI2Shape2TransformA12, rectangle2.getTransform().getA12());
}
Also used : Rectangle(ome.xml.model.Rectangle) Test(org.testng.annotations.Test)

Example 4 with Rectangle

use of ome.xml.model.Rectangle in project bioformats by openmicroscopy.

the class InOutCurrentTest method testValidROINode.

@Test(dependsOnMethods = { "testValidOMENode" })
public void testValidROINode() {
    ROI roi = ome.getROI(0);
    assertNotNull(roi);
    assertEquals(ROI_ID, roi.getID());
    Union shapeUnion = roi.getUnion();
    assertNotNull(shapeUnion);
    assertEquals(1, shapeUnion.sizeOfShapeList());
    Shape s = shapeUnion.getShape(0);
    assertNotNull(s);
    assertEquals(SHAPE_ID, s.getID());
    assertTrue(s instanceof Rectangle);
    Rectangle rect = (Rectangle) s;
    assertEquals(RECTANGLE_X, rect.getX());
    assertEquals(RECTANGLE_Y, rect.getY());
    assertEquals(RECTANGLE_WIDTH, rect.getWidth());
    assertEquals(RECTANGLE_HEIGHT, rect.getHeight());
}
Also used : Shape(ome.xml.model.Shape) Rectangle(ome.xml.model.Rectangle) ROI(ome.xml.model.ROI) Union(ome.xml.model.Union) Test(org.testng.annotations.Test)

Aggregations

Rectangle (ome.xml.model.Rectangle)4 ROI (ome.xml.model.ROI)2 Union (ome.xml.model.Union)2 Test (org.testng.annotations.Test)2 CommentAnnotation (ome.xml.model.CommentAnnotation)1 Ellipse (ome.xml.model.Ellipse)1 Label (ome.xml.model.Label)1 Line (ome.xml.model.Line)1 Mask (ome.xml.model.Mask)1 Point (ome.xml.model.Point)1 Polygon (ome.xml.model.Polygon)1 Polyline (ome.xml.model.Polyline)1 Shape (ome.xml.model.Shape)1