Exemplo n.º 1
0
  protected void doFilter() {
    try {
      final Set<String> allLabels = new HashSet<String>();
      m_ruleFilter.clear();
      for (int i = 0; i < m_textFields.size(); i++) {
        m_ruleFilter.addRules(RulebasedLabelFilter.formatRegExp(m_textFields.get(i).getText()));
      }
      m_activeLabels.clear();

      // filter with hilites
      Collection<L> filtered =
          m_ruleFilter.filterLabeling(
              KNIPGateway.regions().regions(m_labeling).getExistingLabels());

      // filter with rules
      if (m_showHilitedOnly || m_showUnhilitedOnly) {
        filtered = m_hiliteFilter.filterLabeling(filtered);
      }

      m_activeLabels.addAll(filtered);

      for (final L label : filtered) {
        allLabels.add(label.toString());
      }

      // As this is faster than checking all labels
      if ((m_ruleFilter.getRules().size() == 0) && !m_showHilitedOnly && !m_showUnhilitedOnly) {
        m_eventService.publish(new LabelPanelVisibleLabelsChgEvent(null, null));
      } else {
        m_eventService.publish(
            new LabelPanelVisibleLabelsChgEvent(
                allLabels, (Operator) (m_operatorBox).getSelectedItem()));
      }

      m_eventService.publish(new ImgRedrawEvent());

      // TODO fixme
      // Collections.sort(m_activeLabels);

      m_jLabelList.setListData(m_activeLabels);
    } catch (final NullPointerException e) {
      JOptionPane.showMessageDialog(
          null, "No image selected", "Error", JOptionPane.ERROR_MESSAGE, null);
      return;
    }
  }
Exemplo n.º 2
0
  private void fireSelectionChangedEvent() {
    if (m_listeners != null) {
      for (final ChangeListener listener : m_listeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
    m_selectedFileListBorder.setTitle("Selected files (" + m_selectedFileListModel.getSize() + ")");
    repaint();

    if (m_eventService != null) {
      m_eventService.publish(new FileChooserSelectedFilesChgEvent(getSelectedFiles()));
    }
  }
Exemplo n.º 3
0
  /**
   * Updates the selected files list after removing or adding files
   *
   * @param selectedFiles
   */
  public void update(final String[] selectedFiles) {
    // applying the model settings to the components
    if (selectedFiles.length > 0) {
      final File[] files = new File[selectedFiles.length];
      for (int i = 0; i < selectedFiles.length; i++) {
        files[i] = new File(selectedFiles[i]);
      }
      m_selectedFileListModel.removeAll();
      m_selectedFileListModel.addFiles(files, m_fileFilter);
    }

    if (m_eventService != null) {
      m_eventService.publish(new FileChooserSelectedFilesChgEvent(getSelectedFiles()));
    }
  }