/** Constructor */
  @SuppressWarnings("serial")
  public SubnetExtraction(Frame aFrame, GenericElement item) {

    super(aFrame);
    item_ = item;

    // Set model of "subnet size" spinner
    SpinnerNumberModel model = new SpinnerNumberModel();
    model.setMinimum(1);
    model.setStepSize(1);
    int maxSize =
        (item instanceof StructureElement)
            ? ((StructureElement) item).getNetwork().getSize()
            : ((DynamicalModelElement) item).getGeneNetwork().getSize();
    model.setMaximum(maxSize);
    int effectiveSize = (10 <= maxSize) ? 10 : maxSize;
    model.setValue(effectiveSize);
    subnetSize_.setModel(model);

    // Set model of "number of subnets" spinner
    model = new SpinnerNumberModel();
    model.setMinimum(1);
    model.setMaximum(20);
    model.setStepSize(1);
    model.setValue(10);
    numberSubnets_.setModel(model);

    // Set model of "random among top" spinner
    model = new SpinnerNumberModel();
    model.setMinimum(1);
    model.setMaximum(100);
    model.setStepSize(1);
    model.setValue(20);
    randomAmongTopSpinner_.setModel(model);

    // Set model of "From strongly connected components"
    model = new SpinnerNumberModel();
    model.setMinimum(1);
    model.setMaximum(maxSize);
    model.setStepSize(1);
    model.setValue(10);
    numStronglyConnected_.setModel(model);

    // Set model of "From strongly connected components"
    model = new SpinnerNumberModel();
    model.setMinimum(1);
    model.setMaximum((Integer) subnetSize_.getModel().getValue());
    model.setStepSize(1);
    model.setValue(10);
    numRegulators_.setModel(model);

    // add tooltips for all elements of the window
    addTooltips();

    String title1, title2;
    title1 = title2 = "";
    if (item_ instanceof StructureElement) {
      ImodNetwork network = ((StructureElement) item_).getNetwork();
      title1 = item_.getLabel();
      title2 = network.getSize() + " nodes, " + network.getNumEdges() + " edges";
    } else if (item_ instanceof DynamicalModelElement) {
      GeneNetwork geneNetwork = ((DynamicalModelElement) item_).getGeneNetwork();
      title1 = item_.getLabel();
      title2 = geneNetwork.getSize() + " genes, " + geneNetwork.getNumEdges() + " interactions";
    }
    setGeneralInformation(title1 + " (" + title2 + ")");

    /** ACTIONS */
    subnetRootNameDocument_ = subnetRootName_.getDocument();
    subnetRootNameDocument_.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent arg0) {
            runButton_.setEnabled(!subnetRootName_.getText().equals(""));
          }

          public void insertUpdate(DocumentEvent arg0) {
            runButton_.setEnabled(!subnetRootName_.getText().equals(""));
          }

          public void removeUpdate(DocumentEvent arg0) {
            runButton_.setEnabled(!subnetRootName_.getText().equals(""));
          }
        });

    extractAllRegulators_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            disableExtractionOptions();
          }
        });

    randomVertex_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            updateSeedControls();
          }
        });

    selectionFromList_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            updateSeedControls();
          }
        });

    greedy_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            updateNeighborSelectionControls();
          }
        });

    randomAmongTop_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            updateNeighborSelectionControls();
          }
        });

    stronglyConnected_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            updateSeedControls();
          }
        });

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            GnwSettings.getInstance().stopSubnetExtraction(true);
            escapeAction();
          }
        });

    runButton_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            run();
          }
        });

    subnetSize_.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            updateRegulatorsOptions();
          }
        });

    numRegulators_.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            updateRegulatorsOptions();
          }
        });

    useNumRegulators_.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent arg0) {
            numRegulators_.setEnabled(useNumRegulators_.isSelected());
          }
        });

    //		useNumRegulators_.addChangeListener(new ChangeListener() {
    //			public void stateChanged(ChangeEvent arg0) {
    //				numRegulators_.setEnabled(useNumRegulators_.isSelected());
    //			}
    //		});

    subnetIdProposal();
    setListVerticesID();
    updateSeedControls();
    updateNeighborSelectionControls();

    useNumRegulators_.setSelected(false);
    numRegulators_.setEnabled(false);
  }
Ejemplo n.º 2
0
  private void createDataTable(GeneNetwork grn) {
    int numRxns = grn.getSize();

    DefaultTableModel modelTable =
        new DefaultTableModel(numRxns, columnName.length) {
          public boolean isCellEditable(int row, int column) {
            if (column == 0) return false;
            if (column == 1) return false;
            if (column == 2) return false;
            if (column == 3) return false;
            //				if(column == 4)
            //					return true;
            return true;
          }
        };
    modelTable.setColumnIdentifiers(columnName);
    table.setModel(modelTable);

    // set content
    List<RxnButtonRender> editors = new ArrayList<RxnButtonRender>(numRxns);

    // set content
    for (int i = 0; i < numRxns; i++) {
      Gene targetGene = (Gene) grn.getNode(i);

      String inputs = "";
      ArrayList<Gene> inputGenes = ((Gene) targetGene).getInputGenes();
      if (inputGenes != null && inputGenes.size() > 0) {
        for (int j = 0; j < inputGenes.size() - 1; j++)
          inputs += inputGenes.get(j).getLabel() + ",";
        inputs += inputGenes.get(inputGenes.size() - 1).getLabel();
      }

      String reactantString = "";
      ArrayList<Gene> reactants = ((Gene) targetGene).getReactants_();
      if (reactants != null && reactants.size() > 0) {
        for (int j = 0; j < reactants.size() - 1; j++)
          reactantString += reactants.get(j).getLabel() + ",";
        reactantString += reactants.get(reactants.size() - 1).getLabel();
      }

      //			//third column
      //			String inputsActive = "";
      //			ArrayList<Gene> inputActivatorGenes = ((Gene) targetGene).getActivators();
      //			if( inputActivatorGenes != null && inputActivatorGenes.size()>0 ){
      //				for(int j=0;j<inputActivatorGenes.size()-1;j++)
      //					inputsActive += inputActivatorGenes.get(j).getLabel() + ",";
      //				inputsActive += inputActivatorGenes.get(inputActivatorGenes.size()-1).getLabel();
      //			}
      //
      //			//fourth column
      //			String inputsInhibit = "";
      //			ArrayList<Gene> inputInhibitorGenes = ((Gene) targetGene).getInhibitors();
      //			if( inputInhibitorGenes != null && inputInhibitorGenes.size()>0 ){
      //				for(int j=0;j<inputInhibitorGenes.size()-1;j++)
      //					inputsInhibit += inputInhibitorGenes.get(j).getLabel() + ",";
      //				inputsInhibit += inputInhibitorGenes.get(inputInhibitorGenes.size()-1).getLabel();
      //			}

      // fifth column
      //			String combination = ((Gene) targetGene).getCombination();
      //			String disEquation = ((Gene) targetGene).getDisEquation();

      editors.add(
          new RxnButtonRender(
              table, targetGene.getLabel(), targetGene.getRnID(), element, targetGene, c));

      //			//content
      //			String[] tmp = {"R"+(i+1), targetGene.getLabel(), inputs, fourthContent};

      // content
      modelTable.setValueAt(targetGene.getRnID(), i, 0); // 1st
      modelTable.setValueAt(targetGene.getLabel(), i, 1); // 2nd
      modelTable.setValueAt(reactantString, i, 2); // 2nd
      modelTable.setValueAt(inputs, i, 3); // 3rd
      //			modelTable.setValueAt(inputsInhibit, i, 3); //4rd
      //			modelTable.setValueAt(fourthContent, i, 3); //5th

    } // end of for

    table.setEditors(editors);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    // set column width
    int[] width = {20, 20, 30, 30, 30};
    table.setColumnModel(getColumn(table, width));
    table.setRowHeight(20);

    tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.Y_AXIS));
    tablePanel.add(Box.createVerticalStrut(10));
    tablePanel.add(scrollPane);
  }