⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scoredialog.java

📁 Sequence alignement using different algorithms
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
package norman.baba.UI;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

import norman.baba.algorithms.*;
import java.util.*;

import norman.baba.utils.*;

/**
 * <p>Title: BABA</p>
 * <p>Description: Bioinformatique Research Project</p>
 * <p>Copyright: Copyright Norman Casagrande (c) 2003</p>
 * <p>Company: </p>
 * @author Norman Casagrande
 * @version 1.0
 */

public class ScoreDialog
    extends JDialog {

   protected static final int SCOREMATRIX_ORIGINAL = 0;
   protected static final int SCOREMATRIX_PAM250 = 1;
   protected static final int SCOREMATRIX_BLOSUM62 = 2;
   protected static final int SCOREMATRIX_VTML160 = 3;
   protected static final int SCOREMATRIX_PENALIZEMISMATCH = 4;

   protected static int CELLS_WIDTH = 25;

   protected JDialog m_thisDialog;
   protected JTextField m_jTxtValues[];

   protected JButton m_btnOk = new JButton("Ok");
   protected JButton m_btnCancel = new JButton("Cancel");

   protected String[] m_matrixData = {
       "Original", "Pam250", "Blosum62", "Vtml160", "Penalize Mismatch"};
   protected JComboBox m_matrixSelection = new JComboBox(m_matrixData);

   protected int m_resulMatrix[][];
   protected String m_alphabet;

   protected ScoreHash m_passedHash;

   public ScoreDialog(Frame frame, String title, boolean modal,
                     String alphabet, ScoreHash passedHashtable) {
      super(frame, title, modal);

      this.m_thisDialog = this;
      this.m_passedHash = passedHashtable;
      this.m_alphabet = alphabet;

      this.m_matrixSelection.addActionListener(new ComboBoxListener());

      try {
         jbInit();
         pack();
      }
      catch (Exception ex) {
         ex.printStackTrace();
      }

      this.setDialogDimension();
      this.fillCells(passedHashtable);
   }

   protected void setDialogDimension() {

      int nHCells = m_alphabet.length() + 1;
      int calcWidth = CELLS_WIDTH * nHCells;

      Dimension prev = this.getSize();

      if (calcWidth > prev.width) {
         prev.width = calcWidth;
         this.setSize(prev);
      }

      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      Dimension frameSize = this.getSize();
      if (frameSize.height > screenSize.height) {
         frameSize.height = screenSize.height;
      }
      if (frameSize.width > screenSize.width) {
         frameSize.width = screenSize.width;
      }
      this.setLocation( (screenSize.width - frameSize.width) / 2,
                        (screenSize.height - frameSize.height) / 2);

   }

   public ScoreDialog(String alphabet, ScoreHash resultingHashtable) {
      this(null, "Score Table", true, alphabet, resultingHashtable);
   }

   private void jbInit() throws Exception {

      JPanel basePanel = new JPanel();
      JPanel scorePanel = new JPanel();

      int alphSize = m_alphabet.length();
      int i, j;

      basePanel.setLayout(new BorderLayout());

      GridLayout gridLayout = new GridLayout(alphSize+1, alphSize+1);
      scorePanel.setLayout(gridLayout);

      // CENTER
      Border insetsBorder;
      insetsBorder = BorderFactory.createEmptyBorder(0,0,0,5);
      scorePanel.setBorder(insetsBorder);

      JLabel jHTitles[] = new JLabel[alphSize];
      for (i = 0; i < jHTitles.length; ++i) {
         jHTitles[i] = new JLabel(m_alphabet.substring(i,i+1));
         jHTitles[i].setHorizontalAlignment(SwingConstants.CENTER);
      }

      JLabel jVTitles[] = new JLabel[alphSize];
      for (i = 0; i < jVTitles.length; ++i) {
         jVTitles[i] = new JLabel(m_alphabet.substring(i,i+1));
         jVTitles[i].setHorizontalAlignment(SwingConstants.CENTER);
      }

      // First line:
      // _ A G C T
      scorePanel.add(new JLabel());

      for (i = 0; i < alphSize; ++i) {
         scorePanel.add(jHTitles[i]);
      }

      int numEditableCells = (alphSize * alphSize + alphSize) / 2;

      m_jTxtValues = new JTextField[numEditableCells];
      int count = 0;

      for (j = 0; j < alphSize; ++j) {

         scorePanel.add(jVTitles[j]);

         for (i = 0; i < j+1; ++i) {
            m_jTxtValues[count] = new JTextField();
            m_jTxtValues[count].setHorizontalAlignment(SwingConstants.CENTER);
            scorePanel.add(m_jTxtValues[count]);
            count++;
         }

         for (i = j+1; i < alphSize; ++i) {
            scorePanel.add(new JLabel());
         }

      }

      // SOUTH
      JPanel southPanel = new JPanel();
      southPanel.add(m_btnOk);
      southPanel.add(m_btnCancel);

      // NORTH
      JPanel northPanel = new JPanel();
      northPanel.add(new JLabel("ScoreMatrix:"));
      northPanel.add(m_matrixSelection);

      // Add everything to the basic panel
      basePanel.add(northPanel, BorderLayout.NORTH);
      basePanel.add(scorePanel, BorderLayout.CENTER);
      basePanel.add(southPanel, BorderLayout.SOUTH);

      getContentPane().add(basePanel);

      // EVENTS
      m_btnOk.addActionListener(new ButtonListener());
      m_btnCancel.addActionListener(new ButtonListener());

   }

   protected void loadScoreMatrix(int scoreMatrix) {

      ScoreHash wholeMatrix = null;

      switch (scoreMatrix) {

         case SCOREMATRIX_ORIGINAL:
            wholeMatrix = m_passedHash;
            break;

         case SCOREMATRIX_PAM250:

            wholeMatrix = new ScoreHash();
            wholeMatrix.setScore('A', 'A', 2);
            wholeMatrix.setScore('R', 'A', -2);
            wholeMatrix.setScore('R', 'R', 6);
            wholeMatrix.setScore('N', 'A', 0);
            wholeMatrix.setScore('N', 'R', 0);
            wholeMatrix.setScore('N', 'N', 2);
            wholeMatrix.setScore('D', 'A', 0);
            wholeMatrix.setScore('D', 'R', -1);
            wholeMatrix.setScore('D', 'N', 2);
            wholeMatrix.setScore('D', 'D', 4);
            wholeMatrix.setScore('C', 'A', -2);
            wholeMatrix.setScore('C', 'R', -4);
            wholeMatrix.setScore('C', 'N', -4);
            wholeMatrix.setScore('C', 'D', -5);
            wholeMatrix.setScore('C', 'C', 12);
            wholeMatrix.setScore('Q', 'A', 0);
            wholeMatrix.setScore('Q', 'R', 1);
            wholeMatrix.setScore('Q', 'N', 1);
            wholeMatrix.setScore('Q', 'D', 2);
            wholeMatrix.setScore('Q', 'C', -5);
            wholeMatrix.setScore('Q', 'Q', 4);
            wholeMatrix.setScore('E', 'A', 0);
            wholeMatrix.setScore('E', 'R', -1);
            wholeMatrix.setScore('E', 'N', 1);
            wholeMatrix.setScore('E', 'D', 3);
            wholeMatrix.setScore('E', 'C', -5);
            wholeMatrix.setScore('E', 'Q', 2);
            wholeMatrix.setScore('E', 'E', 4);
            wholeMatrix.setScore('G', 'A', 1);
            wholeMatrix.setScore('G', 'R', -3);
            wholeMatrix.setScore('G', 'N', 0);
            wholeMatrix.setScore('G', 'D', 1);
            wholeMatrix.setScore('G', 'C', -3);
            wholeMatrix.setScore('G', 'Q', -1);
            wholeMatrix.setScore('G', 'E', 0);
            wholeMatrix.setScore('G', 'G', 5);
            wholeMatrix.setScore('H', 'A', -1);
            wholeMatrix.setScore('H', 'R', 2);
            wholeMatrix.setScore('H', 'N', 2);
            wholeMatrix.setScore('H', 'D', 1);
            wholeMatrix.setScore('H', 'C', -3);
            wholeMatrix.setScore('H', 'Q', 3);
            wholeMatrix.setScore('H', 'E', 1);
            wholeMatrix.setScore('H', 'G', -2);
            wholeMatrix.setScore('H', 'H', 6);
            wholeMatrix.setScore('I', 'A', -1);
            wholeMatrix.setScore('I', 'R', -2);
            wholeMatrix.setScore('I', 'N', -2);
            wholeMatrix.setScore('I', 'D', -2);
            wholeMatrix.setScore('I', 'C', -2);
            wholeMatrix.setScore('I', 'Q', -2);
            wholeMatrix.setScore('I', 'E', -2);
            wholeMatrix.setScore('I', 'G', -3);
            wholeMatrix.setScore('I', 'H', -2);
            wholeMatrix.setScore('I', 'I', 5);
            wholeMatrix.setScore('L', 'A', -2);
            wholeMatrix.setScore('L', 'R', -3);
            wholeMatrix.setScore('L', 'N', -3);
            wholeMatrix.setScore('L', 'D', -4);
            wholeMatrix.setScore('L', 'C', -6);
            wholeMatrix.setScore('L', 'Q', -2);
            wholeMatrix.setScore('L', 'E', -3);
            wholeMatrix.setScore('L', 'G', -4);
            wholeMatrix.setScore('L', 'H', -2);
            wholeMatrix.setScore('L', 'I', 2);
            wholeMatrix.setScore('L', 'L', 6);
            wholeMatrix.setScore('K', 'A', -1);
            wholeMatrix.setScore('K', 'R', 3);
            wholeMatrix.setScore('K', 'N', 1);
            wholeMatrix.setScore('K', 'D', 0);
            wholeMatrix.setScore('K', 'C', -5);
            wholeMatrix.setScore('K', 'Q', 1);
            wholeMatrix.setScore('K', 'E', 0);
            wholeMatrix.setScore('K', 'G', -2);
            wholeMatrix.setScore('K', 'H', 0);
            wholeMatrix.setScore('K', 'I', -2);
            wholeMatrix.setScore('K', 'L', -3);
            wholeMatrix.setScore('K', 'K', 5);
            wholeMatrix.setScore('M', 'A', -1);
            wholeMatrix.setScore('M', 'R', 0);
            wholeMatrix.setScore('M', 'N', -2);
            wholeMatrix.setScore('M', 'D', -3);
            wholeMatrix.setScore('M', 'C', -5);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -