From: gmungoc Date: Fri, 27 Sep 2019 11:27:35 +0000 (+0100) Subject: JAL-3383 get color as int options removed (to separate branch 3443) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=732b23aab5c88efbd8ca24db9e432345492ed9b1;p=jalview.git JAL-3383 get color as int options removed (to separate branch 3443) --- diff --git a/src/jalview/renderer/OverviewRenderer.java b/src/jalview/renderer/OverviewRenderer.java index f99a7ee..82e89e5 100644 --- a/src/jalview/renderer/OverviewRenderer.java +++ b/src/jalview/renderer/OverviewRenderer.java @@ -167,7 +167,7 @@ public class OverviewRenderer * @param alignment * @param resshader * @param colFinder - * @param shwoProgress + * @param showProgress * possibly not, in JavaScript and for testng */ public OverviewRenderer(AlignmentViewPanel panel, @@ -530,8 +530,8 @@ public class OverviewRenderer { 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()); } /** diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index 7207dea..8206b32 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -22,7 +22,6 @@ package jalview.renderer; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; -import jalview.renderer.seqfeatures.FeatureColourFinder; import jalview.util.Comparison; import java.awt.Color; @@ -38,12 +37,10 @@ public class OverviewResColourFinder extends ResidueColourFinder 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; @@ -80,73 +77,33 @@ public class OverviewResColourFinder extends ResidueColourFinder 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) { @@ -154,13 +111,13 @@ public class OverviewResColourFinder extends ResidueColourFinder 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() { diff --git a/src/jalview/renderer/ResidueColourFinder.java b/src/jalview/renderer/ResidueColourFinder.java index 2e45117..2fc3684 100644 --- a/src/jalview/renderer/ResidueColourFinder.java +++ b/src/jalview/renderer/ResidueColourFinder.java @@ -135,7 +135,8 @@ public class ResidueColourFinder } /** - * 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 diff --git a/src/jalview/renderer/ResidueShader.java b/src/jalview/renderer/ResidueShader.java index 73a5efd..c031170 100644 --- a/src/jalview/renderer/ResidueShader.java +++ b/src/jalview/renderer/ResidueShader.java @@ -262,36 +262,6 @@ public class ResidueShader implements ResidueShaderI 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 @@ -323,20 +293,6 @@ public class ResidueShader implements ResidueShaderI 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 @@ -442,45 +398,6 @@ public class ResidueShader implements ResidueShaderI 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() */ diff --git a/src/jalview/renderer/ResidueShaderI.java b/src/jalview/renderer/ResidueShaderI.java index 2f14a5d..4d97171 100644 --- a/src/jalview/renderer/ResidueShaderI.java +++ b/src/jalview/renderer/ResidueShaderI.java @@ -82,6 +82,4 @@ public interface ResidueShaderI public abstract void setColourScheme(ColourSchemeI cs); - int findColourInt(char symbol, int position, SequenceI seq); - } \ No newline at end of file diff --git a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java index a2ce35b..703f220 100644 --- a/src/jalview/renderer/seqfeatures/FeatureColourFinder.java +++ b/src/jalview/renderer/seqfeatures/FeatureColourFinder.java @@ -117,36 +117,6 @@ public class FeatureColourFinder 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 diff --git a/src/jalview/renderer/seqfeatures/FeatureRenderer.java b/src/jalview/renderer/seqfeatures/FeatureRenderer.java index 0d8185e..cccd916 100644 --- a/src/jalview/renderer/seqfeatures/FeatureRenderer.java +++ b/src/jalview/renderer/seqfeatures/FeatureRenderer.java @@ -102,9 +102,6 @@ public class FeatureRenderer extends FeatureRendererModel 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; @@ -300,9 +297,12 @@ public class FeatureRenderer extends FeatureRendererModel 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; diff --git a/src/jalview/util/ColorUtils.java b/src/jalview/util/ColorUtils.java index a2d8d3e..3eb080b 100644 --- a/src/jalview/util/ColorUtils.java +++ b/src/jalview/util/ColorUtils.java @@ -199,42 +199,6 @@ public class ColorUtils } } - 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 *