Package de.offis.faint.gui.events

Examples of de.offis.faint.gui.events.EventShowFacesOfPerson


        if (!e.getValueIsAdjusting()){
          String person = null;
          if (table.getSelectedRow() != -1){
            person = (String) table.getValueAt(table.getSelectedRow(),0);
          }
          mainFrame.eventDispatcher.dispatchEvent(new EventShowFacesOfPerson(person));
       
      }
View Full Code Here


        mainFrame.setActiveTAB(event.getTab());
    }
     
        // Update table in faceDB tab
    else if (incomingEvent instanceof EventShowFacesOfPerson){
      EventShowFacesOfPerson event = (EventShowFacesOfPerson) incomingEvent;
      mainFrame.faceDBTab.getFacePanel().setSelectedPerson(event.getPerson());   
    }
   
        // Open Folder
    else if (incomingEvent instanceof EventOpenFolder){
     
      mainFrame.setEnabled(false);

      EventOpenFolder event = (EventOpenFolder) incomingEvent;
      File newFolder = event.getFolder();
     
      if (currentFolder == null || !newFolder.equals(currentFolder))
      {
        currentFolder = newFolder;
       
        // Show thumbnails
        mainFrame.browserTab.getThumbnailPanel().setFolder(newFolder);
       
        // Clear currentImage if it is from another folder...
        if (!(currentImage == null || currentImage.getFolder().equals(newFolder)))
          dispatchEvent(new EventOpenImage(null));
      }
     
      // Make sure browser tab is active
      dispatchEvent(new EventShowTab(MainFrame.TAB.BROWSER));
     
      mainFrame.setEnabled(true);
    }
   
    // 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))
            newRegion = null;
        }
      }
     
      if (currentRegion == null || !currentRegion.equals(newRegion)){
        currentRegion = newRegion;
        mainFrame.browserTab.getImagePanel().setSelectedRegion(newRegion);
        mainFrame.browserTab.getAnnotationPanel().setSelectedRegion(newRegion);
      }
     
      // Make sure browser tab is active
      if (currentRegion != null)
        this.dispatchEvent(new EventShowTab(MainFrame.TAB.BROWSER));
    }
   
    // AnnotationPanel has to be updated
    else if (incomingEvent instanceof EventUpdateAnnotationPanel) {
      mainFrame.browserTab.getAnnotationPanel().updateFromModel();     
    }
   
    // Delete selected region
    else if (incomingEvent instanceof EventDeleteRegion) {
      EventDeleteRegion event = (EventDeleteRegion) incomingEvent;
     
      // Delete region from database
      MainController.getInstance().getFaceDB().deleteRegion(event.getRegion());
     
      // Update view
      if (event.getRegion().getImage().equals(currentImage.getFile().getAbsolutePath())){
       
        mainFrame.browserTab.getAnnotationPanel().updateFromModel();
        mainFrame.browserTab.getImagePanel().repaint();
      }     
    }

    // Run Face Detection on current image
    else if (incomingEvent instanceof EventDetectFacesOnCurrentImage) {
     
      DetectionDialog dialog = mainFrame.browserTab.getDetectionDialog();
     
      dialog.performDetection(this.currentImage);
    }
   
    // Run Face Recognition on selected region
    else if (incomingEvent instanceof EventRecognizeFace) {
      EventRecognizeFace event = (EventRecognizeFace) incomingEvent;
     
      mainFrame.setEnabled(false);
     
      HashMap<String, Integer> recognitionResult = (MainController.getInstance().recognizeFace(event.getRegion()));
     
      if (this.currentRegion == event.getRegion())
        mainFrame.browserTab.getImagePanel().getClassificationPanel().updateRecognitionData(recognitionResult);
     
      mainFrame.setEnabled(true);
    }
   
    // Change minimum size of scan window
    else if (incomingEvent instanceof EventChangeScanWindowSize) {
        EventChangeScanWindowSize event = (EventChangeScanWindowSize) incomingEvent;
      MainController.getInstance().setScanWindowSize(event.getNewSize());
      mainFrame.browserTab.getImagePanel().repaint();
    }
   
    // Update menu bar
    else if (incomingEvent instanceof EventUpdateMenuBar) {
      EventUpdateMenuBar event = (EventUpdateMenuBar) incomingEvent;
      mainFrame.browserTab.getMenuBar().update(event.isDetectionAllowed());
    }
   
    // Shut down application and save settings
    else if (incomingEvent instanceof EventShutdownMainFrame) {
        MainController.getInstance().getDetectionHotSpot().serializeContent();
View Full Code Here

TOP

Related Classes of de.offis.faint.gui.events.EventShowFacesOfPerson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.