@Test
 public void testPointROIBeanEqual() throws Exception {
   ROIBean rbean = new PointROIBean();
   ((PointROIBean) rbean).setName("point");
   ((PointROIBean) rbean).setStartPoint(startPoint);
   ((PointROIBean) rbean).setType("PointROI");
   PointROI proi = (PointROI) ROIBeanFactory.decapsulate(rbean);
   PointROIBean resultBean = (PointROIBean) ROIBeanFactory.encapsulate(proi);
   assertEquals(rbean, resultBean);
 }
 @Test
 public void testLinearROIBeanEqual() throws Exception {
   ROIBean rbean = new LinearROIBean();
   ((LinearROIBean) rbean).setName("line");
   ((LinearROIBean) rbean).setStartPoint(startPoint);
   ((LinearROIBean) rbean).setType("LinearROI");
   ((LinearROIBean) rbean).setEndPoint(endPoint);
   LinearROI lroi = (LinearROI) ROIBeanFactory.decapsulate(rbean);
   LinearROIBean resultBean = (LinearROIBean) ROIBeanFactory.encapsulate(lroi);
   assertEquals(rbean, resultBean);
 }
 @Test
 public void testCircularROIBeanEqual() throws Exception {
   // CircularROI
   double radius = 100;
   ROIBean rbean = new CircularROIBean();
   ((CircularROIBean) rbean).setName("circle");
   ((CircularROIBean) rbean).setStartPoint(startPoint);
   ((CircularROIBean) rbean).setType("CircularROI");
   ((CircularROIBean) rbean).setRadius(radius);
   CircularROI croi = (CircularROI) ROIBeanFactory.decapsulate(rbean);
   CircularROIBean resultBean = (CircularROIBean) ROIBeanFactory.encapsulate(croi);
   assertEquals(rbean, resultBean);
 }
 @Test
 public void testRectangularROIBeanEqual() throws Exception {
   ROIBean rbean = new RectangularROIBean();
   ((RectangularROIBean) rbean).setName("rectangle");
   ((RectangularROIBean) rbean).setStartPoint(startPoint);
   ((RectangularROIBean) rbean).setType("RectangularROI");
   ((RectangularROIBean) rbean).setLengths(lengths);
   ((RectangularROIBean) rbean).setEndPoint(endPoint);
   ((RectangularROIBean) rbean).setAngle(0);
   RectangularROI rroi = (RectangularROI) ROIBeanFactory.decapsulate(rbean);
   RectangularROIBean resultBean = (RectangularROIBean) ROIBeanFactory.encapsulate(rroi);
   assertEquals(rbean, resultBean);
 }
 @Test
 public void testSectorROIBeanEqual() throws Exception {
   // SectorROI
   double[] radii = {30, 50}, angles = {6, 9};
   double dpp = 20;
   int symmetry = 5;
   ROIBean rbean = new SectorROIBean();
   ((SectorROIBean) rbean).setAngles(angles);
   ((SectorROIBean) rbean).setStartPoint(startPoint);
   ((SectorROIBean) rbean).setRadii(radii);
   ((SectorROIBean) rbean).setDpp(dpp);
   ((SectorROIBean) rbean).setSymmetry(symmetry);
   SectorROI sroi = (SectorROI) ROIBeanFactory.decapsulate(rbean);
   SectorROIBean resultBean = (SectorROIBean) ROIBeanFactory.encapsulate(sroi);
   assertEquals(rbean, resultBean);
 }
 @Test
 public void testCircularROIBeanConversionToCircularROI() throws Exception {
   // CircularROI
   double radius = 100;
   ROIBean rbean = new CircularROIBean();
   ((CircularROIBean) rbean).setName("circle");
   ((CircularROIBean) rbean).setStartPoint(startPoint);
   ((CircularROIBean) rbean).setType("CircularROI");
   ((CircularROIBean) rbean).setRadius(radius);
   CircularROI croi = (CircularROI) ROIBeanFactory.decapsulate(rbean);
   assertArrayEquals(startPoint, croi.getPoint(), 0);
   assertEquals(radius, croi.getRadius(), 0);
 }
 @Test
 public void testRectangularROIBeanConversionToRectangularROI() throws Exception {
   // RectangularROI
   ROIBean rbean = new RectangularROIBean();
   ((RectangularROIBean) rbean).setName("rectangle");
   ((RectangularROIBean) rbean).setStartPoint(startPoint);
   ((RectangularROIBean) rbean).setType("RectangularROI");
   ((RectangularROIBean) rbean).setLengths(lengths);
   ((RectangularROIBean) rbean).setAngle(0);
   RectangularROI rroi = (RectangularROI) ROIBeanFactory.decapsulate(rbean);
   assertArrayEquals(startPoint, rroi.getPoint(), 0);
   assertArrayEquals(lengths, rroi.getLengths(), 0);
 }
 @Test
 public void testPolylineROIBeanConversionToPolylineROI() throws Exception {
   // PolylineROI
   ROIBean rbean = new PolylineROIBean();
   double[] point0 = {102, 102}, point1 = {105, 105};
   List<double[]> points = new ArrayList<double[]>();
   // points.add(startPoint);
   points.add(point0);
   points.add(point1);
   ((PolylineROIBean) rbean).setName("Polyline");
   ((PolylineROIBean) rbean).setPoints(points);
   ((PolylineROIBean) rbean).setStartPoint(startPoint);
   ((PolylineROIBean) rbean).setType("PolylineROI");
   PolylineROI proi = (PolylineROI) ROIBeanFactory.decapsulate(rbean);
   assertArrayEquals(startPoint, proi.getPoint(), 0);
   assertArrayEquals(point0, proi.getPoint(1).getPoint(), 0);
   assertArrayEquals(point1, proi.getPoint(2).getPoint(), 0);
 }
  @Test
  public void testSectorROIBeanConversionToSectorROI() throws Exception {
    // SectorROI
    double[] radii = {30, 50}, angles = {6, 9};
    double dpp = 20;
    int symmetry = 5;
    ROIBean rbean = new SectorROIBean();
    ((SectorROIBean) rbean).setAngles(angles);
    ((SectorROIBean) rbean).setStartPoint(startPoint);
    ((SectorROIBean) rbean).setRadii(radii);
    ((SectorROIBean) rbean).setDpp(dpp);
    ((SectorROIBean) rbean).setSymmetry(symmetry);

    SectorROI sroi = (SectorROI) ROIBeanFactory.decapsulate(rbean);
    assertArrayEquals(startPoint, sroi.getPoint(), 0);
    assertArrayEquals(radii, sroi.getRadii(), 0);
    assertArrayEquals(angles, sroi.getAngles(), 0);
    assertEquals(dpp, sroi.getDpp(), 0);
    assertEquals(symmetry, sroi.getSymmetry());
  }