Exemplo n.º 1
0
  /** @param e */
  @EventListener
  public void onLabelingUpdated(final LabelingWithMetadataChgEvent<L> e) {
    m_labeling = e.getData();
    m_regions = KNIPGateway.regions().regions(m_labeling);

    m_activeLabels.clear();
    for (final L label : KNIPGateway.regions().regions(m_labeling).getExistingLabels()) {
      if (m_ruleFilter.isValid(label)) {
        m_activeLabels.add(label);
      }
    }

    // TODO Collections.sort(m_activeLabels);
    m_jLabelList.setListData(m_activeLabels);
  }
Exemplo n.º 2
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;
    }
  }