X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureRenderer.java;h=83badd0da33d0fa9ebbc71b6d8a4e6b00e32903b;hb=0d37fef8a89c67845c14f2383e89003c9a2c5b62;hp=1dd434ddd0563f4d6f64eb5f210f1014aecad729;hpb=99c58ee0ae2a848f982552e53feaf6d5cb9925e5;p=jalview.git diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java old mode 100755 new mode 100644 index 1dd434d..83badd0 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -1,99 +1,47 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ - -package jalview.gui; - -import jalview.datamodel.*; -import jalview.schemes.*; -import java.awt.*; -import java.util.*; - -public class FeatureRenderer -{ - 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 features = seq.getSequenceFeatures(); - Enumeration e = features.elements(); - while( e.hasMoreElements() ) - { - SequenceFeature sf = (SequenceFeature)e.nextElement(); - if(sf.getStart()>seq.getEnd()) - continue; - - 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++) - { - char s = seq.getSequence().charAt(i); - if( jalview.util.Comparison.isGap(s) ) - continue; - - g.setColor(Color.blue); - g.fillRect( (i-start) * width, y1, width, height); - - g.setColor(Color.white); - - 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); - } - } - } - - } - } - -} +/* + * 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; + +/** + * A class that manages drawing of sequence features for the Swing gui + */ +public class FeatureRenderer + extends jalview.renderer.seqfeatures.FeatureRenderer +{ + 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); + } + } +}