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

📄 graphicsequencecollection.java

📁 emboss的linux版本的源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    }    return Color.black;  }  /**  *  * Determine the colour of a residue background  *  */  protected Color getPrettyBackground(Color textColour)  {    if(textColour.equals(prettyPlot.getIDColour()))      return prettyPlot.getIDBackgroundColour();    else if(textColour.equals(prettyPlot.getMatchColour()))      return prettyPlot.getMatchBackgroundColour();    else      return null;  }   /**  *  * Determine if the identities are to be boxed  * @return 	true if to draw boxes  *  */   protected boolean isPrettyBox()  {    return prettyPlot.isPrettyBox();  }    /**  *  *   *  */  protected int testUpAndDown(int pos, Sequence seq)  {    int seqIndex = seqs.indexOf(seq);    int testUp = -1;    if(seqIndex == 0)      testUp = 1;    else    {      Sequence seqUp = (Sequence)seqs.get(seqIndex-1);      String res = seqUp.getSequence().substring(pos,pos+1);      Color col = getColor(res,pos,seqUp.getName());      if(col.equals(Color.black))        testUp = 1;    }    int testDown = -1;    if(seqIndex+1 == seqs.size())      testDown= 1;    else    {      Sequence seqDown = (Sequence)seqs.get(seqIndex+1);      SequenceJPanel seqPanelDown = (SequenceJPanel)graphicSequence.get(seqIndex+2);      String res = seqDown.getSequence().substring(pos,pos+1);      Color col = getColor(res,pos,seqDown.getName());      if(col.equals(Color.black) || !seqPanelDown.isPrettyPlot())           testDown = 1;    }    if(testUp > -1 && testDown > -1)      return 3;    else if(testDown > -1)      return 2;    else if(testUp > -1)      return 1;    return -1;  }  /**  *  * Remove a sequence from the editor display  * @param name		name of sequence to remove  *  */  private Sequence removeSequence(String name)  {    boolean removed = false;    int index = 0;    Enumeration enumer = seqs.elements();    Sequence seq = null;    while(enumer.hasMoreElements())    {      seq = (Sequence)enumer.nextElement();      if(seq.getName().equals(name))      {        removedSeqs.add(seq);        removed = true;        seqs.remove(seq);        break;      }      index++;    }    if(!removed)      return null;    if(drawNumber)      index++;    seqBox.remove(index);    seqNameBox.remove(index);    graphicName.removeElementAt(index);    graphicSequence.removeElementAt(index);    return seq;  }  /**  *  *  Delete a sequence from the sequence collection display  *  and resize the sequence panel display  *  @param name	name of sequence to remove  *  */  protected void deleteSequence(String name)  {    removeSequence(name);    setMaxSeqLength();    numberDraw.setSequenceLength(MAXSEQLENGTH);    Dimension dpane = getPanelSize();    setMinimumSize(dpane);    setPreferredSize(dpane);    numberDraw.setMaximumSize(numberDraw.getPreferredSize());    numberDraw.setMinimumSize(numberDraw.getPreferredSize());    setJScrollPaneViewportView();  }  /**  *  * Move a sequence to a new position  * @param name		name of sequence to remove  * @param i		new position in the sequence editor  *  */  protected void moveSequence(String name, int i)  {    Sequence seq = removeSequence(name);    addSequence(seq,true,0,0,i);  }  /**  *  * Sorts the sequences and displays them by their id's  *  */  protected void idSort()  {    int nseqs = 0;// get no. of sequences excl. consensus    Enumeration enumer = seqs.elements();    while(enumer.hasMoreElements())    {        String name = ((Sequence)enumer.nextElement()).getName();      if(!name.equals("Consensus"))        nseqs++;    }    String seqName[] = new String[nseqs];    int i = 0;    enumer = seqs.elements();     while(enumer.hasMoreElements())    {      String name = ((Sequence)enumer.nextElement()).getName();      if(!name.equals("Consensus"))      {        seqName[i] = new String(name);        i++;      }    }    Arrays.sort(seqName);    for(i=0;i<nseqs;i++)      moveSequence(seqName[i],i);  }  /**  *  *  Add a sequence at a particular index to the sequence   *  collection display and to the collection of sequences   *  (seqs) with a specified y-padding.  *  @param seq			sequence to add to the editor display  *  @param addToSequences	true to add seq to the vector of sequences  *  @param ypad		sequence panel height padding  *  @param fontSize		font size  *  @param index		sequence index  *  */  protected void addSequence(Sequence seq, boolean addToSequences,                              int ypad, int fontSize, int index)  {    if(addToSequences)      seqs.add(index,seq);    if(drawNumber)      index++;    SequenceJPanel gs = new SequenceJPanel(seq,this,                           drawSequence,drawBlackBox,drawColorBox,                           colorScheme,ypad);    graphicSequence.add(index,gs);    Box XBox = new Box(BoxLayout.X_AXIS);    XBox.add(gs);    XBox.add(Box.createHorizontalGlue());    seqBox.add(XBox,index);    gs.setToolTipText("");   //enable tooltip display    SequenceNameJButton snj = new SequenceNameJButton(seq,ypad);    graphicName.add(index,snj);    XBox = new Box(BoxLayout.X_AXIS);    XBox.add(Box.createHorizontalGlue());    XBox.add(snj);    seqNameBox.add(XBox,index);    if(seq.getLength()>MAXSEQLENGTH)      MAXSEQLENGTH = seq.getLength();    Dimension actual = gs.getMaximumSize();    int slen = gs.getResidueWidth()*(int)(MAXSEQLENGTH*1.2);    gs.setMaximumSize(new Dimension(slen,(int)actual.getHeight()));  }  /**  *  *  Add a sequence to the sequence collection display and  *  to the collection of sequences (seqs) with a specified  *  y-padding.  *  @param seq                 sequence to add to the editor display  *  @param addToSequences      true to add seq to the vector of sequences  *  @param ypad                sequence panel height padding  *  @param fontSize            font size  *  */  protected void addSequence(Sequence seq, boolean addToSequences,                             int ypad, int fontSize)  {    if(addToSequences)      seqs.add(seq);    SequenceJPanel gs = new SequenceJPanel(seq,this,                           drawSequence,drawBlackBox,drawColorBox,                           colorScheme,fontSize,ypad);    graphicSequence.add(gs);    Box XBox = new Box(BoxLayout.X_AXIS);    XBox.add(gs);    XBox.add(Box.createHorizontalGlue());    seqBox.add(XBox);    gs.setToolTipText("");   //enable tooltip display    SequenceNameJButton snj = new SequenceNameJButton(seq,ypad);    graphicName.add(snj);    XBox = new Box(BoxLayout.X_AXIS);    XBox.add(Box.createHorizontalGlue());    XBox.add(snj);    seqNameBox.add(XBox);    if(seq.getLength()>MAXSEQLENGTH)      MAXSEQLENGTH = seq.getLength();    Dimension actual = gs.getMaximumSize();    int slen = gs.getResidueWidth()*(int)(MAXSEQLENGTH*1.2);    gs.setMaximumSize(new Dimension(slen,(int)actual.getHeight()));  }  /**  *  * Get the sequence view size  * @return 	sequence view dimension  *  */  public Dimension getViewSize()  {    hgt = 1;    len = 0;     Enumeration enumer = graphicSequence.elements();    while(enumer.hasMoreElements())    {      SequenceJPanel gs = (SequenceJPanel)enumer.nextElement();      hgt = hgt+gs.getSequenceHeight();      if(len<gs.getSequenceWidth())        len = gs.getSequenceWidth();    }    if(pc !=null)     {      Dimension dplot = pc.getPreferredSize();      hgt = hgt + (int)dplot.getHeight() + plotConStrut;    }    return new Dimension(len,hgt);  }  public String getName(int i)  {    return ((Sequence)seqs.get(i)).getName();  }  /**  *  * Get the sequence name view size  * @return	sequence name dimension  *  */  public Dimension getNameViewSize()  {    int hgtName = getNameHeight();    int lenName = getNameWidth();    return new Dimension(lenName,hgtName);  }  /**  *  * Get the sequence view size  * @return     sequence view dimension  *  */  public Dimension getPanelSize()  {    getViewSize();    return new Dimension(len,hgt);  }  /**  *  * Get the sequence name panel height   * @return     sequence name panel height  *  */  public int getNameHeight()  {    int hgtName = 0;    Enumeration enumer = graphicName.elements();    while(enumer.hasMoreElements())      hgtName = hgtName+          ((SequenceNameJButton)enumer.nextElement()).getPanelHeight();    return hgtName;  }  /**  *  * Get the sequence name panel width  * @return     sequence name panel width  *  */  public int getNameWidth()  {    int lenName = 0;    Enumeration enumer = graphicName.elements();    while(enumer.hasMoreElements())    {      SequenceNameJButton gs = (SequenceNameJButton)enumer.nextElement();      if(lenName<gs.getPanelWidth())        lenName = gs.getPanelWidth();    }    return lenName;  }   /**  *  * Set the sequence name panel width  * @param x	sequence name panel  width  *  */  public void setNamePanelWidth(int x)  {    seqNamePanel.setPreferredSize(new Dimension(x,1000));  }  /**  *  * Get the sequence panel height  * @return     sequence panel height  *  */  public int getPanelHeight()  {    getViewSize();    return hgt;  }  /**  *  * Get the sequence panel width  * @return     sequence panel width  *  */  public int getPanelWidth()  {//  getNameViewSize();    getViewSize();    return len;  }  /**  *  * Get the vector containing the SequenceJPanel objects  * @return	vector containing the SequenceJPanel objects  *  */  public Vector getGraphicSequence()  {    return graphicSequence;  }  /**  *  * Draw the boxes around the residues of each sequence  * @param	true to draw boxes, false not to display  *		boxes  *  */  public void setDrawBoxes(boolean drawBlackBox)  {    this.drawBlackBox = drawBlackBox;    Enumeration enumer = graphicSequence.elements();    while(enumer.hasMoreElements())      ((SequenceJPanel)(enumer.nextElement())).setDrawBoxes(drawBlackBox);    setJScrollPaneViewportView();  }  /**  *  * Draw the residue colours in each sequence  * @param      true to display colour, false not to display  *             colour  *  */  public void setDrawColor(boolean drawColorBox)  {    this.drawColorBox = drawColorBox;    Enumeration enumer = graphicSequence.elements();    while(enumer.hasMoreElements())      ((SequenceJPanel)(enumer.nextElement())).setDrawColor(drawColorBox);    setJScrollPaneViewportView();  }  /**  *  * Set the font size of the sequences in the editor  * @param	font size to use  *  */  public void setFontSizeForCollection(int fs)  {    Enumeration enumer = graphicSequence.elements();    while(enumer.hasMoreElements())    {      SequenceJPanel gs = (SequenceJPanel)enumer.nextElement();      gs.setFontSize(fs);      Dimension actual = gs.getMaximumSize();      int slen = gs.getResidueWidth()*(int)(MAXSEQLENGTH*1.2);      gs.setMaximumSize(new Dimension(slen,(int)actual.getHeight()));    }    Enumeration enumName = graphicName.elements();    while(enumName.hasMoreElements())    {      SequenceNameJButton snjp = (SequenceNameJButton)enumName.nextElement();      snjp.setFontSize(fs);      snjp.setMaximumSize(snjp.getPreferredSize());    }

⌨️ 快捷键说明

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