X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=0553fef37f19fdbd6de5462fd3112e6b7d2fcf98;hb=bd53adc27eab07569b1944a7c33f31c41dad785f;hp=d21b39e433171a8ba1f6ae05496fe088ec7242d2;hpb=8c6a0091158548409984e31ffbb9d52516b95fa5;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java old mode 100755 new mode 100644 index d21b39e..0553fef --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -1,76 +1,54 @@ -package jalview.gui; - -import jalview.datamodel.*; -import jalview.schemes.*; -import java.awt.*; -import java.util.*; - -public class FeatureRenderer implements RendererI -{ - AlignViewport av; - - SequenceGroup currentSequenceGroup = null; - SequenceGroup [] allGroups = null; - Color resBoxColour; - Graphics graphics; - - public FeatureRenderer(AlignViewport av) - { - this.av = av; - } - - - public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height, Vector pid, int seqnum) - { - Vector features = seq.getSequenceFeatures(); - Enumeration e = features.elements(); - while( e.hasMoreElements() ) - { - SequenceFeature sf = (SequenceFeature)e.nextElement(); - int fstart = seq.findIndex(sf.getStart())-1; - int fend = seq.findIndex(sf.getEnd())-1; - - if( (fstart<=end && fend>=start) ) - { - if(fstart<0) // fix for if the feature we have starts before the sequence start, - fstart = 0;// but the feature end is still valid!! - - if(fstart==fend) - { - g.setColor(Color.red); - g.fillRoundRect( (fstart - start) * width, y1, width, height, 4,4); - g.setColor(Color.white); - - char s = seq.getSequence().charAt(fstart); - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s))/2; - int pady = height/5; - g.drawString(String.valueOf(s), charOffset + x1 + width * (fstart - start), y1 + height - pady); - - } - else - { - for (int i = fstart; i <= fend; i++) - { - try{ - g.setColor(Color.blue); - g.fillRect( (i-start) * width, y1, width, height); - - g.setColor(Color.white); - char s = seq.getSequence().charAt(i); - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + width * (i-start), - y1 + height - pady); - - }catch(Exception ex){System.out.println(i+" "+fstart+" "+fend+" " +sf.getDescription()+" "+seq.getName()+" "+seq.getLength()); } - } - } - } - - } - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.gui; + +import java.awt.Color; + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class FeatureRenderer + extends jalview.renderer.seqfeatures.FeatureRenderer +{ + Color resBoxColour; + + AlignmentPanel ap; + + /** + * Creates a new FeatureRenderer object + * + * @param alignPanel + */ + public FeatureRenderer(AlignmentPanel alignPanel) + { + super(alignPanel.av); + this.ap = alignPanel; + if (alignPanel.getSeqPanel() != null + && alignPanel.getSeqPanel().seqCanvas != null + && alignPanel.getSeqPanel().seqCanvas.fr != null) + { + transferSettings(alignPanel.getSeqPanel().seqCanvas.fr); + } + } +}