testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final TangoKey key1 = new TangoKey();
TangoKeyTool.registerAttribute(key1, "tango/tangotest/titan/double_image");
final TangoKey key2 = new TangoKey();
TangoKeyTool.registerAttribute(key2, "tango/tangotest/titan/long_image_ro");
final ImageViewer viewer = new ImageViewer();
viewer.setApplicationId(CometeUtils.generateIdForClass(ImageConnexionTest.class));
final NumberMatrixBox box = new NumberMatrixBox();
box.setCleanWidgetOnDisconnect(viewer, false);
box.connectWidget(viewer, key1);
final JCheckBox keySelectionBox = new JCheckBox("Use 1st key");
keySelectionBox.setSelected(true);
keySelectionBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
box.disconnectWidgetFromAll(viewer);
box.connectWidget(viewer, keySelectionBox.isSelected() ? key1 : key2);
}
});
}
});
final JCheckBox cleanCheckBox = new JCheckBox("Clean on disconnect");
cleanCheckBox.setSelected(box.isCleanWidgetOnDisconnect(viewer));
cleanCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
box.setCleanWidgetOnDisconnect(viewer, cleanCheckBox.isSelected());
}
});
CometeRoi cometeRoi = new CometeRoi("testRoi", RoiShape.LINE, 10, 15, 63, 100, 100, CometeColor.GREEN);
viewer.addRoi(cometeRoi);
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(cleanCheckBox, BorderLayout.NORTH);
mainPanel.add(viewer, BorderLayout.CENTER);
mainPanel.add(keySelectionBox, BorderLayout.SOUTH);