Exemplo n.º 1
0
    public void actionPerformed(final ActionEvent ae) {
      final boolean saveInteractionsFlag = LigandExplorer.saveInteractionsFlag;
      LigandExplorer.saveInteractionsFlag = false;

      final StructureModel model = LigandExplorer.sgetModel();
      //			final LXGlGeometryViewer glViewer = LigandExplorer.sgetGlGeometryViewer();

      // **J check to make sure all text fields have three
      // characters in them; if not, make the correction
      String philicText2 = philicFLF2.getText();
      switch (philicText2.length()) {
        case 0:
          philicText2 = "0.0";
          philicFLF2.setText(philicText2);
          break;
        case 1:
          philicText2 = philicText2 + ".0";
          philicFLF2.setText(philicText2);
          break;
        case 2:
          philicText2 = philicText2 + "0";
          philicFLF2.setText(philicText2);
      }

      String phobicText2 = phobicFLF2.getText();
      switch (phobicText2.length()) {
        case 0:
          phobicText2 = "0.0";
          phobicFLF2.setText(phobicText2);
          break;
        case 1:
          phobicText2 = phobicText2 + ".0";
          phobicFLF2.setText(phobicText2);
          break;
        case 2:
          phobicText2 = phobicText2 + "0";
          phobicFLF2.setText(phobicText2);
      }

      String l_h2o_pText2 = l_h2o_pflf2.getText();
      switch (l_h2o_pText2.length()) {
        case 0:
          l_h2o_pText2 = "0.0";
          l_h2o_pflf2.setText(l_h2o_pText2);
          break;
        case 1:
          l_h2o_pText2 = l_h2o_pText2 + ".0";
          l_h2o_pflf2.setText(l_h2o_pText2);
          break;
        case 2:
          l_h2o_pText2 = l_h2o_pText2 + "0";
          l_h2o_pflf2.setText(l_h2o_pText2);
      }

      String otherText2 = otherFLF2.getText();
      switch (otherText2.length()) {
        case 0:
          otherText2 = "0.0";
          otherFLF2.setText(otherText2);
          break;
        case 1:
          otherText2 = otherText2 + ".0";
          otherFLF2.setText(otherText2);
          break;
        case 2:
          otherText2 = otherText2 + "0";
          otherFLF2.setText(otherText2);
      }
      String neighborText1 = neighborFLF1.getText();
      switch (neighborText1.length()) {
        case 0:
          neighborText1 = "0.0";
          neighborFLF1.setText(neighborText1);
          break;
        case 1:
          neighborText1 = neighborText1 + ".0";
          neighborFLF1.setText(neighborText1);
          break;
        case 2:
          neighborText1 = neighborText1 + "0";
          neighborFLF1.setText(neighborText1);
      }

      if (model.hasStructures()) {
        final Structure structure = model.getStructures().get(0);

        final TreePath treeSelection[] = ligandJList.getSelectionPaths();
        if (treeSelection != null) {
          Residue residues[] = null;
          DefaultMutableTreeNode node =
              (DefaultMutableTreeNode) treeSelection[0].getLastPathComponent();
          StructureComponent nodeValue = (StructureComponent) node.getUserObject();
          if (nodeValue instanceof Chain) {
            assert (treeSelection.length == 1);
            Chain chain = (Chain) nodeValue;
            if (chain.getBird() != null) {
              residues = getBirdResidues(structure, chain);
            } else {
              residues = new Residue[chain.getResidueCount()];
              for (int ix = 0; ix < chain.getResidueCount(); ix++) {
                residues[ix] = chain.getResidue(ix);
              }
            }
          } else if (nodeValue instanceof Residue) {
            int ix = 0;
            residues = new Residue[treeSelection.length];

            for (TreePath path : treeSelection) {
              node = (DefaultMutableTreeNode) path.getLastPathComponent();
              nodeValue = (StructureComponent) node.getUserObject();
              assert (nodeValue instanceof Residue);
              residues[ix] = (Residue) nodeValue;
              ix++;
            }
          }
          if (residues != null) {
            LigandExplorer.sgetSceneController().setLigandResidues(residues);
          }
        }

        final float philicf2 = Float.parseFloat(philicText2);
        final float phobicf2 = Float.parseFloat(phobicText2);
        final float l_h2o_pf2 = Float.parseFloat(l_h2o_pText2);
        final float otherf2 = Float.parseFloat(otherText2);
        final float neighborf1 = Float.parseFloat(neighborText1);

        // Thread runner = new Thread() {
        //
        // public void run() {
        try {
          LigandExplorer.sgetSceneController()
              .processLeftPanelEvent(
                  structure,
                  l_h2o_pf2,
                  box.isSelected(),
                  hydrogenBondBox.isSelected(),
                  philicf2,
                  hydrophobicBox.isSelected(),
                  phobicf2,
                  metalInteractionBox.isSelected(),
                  otherf2,
                  distanceBox.isSelected(),
                  neighborf1,
                  neighborBox.isSelected(),
                  saveInteractionsFlag);
        } catch (final Exception e) {
          e.printStackTrace();
          Status.progress(
              100, "Error while processing your options...Please select different options");
        }
        // }
        // };
        // runner.start();

        // remove current surfaces from display list and add them again to ensure
        // transparent surfaces are drawn on top of the interactions
        LigandExplorer.sgetGlGeometryViewer().surfaceRemoved(structure);
        LigandExplorer.sgetGlGeometryViewer().surfaceAdded(structure);
      } else {
        // add a display message here, ask user to load a
        // structure, do this later
      }
    }