}
// Open Image
else if (incomingEvent instanceof EventOpenImage){
EventOpenImage event = (EventOpenImage) incomingEvent;
ImageModel image = event.getImage();
if (image == null || image.isAvailable()){
mainFrame.setEnabled(false);
if (currentImage == null || !currentImage.equals(image)) {
currentImage = image;
// Cache BufferedImage
if (image != null)
MainController.getInstance().getBufferedImageCache().cacheImage(image.getFile().getPath());
// Update Image
mainFrame.browserTab.getImagePanel().setImage(image);
// Update AnnotationTable and selected region
mainFrame.browserTab.getAnnotationPanel().setImage(currentImage);
// Make sure that the right folder is opened.
if (currentImage!=null)
dispatchEvent(new EventOpenFolder(currentImage.getFolder()));
// Make sure that the right thumbnail is selected
mainFrame.browserTab.getThumbnailPanel().setSelectedImage(image);
// Update Buttons
dispatchEvent(new EventUpdateMenuBar(currentImage != null));
}
mainFrame.setEnabled(true);
}
else {
new InfoDialog(mainFrame," Image "+image.getFile().getPath()+" not available!");
}
}
// Delete Person
else if (incomingEvent instanceof EventDeletePerson){
EventDeletePerson event = (EventDeletePerson) incomingEvent;
String[] options = { "Ok", "Cancel"};
int n = JOptionPane.showOptionDialog( mainFrame,
"Remove "+event.getName()+" from database?",
"Delete Person",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, options,options[0] );
if ( n == JOptionPane.YES_OPTION )
{
MainController.getInstance().getFaceDB().deleteAnnotation(event.getName());
mainFrame.browserTab.getAnnotationPanel().updateFromModel();
mainFrame.browserTab.getImagePanel().getClassificationPanel().updateFromModel();
mainFrame.faceDBTab.getPersonPanel().updateFromModel();
}
}
// Set the classification of a region
else if (incomingEvent instanceof EventClassifyRegion){
EventClassifyRegion event = (EventClassifyRegion) incomingEvent;
// Save classification in database
MainController.getInstance().getFaceDB().put(event.getRegion(),event.getAnnotation());
// Update view
mainFrame.browserTab.getAnnotationPanel().repaint();
mainFrame.browserTab.getImagePanel().getClassificationPanel().repaint();
}
// Rename a person
else if (incomingEvent instanceof EventRenamePerson){
EventRenamePerson event = (EventRenamePerson) incomingEvent;
MainController.getInstance().getFaceDB().renameAnnotation(event.getOldName(), event.getNewName());
mainFrame.browserTab.getAnnotationPanel().updateFromModel();
mainFrame.browserTab.getImagePanel().getClassificationPanel().updateFromModel();
mainFrame.faceDBTab.getPersonPanel().updateFromModel();
}
// Change training flag of region
else if (incomingEvent instanceof EventModifyTrainingData){
EventModifyTrainingData event = (EventModifyTrainingData) incomingEvent;
event.getRegion().setUsedForTraining(event.getValue());
}
// Add a new person to the database
else if (incomingEvent instanceof EventAddKnownPerson){
EventAddKnownPerson event = (EventAddKnownPerson) incomingEvent;
MainController.getInstance().getFaceDB().put(null, event.getName());
}
// Selected region changed
else if (incomingEvent instanceof EventRegionSelectionChanged){
EventRegionSelectionChanged event = (EventRegionSelectionChanged) incomingEvent;
Region newRegion = event.getRegion();
if (newRegion != null){
ImageModel image = new ImageModel(newRegion.getImage());
if (currentImage == null || !currentImage.equals(image))
{
dispatchEvent(new EventOpenImage(image));
if (currentImage == null || !currentImage.equals(image))