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

📄 sectionpanel.java

📁 emboss的linux版本的源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/**********************************************************************  This library is free software; you can redistribute it and/or*  modify it under the terms of the GNU Library General Public*  License as published by the Free Software Foundation; either*  version 2 of the License, or (at your option) any later version.**  This library is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU*  Library General Public License for more details.**  You should have received a copy of the GNU Library General Public*  License along with this library; if not, write to the*  Free Software Foundation, Inc., 59 Temple Place - Suite 330,*  Boston, MA  02111-1307, USA.**  @author: Copyright (C) Tim Carver*********************************************************************/package org.emboss.jemboss.gui.form;import java.awt.*;import javax.swing.*;import javax.swing.border.TitledBorder;import javax.swing.border.Border;import java.util.Vector;import java.util.Enumeration;import java.util.StringTokenizer;import java.awt.event.*;import java.io.*;import org.emboss.jemboss.programs.RunEmbossApplication2;import org.emboss.jemboss.gui.AdvancedOptions;import org.emboss.jemboss.gui.BuildProgramMenu;import org.emboss.jemboss.parser.*;import org.emboss.jemboss.programs.ListFile;import org.emboss.jemboss.gui.sequenceChooser.*;import org.emboss.jemboss.soap.CallAjax;import org.emboss.jemboss.soap.JembossSoapException;import org.emboss.jemboss.JembossParams;/**** Responsible for displaying the Jemboss application form* generated from the ACD file. This also handles events related to* dependent parameters.**/public class SectionPanel{  private MultiTextField multiTextField[];  /** text field sink    */  private TextFieldSink textf[];  /** integer field sink */  private TextFieldInt textInt[];  /** float field sink   */  private TextFieldFloat textFloat[];  /** range field        */  private JTextField rangeField[];  /** boolean fields     */  private JCheckBox  checkBox[];  /** input sequence attributes */  private InputSequenceAttributes inSeqAttr[];  /** list file panel    */  private ListFilePanel filelist[];  /** checkbox popup field for list and select */  private JembossComboPopup fieldOption[];  /** multiple option field for list and select */  private JList multiOption[];  /** input sequence field */  private SetInFileCard inSeq[];  /** field label container */  private Box lab[];  /** available databases */  private String db[];//private JComboBox graphics;  /** ACD parser for the application selected */  private ParseAcd parseAcd;  /** number of fields in the ACD */  private int numofFields;  /** field number to start from */  private int nf;  /** sequence length */  public static int ajaxLength;  /** sequence weight */  public static float ajaxWeight;  /** sequence type   */  public static boolean ajaxProtein;  /** true if in client-server mode */  private boolean withSoap;  /** application name   */  private String appName = "";  /** Jemboss form panel */  private JPanel p3;  /** container for this ACD section */  private JPanel sectionPane;  /** container for this ACD section */  private Box sectionBox;  /** jemboss properties */  private JembossParams mysettings;// input, required, advanced & output sections  /** true if the input section    */  private boolean isInp = false;  /** true if the required section */  private boolean isReq = false;  /** true if the advanced section */  private boolean isAdv = false;  /** true if the additional section */  private boolean isAdd = false;  /** true if the output section   */  private boolean isOut = false;  /** true if shading disabled fields, otherwise they       are removed from the form */  private boolean isShadedGUI;  /** label colour */  public static Color labelColor = new Color(0, 0, 0);  /** label font   */  public static Font labfont = new Font("SansSerif", Font.BOLD, 12);    /** small label font */  public static Font labfont2 = new Font("SansSerif", Font.BOLD, 11);  /** maximum width of the form */  private final int maxSectionWidth = 498;  /** Jemboss frame    */  private JFrame f;  /** report format    */  private ReportFormat rf=null;  /** alignment format */  private AlignFormat af=null;  /**  *  * @param f 		Jemboss frame  * @param p3		JPanel ACD form panel  * @param fieldPane	containing all the fields   * @param parseAcd	representing the ACD file to display as a form  * @param nff		field number  * @param textf		text fields in the form  * @param textInt	integer fields in the form  * @param textFloat	float fields in the form  * @param rangeField	ranges in the form  * @param checkBox	for the boolean switches  * @param inSeqAttr	the input sequence(s) attributes  * @param fieldOption	for the list/selection data types  * @param multiOption	for multiple selection lists  * @param inSeq 		the input sequence(s)  * @param filelist	list file panel  * @param db		String array containing the databases  * @param des		String containing the one line description for the application  * @param lab		Box for all the component labels  * @param numofFields	total number of fields  * @param mysettings	jemboss properties  * @param withSoap 	true if using a soap server  *  */  protected SectionPanel(JFrame f, JPanel p3, Box fieldPane,             ParseAcd parseAcd, int nff, final MultiTextField multiTextField[],            final TextFieldSink textf[],             TextFieldInt textInt[], TextFieldFloat textFloat[],            JTextField rangeField[], JCheckBox  checkBox[],            InputSequenceAttributes inSeqAttr[],            JembossComboPopup fieldOption[], JList multiOption[],             SetInFileCard inSeq[], ListFilePanel filelist[], JComboBox graphics,            String db[], String des, Box lab[], int numofFields,            JembossParams mysettings, boolean withSoap, String[] envp)  {    Border etched = BorderFactory.createEtchedBorder();    isShadedGUI = AdvancedOptions.prefShadeGUI.isSelected();    this.p3 = p3;    this.textf = textf;    this.textInt = textInt;    this.textFloat = textFloat;    this.rangeField = rangeField;    this.checkBox = checkBox;    this.inSeqAttr = inSeqAttr;    this.fieldOption = fieldOption;    this.multiOption = multiOption;    this.inSeq = inSeq;    this.numofFields = numofFields;    this.db = db;    this.lab = lab;    this.parseAcd = parseAcd;    this.mysettings = mysettings;    this.withSoap = withSoap;     this.f = f;//  this.graphics = graphics;//using JNI?    nf = nff;    String att = parseAcd.getParameterAttribute(nf,0).toLowerCase();//set the ACD title    if(att.startsWith("appl"))    {      setAppTitle(des,p3);      nf++;      att = parseAcd.getParameterAttribute(nf,0).toLowerCase();    }      Box section = new Box(BoxLayout.Y_AXIS);    fieldPane.add(Box.createRigidArea(new Dimension(0,10)));    JLabel bxlab = new JLabel();    bxlab.setFont(labfont);    sectionPane = new JPanel(new GridLayout(1,1));    sectionPane.setBorder(BorderFactory.createEtchedBorder());    String nameSect = parseAcd.getParamValueStr(nf, 0);    if(att.equals("section"))    {      TitledBorder title;      title = BorderFactory.createTitledBorder(etched,                 parseAcd.getInfoParamValue(nf).toLowerCase(),                TitledBorder.LEFT,TitledBorder.TOP,                new Font("SansSerif", Font.BOLD, 13),                Color.blue);      sectionPane.setBorder(title);      String secType = parseAcd.getInfoParamValue(nf).toLowerCase();      if(secType.startsWith("advanced "))        isAdv = true;      else if(secType.startsWith("additional "))        isAdd = true;      else if(secType.startsWith("input "))        isInp = true;      else if(secType.startsWith("output "))        isOut = true;      else if(secType.startsWith("required "))        isOut = true;      else        System.out.println("Unknown section type " + secType);      nf++;      att = parseAcd.getParameterAttribute(nf,0).toLowerCase();    }    String varName = parseAcd.getParamValueStr(nf, 0);    int numberOfParameters = 0;// loop over all the fields in the section or the all fields in the ACD    while( !( att.equals("endsection")  && varName.equals(nameSect)) &&            nf < numofFields )    {           if(!(att.equals("var") || att.equals("variable")))       {        numberOfParameters++;        final int h = parseAcd.getGuiHandleNumber(nf);        Box pan = new Box(BoxLayout.X_AXIS);        section.add(pan);        String l = getMinMaxDefault(null,null,null,nf);      	lab[nf] = new LabelTextBox(parseAcd.getInfoParamValue(nf),                                  parseAcd.getHelpParamValue(nf));        if(l != null && !att.startsWith("bool"))        {          bxlab = new JLabel(" " + l);          bxlab.setFont(labfont2);          bxlab.setForeground(Color.blue);          lab[nf].add(bxlab);        }        if(att.startsWith("appl"))        {          setAppTitle(des,p3);        }        else if(att.endsWith("graph"))        {          Dimension d  = graphics.getPreferredSize();          d = new Dimension(150,(int)d.getHeight());          graphics.setMaximumSize(d);          graphics.setPreferredSize(d);          pan.add(graphics);          pan.add(new JLabel(" Graph Format"));        }        else if(att.startsWith("int"))        {          if(parseAcd.isDefaultParamValueStr(nf))           {            if( !(parseAcd.getDefaultParamValueStr(nf).startsWith("@") ||                  parseAcd.getDefaultParamValueStr(nf).startsWith("$")) )              textInt[h].setValue(Integer.parseInt(                           parseAcd.getDefaultParamValueStr(nf)));          }          else          {            Double val = new Double(parseAcd.getDefaultParamValueDbl(nf));            textInt[h].setValue(val.intValue());          }          pan.add(textInt[h]);          pan.add(lab[nf]);        } else if(att.startsWith("float")) {          if(parseAcd.isDefaultParamValueStr(nf))          {            if( !(parseAcd.getDefaultParamValueStr(nf).startsWith("@") ||                  parseAcd.getDefaultParamValueStr(nf).startsWith("$")) )              textFloat[h].setValue(Double.parseDouble(                           parseAcd.getDefaultParamValueStr(nf)));          }          else          {            Double val = new Double(parseAcd.getDefaultParamValueDbl(nf) );            textFloat[h].setValue(val.doubleValue());          }          pan.add(textFloat[h]);          pan.add(lab[nf]);        }        else if(att.startsWith("matrix"))        {          if(parseAcd.isDefaultParamValueStr(nf))            if( !(parseAcd.getDefaultParamValueStr(nf).startsWith("@") ||                  parseAcd.getDefaultParamValueStr(nf).startsWith("$")) )              textf[h].setText( parseAcd.getDefaultParamValueStr(nf));                   pan.add(textf[h]);          pan.add(lab[nf]);            Box pan2 = new Box(BoxLayout.X_AXIS);          section.add(pan2);                    JembossComboPopup selectMatrix = new JembossComboPopup(                                        BuildProgramMenu.getMatrices());          selectMatrix.addActionListener(new ActionListener()          {            public void actionPerformed(ActionEvent e)            {              JembossComboPopup cb = (JembossComboPopup)e.getSource();              String matrix = (String)cb.getSelectedItem();              textf[h].setText(matrix);            }          });          Dimension d = selectMatrix.getPreferredSize();          d = new Dimension(150,(int)d.getHeight());          selectMatrix.setMaximumSize(d);          selectMatrix.setPreferredSize(d);          pan2.add(selectMatrix);          pan2.add(Box.createHorizontalGlue());                  }        else if(att.startsWith("codon"))        {             if(parseAcd.isDefaultParamValueStr(nf))            if( !(parseAcd.getDefaultParamValueStr(nf).startsWith("@") ||                  parseAcd.getDefaultParamValueStr(nf).startsWith("$")) )              textf[h].setText( parseAcd.getDefaultParamValueStr(nf));          pan.add(textf[h]);          pan.add(lab[nf]);             Box pan2 = new Box(BoxLayout.X_AXIS);          section.add(pan2);          JembossComboPopup selectMatrix = new JembossComboPopup(                                        BuildProgramMenu.getCodonUsage());          selectMatrix.addActionListener(new ActionListener()          {            public void actionPerformed(ActionEvent e)            {              JembossComboPopup cb = (JembossComboPopup)e.getSource();              String matrix = (String)cb.getSelectedItem();              textf[h].setText(matrix);            }          });          Dimension d = selectMatrix.getPreferredSize();          d = new Dimension(150,(int)d.getHeight());          selectMatrix.setMaximumSize(d);          selectMatrix.setPreferredSize(d);          pan2.add(selectMatrix);          pan2.add(Box.createHorizontalGlue());        }        else if(att.startsWith("dirlist") || att.startsWith("string") ||                att.startsWith("infile")  || att.startsWith("regexp") ||                att.startsWith("featout") )        {          if(parseAcd.isDefaultParamValueStr(nf))             if( !(parseAcd.getDefaultParamValueStr(nf).startsWith("@") ||                  parseAcd.getDefaultParamValueStr(nf).startsWith("$")) )              textf[h].setText( parseAcd.getDefaultParamValueStr(nf));          pan.add(textf[h]);          pan.add(lab[nf]);        }        else if( att.startsWith("pattern") )        {          LabelTextBox labs[] = new LabelTextBox[2];                    labs[0] = (LabelTextBox)lab[nf];          labs[1] = new LabelTextBox("Pattern mismatch",                                     "Number of pattern mismatch");                    multiTextField[h] = new MultiTextField(2, labs);          pan.add(multiTextField[h].getBoxOfTextFields());        }        else if(att.startsWith("seqout"))        {          new SetOutFileCard(pan,textf[h],labelColor,sectionPane);        }        else if(att.startsWith("outfile") || att.startsWith("datafile"))        {          if(parseAcd.isDefaultParamValueStr(nf))            if( !(parseAcd.getDefaultParamValueStr(nf).startsWith("@") ||                  parseAcd.getDefaultParamValueStr(nf).startsWith("$")) )              textf[h].setText( parseAcd.getDefaultParamValueStr(nf));          if(parseAcd.getInfoParamValue(nf).equals(""))          {            bxlab = new JLabel(" " + att + " file name");            bxlab.setForeground(labelColor);          }

⌨️ 快捷键说明

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