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

📄 sequencelist.java

📁 emboss的linux版本的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// drag source  public void dragGestureRecognized(DragGestureEvent e)  {    Point p = e.getDragOrigin();    int ncol = columnAtPoint(p);    if(ncol == convertColumnIndexToView(SequenceListTableModel.COL_NAME))    {      int nrow = getSelectedRow();      e.startDrag(DragSource.DefaultCopyDrop,             // cursor            (Transferable)seqModel.getSequenceData(nrow), // transferable data                  this);                                  // drag source listener    }  }  public void dragDropEnd(DragSourceDropEvent e) {}  public void dragEnter(DragSourceDragEvent e) {}  public void dragExit(DragSourceEvent e) {}  public void dragOver(DragSourceDragEvent e) {}  public void dropActionChanged(DragSourceDragEvent e) {}  public String getFileName(int row)  {    return (String)seqModel.getValueAt(row,                  SequenceListTableModel.COL_NAME);  }  /**  *  * Determine if a row in the table contains a list file  * @param row	row in the table  * @return 	true if row contains a list file  *  */  public Boolean isListFile(int row)  {    return (Boolean)seqModel.getValueAt(row,                  SequenceListTableModel.COL_LIST);  }// drop sink  public void dragEnter(DropTargetDragEvent e)  {    if(e.isDataFlavorSupported(RemoteFileNode.REMOTEFILENODE) ||       e.isDataFlavorSupported(FileNode.FILENODE) ||       e.isDataFlavorSupported(DataFlavor.stringFlavor) ||       e.isDataFlavorSupported(SequenceData.SEQUENCEDATA) )      e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);  }  public void drop(DropTargetDropEvent e)  {    Transferable t = e.getTransferable();    if(t.isDataFlavorSupported(FileNode.FILENODE))    {      try      {        final FileNode fn =           (FileNode)t.getTransferData(FileNode.FILENODE);        insertData(seqModel,e.getLocation(),fn.getFile().getCanonicalPath(),                   "","",new Boolean(false),new Boolean(false),                   new Boolean(false));        e.getDropTargetContext().dropComplete(true);      }      catch(UnsupportedFlavorException ufe){}      catch(IOException ioe){}    }    else if(t.isDataFlavorSupported(RemoteFileNode.REMOTEFILENODE))    {      try      {        String dropS = (String)t.getTransferData(DataFlavor.stringFlavor);        insertData(seqModel,e.getLocation(),dropS,                   "","",new Boolean(false),new Boolean(false),                   new Boolean(true));        e.getDropTargetContext().dropComplete(true);      }      catch (Exception exp)      {        e.rejectDrop();      }    }    else if(t.isDataFlavorSupported(SequenceData.SEQUENCEDATA))    {      try      {        SequenceData seqData = (SequenceData)           t.getTransferData(SequenceData.SEQUENCEDATA);        String seqName = seqData.s_name;        insertData(seqModel,e.getLocation(),seqData.s_name,                   seqData.s_beg,seqData.s_end,                   seqData.s_listFile,seqData.s_default,                   seqData.s_remote);      }      catch (UnsupportedFlavorException ufe){}      catch (IOException ioe){}    }  }  /**  *  * Inser sequence data into the sequence table  * @param seqModel 	model for the sequence table   * @param ploc		point location to insert  * @param fileName	name of file  * @param sbeg		start of sequence  * @param send		end of sequence  * @param lis		true if a list file  * @param def		true if the default sequence  * @param bremote	true if a sequence on the server  *  */  public void insertData(SequenceListTableModel seqModel, Point ploc,                         String fileName, String sbeg, String send,                         Boolean lis, Boolean def, Boolean bremote)  {    int row = rowAtPoint(ploc);    seqModel.modelVector.insertElementAt(new SequenceData(fileName,                                   sbeg,send,lis,def,bremote),row);    tableChanged(new TableModelEvent(seqModel, row+1, row+1,            TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));  }  public void dragOver(DropTargetDragEvent e)  {     Point ploc = e.getLocation();    int row = rowAtPoint(ploc);    setRowSelectionInterval(row,row);  }  public void dropActionChanged(DropTargetDragEvent e) {}  public void dragExit(DropTargetEvent e){}}/**** Content of each column in the DragJTable**/class ColumnData{  protected String title;  protected int width;  protected int alignment;  public ColumnData(String title, int width, int alignment)  {    this.title = title;    this.width = width;    this.alignment = alignment;  }}/**** Model for the sequence table **/class SequenceListTableModel extends AbstractTableModel{  protected static Vector modelVector;  public static final int COL_NAME = 0;  public static final int COL_BEG  = 1;  public static final int COL_END  = 2;  public static final int COL_LIST = 3;  public static final int COL_DEF  = 4;  public SequenceListTableModel()  {    modelVector = new Vector();    File fseq = new File(System.getProperty("user.home")                  + System.getProperty("file.separator")                  + ".jembossSeqList");    setDefaultData();    if(fseq.canRead())      loadStoredSeqList(fseq);  }  /**  *  * Define the columns as file/start/end/list and default  *  */  public static final ColumnData modelColumns[] =  {    new ColumnData("File / Database Entry",170,JLabel.LEFT),    new ColumnData("Start",45,JLabel.LEFT),    new ColumnData("End",45,JLabel.LEFT),    new ColumnData("List File",15,JLabel.LEFT),    new ColumnData("Default",15,JLabel.LEFT)  };  /**  *  * DragJTable uses this method to determine the default renderer/  * editor for each cell.  If we didn't implement this method,  * then the last column would contain text ("true"/"false"),  * rather than a check box.  * @param c	column index  * @return 	class represented in that column  *  */  public Class getColumnClass(int c)   {    return getValueAt(0, c).getClass();  }  /**  *  * Load from stored file the SequenceList created from  * a previous session.  * @param fseq 	contains stored sequence list  *  */  protected void loadStoredSeqList(File fseq)  {    try    {      BufferedReader in = new BufferedReader(new FileReader(fseq));      String line;      int nrow = 0;      while((line = in.readLine()) != null)      {        if(!line.equals(""))        {          line = line.trim();          StringTokenizer st = new StringTokenizer(line, " ");          for(int i=0;i<getColumnCount();i++)          {            if(!st.hasMoreTokens())              break;            if(nrow >= getRowCount())            {              Boolean bdef = new Boolean(false);              modelVector.addElement(new SequenceData("","","",bdef,bdef,bdef));            }                         String value = st.nextToken();            if(value.equals("-"))              value = "";            if(value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false"))              setValueAt(new Boolean(value),nrow,i);            else               setValueAt(value,nrow,i);          }          nrow++;        }      }     }    catch (ArrayIndexOutOfBoundsException ai)    {      System.out.println("ArrayIndexOutOfBoundsException in SequenceList");      setDefaultData();    }    catch (IOException ioe)    {      setDefaultData();    }  }  /**  *  * Setup a blank square table   *  */  protected void setDefaultData()  {    modelVector.removeAllElements();    Boolean bdef = new Boolean(false);    for(int i=0;i<getColumnCount();i++)      modelVector.addElement(new SequenceData("","","",bdef,bdef,bdef));       }    /**  *  * The <code>SequenceData</code> for a given row  * number.  * @param row 	number  * @return 	<code>SequenceData</code> for the row  *  */  protected SequenceData getSequenceData(int nrow)  {    return (SequenceData)modelVector.get(nrow);  }  /**  *  * Return the number of rows in the table  * @return 	number of rows in the table  *  */  public int getRowCount()  {    return modelVector==null ? 0 : modelVector.size();  }  /**  *  * Return the number of columns in the table  * @return 	number of columns in the table  *  */  public int getColumnCount()  {    return modelColumns.length;  }  /**  *  * Return the name columns in the table  * @param c	column index  * @return 	name columns in the table  *  */  public String getColumnName(int c)  {    return modelColumns[c].title;  }  /**  *  * Define if a cell is editable by the user  * @param nRow	row number  * @param nCol	column number  * @return 	true if editable  *  */  public boolean isCellEditable(int nRow, int nCol)  {    return true;  }  /**  *  * Get the Object in a cell in the table  * @param nRow	row number  * @param nCol	column number  * @return 	value of a cell in the table  *  */  public Object getValueAt(int nRow, int nCol)  {    if(nRow < 0 || nCol>=getRowCount())      return "";    SequenceData row = (SequenceData)modelVector.elementAt(nRow);    switch(nCol)    {       case COL_NAME: return row.s_name;      case COL_BEG: return row.s_beg;      case COL_END: return row.s_end;      case COL_DEF:  return row.s_default;      case COL_LIST:  return row.s_listFile;    }    return "";   }  /**  *  * Set the Object in a cell in the table  * @param value to set  * @param row number  * @param column number  *  */  public void setValueAt(Object value, int nRow, int nCol)  {    if(nRow < 0 || nCol>=getRowCount())      return ;    SequenceData row = (SequenceData)modelVector.elementAt(nRow);    String svalue = value.toString();        switch(nCol)    {      case COL_NAME:         row.s_name = svalue;        break;      case COL_BEG:         row.s_beg = svalue;        break;      case COL_END:        row.s_end = svalue;        break;      case COL_DEF:          row.s_default = (Boolean)value;        break;      case COL_LIST:        row.s_listFile = (Boolean)value;        break;    }  }  /**  *  * Insert a blank row  * @param row index to insert at  *  */  public void insertRow(int row)  {    if(row < 0)      row = 0;    if(row > modelVector.size())      row = modelVector.size();    modelVector.insertElementAt(new SequenceData(), row);  }    /**  *  * Delete a row from the table  * @param row 	number to delete  * @return 	true if deleted  *  */  public boolean deleteRow(int row)  {    if(row < 0 || row>=modelVector.size())      return false;    modelVector.remove(row);//add in blank row so there is always at least//same number of rows as there is columns    if(getRowCount() < getColumnCount())    {      Boolean bdef = new Boolean(false);      modelVector.addElement(new SequenceData("","","",bdef,bdef,bdef));    }    return true;  }}

⌨️ 快捷键说明

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