/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 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.
- *
+ * 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 <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
-import java.awt.*;
+import jalview.api.FeatureRenderer;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.schemes.ColourSchemeI;
-import jalview.datamodel.*;
-import jalview.schemes.*;
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
/**
* DOCUMENT ME!
// If EPS graphics, stringWidth will be a double, not an int
double dwidth = fm.getStringBounds("M", g).getWidth();
- monospacedFont = (dwidth == fm.getStringBounds("|", g).getWidth() && (float) av.charWidth == dwidth);
+ monospacedFont = (dwidth == fm.getStringBounds("|", g).getWidth() && av.charWidth == dwidth);
this.renderGaps = renderGaps;
}
+ @Override
public Color getResidueBoxColour(SequenceI seq, int i)
{
- allGroups = av.alignment.findAllGroups(seq);
+ allGroups = av.getAlignment().findAllGroups(seq);
if (inCurrentSequenceGroup(i))
{
}
else if (av.getShowBoxes())
{
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
}
return resBoxColour;
}
/**
+ * Get the residue colour at the given sequence position - as determined by
+ * the sequence group colour (if any), else the colour scheme, possibly
+ * overridden by a feature colour.
+ *
+ * @param seq
+ * @param position
+ * @param fr
+ * @return
+ */
+ @Override
+ public Color getResidueColour(final SequenceI seq, int position,
+ FeatureRenderer fr)
+ {
+ // TODO replace 8 or so code duplications with calls to this method
+ // (refactored as needed)
+ Color col = getResidueBoxColour(seq, position);
+
+ if (fr != null)
+ {
+ col = fr.findFeatureColour(col, seq, position);
+ }
+ return col;
+ }
+
+ /**
* DOCUMENT ME!
*
* @param cs
{
if (cs != null)
{
- resBoxColour = cs.findColour(seq.getCharAt(i), i);
+ resBoxColour = cs.findColour(seq.getCharAt(i), i, seq);
}
else if (forOverview
&& !jalview.util.Comparison.isGap(seq.getCharAt(i)))
}
/**
- * draw coloured sequence to the current graphics cursor
+ * DOCUMENT ME!
+ *
+ * @param g
+ * DOCUMENT ME!
* @param seq
+ * DOCUMENT ME!
* @param sg
+ * DOCUMENT ME!
* @param start
+ * DOCUMENT ME!
* @param end
+ * DOCUMENT ME!
+ * @param x1
+ * DOCUMENT ME!
* @param y1
- * @param drawBox - draw background
- * @param drawText - draw text (if shading style permits)
+ * DOCUMENT ME!
+ * @param width
+ * DOCUMENT ME!
+ * @param height
+ * DOCUMENT ME!
*/
public void drawSequence(SequenceI seq, SequenceGroup[] sg, int start,
- int end, int y1, boolean drawBox, boolean drawText)
+ int end, int y1)
{
allGroups = sg;
- if (drawBox) {
- drawBoxes(seq, start, end, y1);
- }
+ drawBoxes(seq, start, end, y1);
- if (av.validCharWidth && drawText)
+ if (av.validCharWidth)
{
drawText(seq, start, end, y1);
}
int y1)
{
if (seq == null)
+ {
return; // fix for racecondition
+ }
int i = start;
int length = seq.getLength();
}
else if (av.getShowBoxes())
{
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
}
}
if (currentSequenceGroup.getShowNonconserved()) // todo optimize
{
// todo - use sequence group consensus
- s = getDisplayChar(av.consensus, i, s, '.');
+ s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s,
+ '.');
}
if (av.getColourText())
{
getboxColour = true;
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
if (av.getShowBoxes())
{
{
if (!getboxColour)
{
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
}
if (resBoxColour.getRed() + resBoxColour.getBlue()
graphics.setColor(av.textColour2);
}
}
- if (av.showUnconserved)
+ if (av.getShowUnconserved())
{
- s = getDisplayChar(av.consensus, i, s, '.');
+ s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s,
+ '.');
}