コード例 #1
0
  @Override
  public void updateSelection(ViewState options) {
    NETWORK cyNetwork = cytoscapeUtils.getCurrentNetwork();
    if (cyNetwork == null) {
      return;
    }
    int totalEnabled = 0;
    NetworkGroupDetailPanel<NETWORK, NODE, EDGE> mostRecent = null;
    Group<?, ?> mostRecentGroup = options.getMostRecentGroup();
    for (NetworkGroupDetailPanel<NETWORK, NODE, EDGE> panel : dataModel) {
      Group<?, ?> group = panel.getSubject();
      boolean enabled = options.getGroupHighlighted(group);
      if (enabled) {
        totalEnabled++;
        panel.showDetails(true, 1);
      }

      panel.setItemEnabled(options.getEnabled(group));

      panel.setSelected(enabled);
      if (group.equals(mostRecentGroup)) {
        mostRecent = panel;
      }
      panel.getNetworkInfoPanel().updateSelection(options);
    }
    if (totalEnabled == 0) {
      cytoscapeUtils.setHighlighted(options, cyNetwork, false);
      options.clearHighlightedNetworks();
      mostRecent = null;
    }
    if (mostRecent != null) {
      ensureVisible(mostRecent);
      mostRecent.showDetails(true, 1);
    }
  }
コード例 #2
0
  @Override
  public void applyOptions(final ViewState options) {
    removeAll();
    if (selectionListener != null) {
      removeSelectionListener(selectionListener);
    }

    selectionListener =
        new SelectionListener<Group<?, ?>>() {
          public void selectionChanged(SelectionEvent<Group<?, ?>> event) {
            // Only handle deselections
            if (event.selected) {
              return;
            }

            for (Group<?, ?> group : event.items) {
              for (Network<?> network : group.getNetworks()) {
                options.setNetworkHighlighted(network, false);
              }
            }
            for (NetworkGroupDetailPanel<NETWORK, NODE, EDGE> panel : dataModel) {
              panel.getNetworkInfoPanel().updateSelection(options);
            }
          }
        };

    addSelectionListener(selectionListener);

    int index = 0;
    NETWORK network = cytoscapeUtils.getCurrentNetwork();
    for (Group<?, ?> group : options.getAllGroups()) {
      if (group.getWeight() == 0) {
        continue;
      }

      boolean enabledByDefault = options.getEnabled(group);
      NetworkGroupDetailPanel<NETWORK, NODE, EDGE> panel =
          new NetworkGroupDetailPanel<NETWORK, NODE, EDGE>(
              group, this, plugin, networkUtils, uiUtils, enabledByDefault, options);
      addDetailPanel(panel, index);
      index++;

      cytoscapeUtils.setHighlight(options, group, network, enabledByDefault);
    }
    add(
        uiUtils.createFillerPanel(),
        new GridBagConstraints(
            0,
            index,
            1,
            1,
            1,
            1,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    sort(1, true);
    invalidate();
  }