jf1 = new JFrame();
// Initialiser le device et le composant
initFirstDevice();
final AttributeImagePanel widget = new AttributeImagePanel.Builder(
m_deviceName, attributeName).setShowRoiInformationTable(true)
.jframe(jf1).build();
Sleeper.SECONDS.sleep(2);
// enable ROI table display
final JTable roiTable = (JTable) tth.findFirstComponent(
ARoiInfoTable.class, jf1);
Assert.assertTrue("ROI table should be visible", roiTable != null);
final TableModel roiData = roiTable.getModel();
Assert.assertTrue("ROI Table should be empty",
roiData.getRowCount() == 0);
Assert.assertTrue("ROI should contain 10 columns",
roiData.getColumnCount() == 10);
widget.addRoi("MyRoi1,Rectangle, 2, 60, 60, 80, 50,BLACK");
Assert.assertTrue("ROI Table should contain 1 ROI",
roiData.getRowCount() == 1);
// verify row 0 according to MyRoi1
int row = 0;
int col = 0;
Assert.assertTrue("[" + row + "," + col + "] should contain 'MyRoi1'",
roiData.getValueAt(col, row).equals("MyRoi1"));
col = 1;
Assert.assertTrue("[" + row + "," + col
+ "] should contain 'Rectangle'", roiData.getValueAt(row, col)
.equals("Rectangle"));
col = 4;
Assert.assertTrue("[" + row + "," + col + "] should contain 50",
roiData.getValueAt(row, col).equals(new Double(50)));
col = 5;
Assert.assertTrue("[" + row + "," + col + "] should contain 80",
roiData.getValueAt(row, col).equals(new Double(80)));
widget.addRoi("MyRoi3,Cross, 2, 72, 72, 90, 60,GREEN");
widget.addRoi("MyRoi2,Rectangle, 2, 70, 70, 90, 60,GREEN");
Assert.assertTrue("ROI Table should contain 3 ROIs in 4 lines",
roiTable.getModel().getRowCount() == 4);
// verify rows 0 & 1 according to MyRoi3
row = 1;
col = 0;
Assert.assertTrue("[" + row + "," + col + "] should contain 'MyRoi3'",
roiData.getValueAt(row, col).equals("MyRoi3"));
col = 1;
Assert.assertTrue("[" + row + "," + col
+ "] should contain 'Straight Line'",
roiData.getValueAt(row, col).equals("Straight Line"));
col = 4;
Assert.assertTrue("[" + row + "," + col + "] should contain 60",
roiData.getValueAt(row, col).equals(new Double(60)));
col = 5;
Assert.assertTrue("[" + row + "," + col + "] should contain 0", roiData
.getValueAt(row, col).equals(new Double(0)));
row = 2;
col = 0;
Assert.assertTrue("[" + row + "," + col + "] should be empty", roiData
.getValueAt(row, col).equals(""));
col = 1;
Assert.assertTrue("[" + row + "," + col
+ "] should contain 'Straight Line'",
roiData.getValueAt(row, col).equals("Straight Line"));
col = 4;
Assert.assertTrue("[" + row + "," + col + "] should contain 0", roiData
.getValueAt(row, col).equals(new Double(0)));
col = 5;
Assert.assertTrue("[" + row + "," + col + "] should contain 90",
roiData.getValueAt(row, col).equals(new Double(90)));
// try to remove MyRoi3
widget.addRoi("MyRoi3,None, 2, 72, 72, 90, 60,GREEN");
col = 0;
row = 0;
Assert.assertTrue("Cannot remove ROI", roiTable.getModel()
.getRowCount() == 2);
Assert.assertTrue("[" + row + "," + col + "] should contain 'MyRoi1'",
roiData.getValueAt(row, col).equals("MyRoi1"));
row = 1;
Assert.assertTrue("[" + row + "," + col + "] should contain 'MyRoi2'",
roiData.getValueAt(row, col).equals("MyRoi2"));
// test du SetVisible
widget.setVisible(false);
Assert.assertTrue("widget should not be visible", !roiTable.isShowing());
// clean
widget.stop();
jf1.dispose();
}