* @param alignment
* @param resshader
* @param colFinder
- * @param shwoProgress
+ * @param showProgress
* possibly not, in JavaScript and for testng
*/
public OverviewRenderer(AlignmentViewPanel panel,
{
return (seq == null || icol >= seq.getLength()
? resColFinder.gapColourInt
- : resColFinder.getResidueColourInt(true, shader, allGroups, seq,
- icol, finder));
+ : resColFinder.getResidueColour(true, shader, allGroups, seq,
+ icol, finder).getRGB());
}
/**
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import jalview.renderer.seqfeatures.FeatureColourFinder;
import jalview.util.Comparison;
import java.awt.Color;
final Color gapColour; // colour to use for gaps
- final int gapColourInt;
+ final int gapColourInt; // RGB value of gapColour
final Color residueColour; // colour to use for uncoloured residues
- final int residueColourInt;
-
final Color hiddenColour; // colour for hidden regions
boolean useLegacy = false;
residueColour = Color.WHITE;
}
gapColourInt = gapColour.getRGB();
- residueColourInt = residueColour.getRGB();
hiddenColour = hiddenCol;
}
+ /**
+ * Overrides the method to return the currently configured Overview colours
+ * for gaps, or residues with no colour scheme set. A custom colour scheme
+ * which specifies a colour for gaps overrides the normal gap colour.
+ */
@Override
public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
{
- return new Color(getBoxColourInt(shader, seq, i));
- }
-
- public int getBoxColourInt(ResidueShaderI shader, SequenceI seq, int i)
- {
char currentChar = seq.getCharAt(i);
- // In the overview window, gaps are coloured grey, unless the colour scheme
- // specifies a gap colour, in which case gaps honour the colour scheme
- // settings
boolean isGap = Comparison.isGap(currentChar);
if (shader.getColourScheme() == null)
{
- return (isGap ? gapColourInt : residueColourInt);
+ return (isGap ? gapColour : residueColour);
}
- return (isGap && !shader.getColourScheme().hasGapColour() ? gapColourInt
- : shader.findColourInt(currentChar, i, seq));
- }
-
- @Override
- public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
- SequenceGroup[] allGroups, final SequenceI seq, int i,
- FeatureColourFinder finder)
- {
- Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq, i);
-
- // if there's a FeatureColourFinder we might override the residue colour
- // here with feature colouring
- col = finder == null || finder.noFeaturesDisplayed() ? col
- : finder.findFeatureColour(col, seq, i);
- return col;
- }
-
-
- public int getResidueColourInt(boolean showBoxes, ResidueShaderI shader,
- SequenceGroup[] allGroups, final SequenceI seq, int i,
- FeatureColourFinder finder)
- {
- int col = getResidueBoxColourInt(showBoxes, shader, allGroups, seq, i);
-
- // if there's a FeatureColourFinder we might override the residue colour
- // here with feature colouring
- col = finder == null || finder.noFeaturesDisplayed() ? col
- : finder.findFeatureColourInt(col, seq, i);
- return col;
- }
-
- @Override
- protected Color getResidueBoxColour(boolean showBoxes,
- ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
- int i)
- {
- return new Color(
- getResidueBoxColourInt(showBoxes, shader, allGroups, seq, i));
+ return (isGap && !shader.getColourScheme().hasGapColour() ? gapColour
+ : shader.findColour(currentChar, i, seq));
}
/**
* In the overview, the showBoxes setting is ignored, as the overview displays
- * the colours regardless.
+ * the colours regardless
*/
- protected int getResidueBoxColourInt(boolean showBoxes,
+ @Override
+ protected Color getResidueBoxColour(boolean showBoxes,
ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
int i)
{
i);
ResidueShaderI currentShader = (currentSequenceGroup == null ? shader
: currentSequenceGroup.getGroupColourScheme());
- return getBoxColourInt(currentShader, seq, i);
+ return getBoxColour(currentShader, seq, i);
}
/**
- * Supply hidden colour
+ * Returns the coloured configured for hidden regions in the Overview
*
- * @return colour of hidden regions
+ * @return
*/
protected Color getHiddenColour()
{
}
/**
- * DOCUMENT ME!
+ * Returns the colour to draw the residue's box, as determined by the colour
+ * scheme, or white if no colour scheme is set
*
* @param shader
* the viewport's colour scheme
return colour;
}
- @Override
- public int findColourInt(char symbol, int position, SequenceI seq)
- {
- if (colourScheme == null)
- {
- return -1;// Color.white; // Colour is 'None'
- }
-
- /*
- * get 'base' colour
- */
- ProfileI profile = consensus == null ? null : consensus.get(position);
- String modalResidue = profile == null ? null
- : profile.getModalResidue();
- float pid = profile == null ? 0f
- : profile.getPercentageIdentity(ignoreGaps);
- int colour = colourScheme
- .findColour(symbol, position, seq, modalResidue, pid).getRGB();
-
- /*
- * apply PID threshold and consensus fading if in force
- */
- if (!Comparison.isGap(symbol))
- {
- colour = adjustColourInt(symbol, position, colour);
- }
-
- return colour;
- }
-
/**
* Adjusts colour by applying thresholding or conservation shading, if in
* force. That is
return colour;
}
- protected int adjustColourInt(char symbol, int column, int colour)
- {
- if (!aboveThreshold(symbol, column))
- {
- colour = -1;// Color.white;
- }
-
- if (conservationColouring)
- {
- colour = applyConservationInt(colour, column);
- }
- return colour;
- }
-
/**
* Answers true if there is a consensus profile for the specified column, and
* the given residue matches the consensus (or joint consensus) residue for
return ColorUtils.bleachColour(currentColour, bleachFactor);
}
- protected int applyConservationInt(int currentColour, int column)
- {
- if (conservation == null || conservation.length <= column)
- {
- return currentColour;
- }
- char conservationScore = conservation[column];
-
- /*
- * if residues are fully conserved (* or 11), or all properties
- * are conserved (+ or 10), leave colour unchanged
- */
- if (conservationScore == '*' || conservationScore == '+'
- || conservationScore == (char) 10
- || conservationScore == (char) 11)
- {
- return currentColour;
- }
-
- if (Comparison.isGap(conservationScore))
- {
- return -1;// Color.white;
- }
-
- /*
- * convert score 0-9 to a bleaching factor 1.1 - 0.2
- */
- float bleachFactor = (11 - (conservationScore - '0')) / 10f;
-
- /*
- * scale this up by 0-5 (percentage slider / 20)
- * as a result, scores of: 0 1 2 3 4 5 6 7 8 9
- * fade to white at slider value: 18 20 22 25 29 33 40 50 67 100%
- */
- bleachFactor *= (conservationIncrement / 20f);
-
- return ColorUtils.bleachColourInt(currentColour, bleachFactor);
- }
-
/**
* @see jalview.renderer.ResidueShaderI#getColourScheme()
*/
public abstract void setColourScheme(ColourSchemeI cs);
- int findColourInt(char symbol, int position, SequenceI seq);
-
}
\ No newline at end of file
return c;
}
- public int findFeatureColourInt(int defaultColour, SequenceI seq,
- int column)
- {
- Graphics g = null;
-
- /*
- * if transparency applies, provide a notional 1x1 graphics context
- * that has been primed with the default colour
- */
- if (featureRenderer.getTransparency() != 1f)
- {
- g = goff;
- if (defaultColour != 0)
- {
- offscreenImage.setRGB(0, 0, defaultColour);
- }
- }
-
- Color c = featureRenderer.findFeatureColour(seq, column + 1, g);
- if (c == null)
- {
- return defaultColour;
- }
-
- if (g != null)
- {
- return offscreenImage.getRGB(0, 0);
- }
- return c.getRGB();
- }
/**
* Answers true if feature display is turned off, or there are no features
* configured to be visible
char s = '\0';
for (int i = featureStart; i <= featureEnd; i++)
{
-
- // colourOnly is just for Overview -- no need to check this again
-
if (!colourOnly && Comparison.isGap(s = seq.getCharAt(i)))
{
continue;
if (transparency != 1f)
{
- ((Graphics2D) g).setComposite(
- AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
transparency));
+ // ((Graphics2D) g).setComposite(
+ // AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
+ // transparency));
}
Color drawnColour = null;
}
}
- public static int bleachColourInt(int colour, float bleachFactor)
- {
- if (bleachFactor >= 1f)
- {
- return -1;// Color.WHITE;
- }
- if (bleachFactor <= -1f)
- {
- return 0xFF000000;// Color.BLACK;
- }
- if (bleachFactor == 0f)
- {
- return colour;
- }
-
- int red = (colour >> 16) & 0xFF;// getRed();
- int green = (colour >> 8) & 0xFF;// colour.getGreen();
- int blue = colour & 0xFF;// .getBlue();
-
- if (bleachFactor > 0)
- {
- red += (255 - red) * bleachFactor;
- green += (255 - green) * bleachFactor;
- blue += (255 - blue) * bleachFactor;
- }
- else
- {
- float factor = 1 + bleachFactor;
- red *= factor;
- green *= factor;
- blue *= factor;
- }
- return 0xFF000000 | (red << 16) | (green << 8) | blue;// new Color(red,
- // green, blue);
- }
-
/**
* Parses a string into a Color, where the accepted formats are
* <ul>