From a435a8668f8df568d3bdcf4e286210b69c18920c Mon Sep 17 00:00:00 2001 From: hansonr Date: Mon, 29 Jul 2019 15:34:41 -0500 Subject: [PATCH] JAL-3383 JAL-3253-applet Allows for possibility of a sequence caching its colors for speed; not implemented --- src/jalview/datamodel/Sequence.java | 18 ++++++++ src/jalview/datamodel/SequenceI.java | 6 +++ src/jalview/renderer/OverviewResColourFinder.java | 46 +++++++-------------- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index ca2b6d4..4c46522 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -28,6 +28,7 @@ import jalview.util.DBRefUtils; import jalview.util.MapList; import jalview.util.StringUtils; +import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; @@ -2127,4 +2128,21 @@ public class Sequence extends ASequence implements SequenceI // otherwise, sequence was completely hidden return 0; } + + @Override + public Color getColor(int i) + { + return null; + } + + @Override + public Color setColor(int i, Color c) + { + return c; + } + + @Override + public void resetColors() + { + } } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index 933f332..5e2355d 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -25,6 +25,7 @@ import jalview.datamodel.features.SequenceFeaturesI; import jalview.util.MapList; import jalview.ws.params.InvalidArgumentException; +import java.awt.Color; import java.util.BitSet; import java.util.Iterator; import java.util.List; @@ -584,6 +585,11 @@ public interface SequenceI extends ASequenceI */ public int firstResidueOutsideIterator(Iterator it); + public Color getColor(int i); + + public Color setColor(int i, Color c); + + public void resetColors(); } diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index a497d92..ff52f1d 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -81,30 +81,24 @@ public class OverviewResColourFinder extends ResidueColourFinder @Override public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i) { - Color resBoxColour = RESIDUE_COLOUR; + seq.resetColors(); + Color c = seq.getColor(i); + if (c != null) + { + return c; + } 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 - if (shader.getColourScheme() != null) + boolean isGap = Comparison.isGap(currentChar); + if (shader.getColourScheme() == null) { - if (Comparison.isGap(currentChar) - && (!shader.getColourScheme().hasGapColour())) - { - resBoxColour = GAP_COLOUR; - } - else - { - resBoxColour = shader.findColour(currentChar, i, seq); - } + return seq.setColor(i, isGap ? GAP_COLOUR : RESIDUE_COLOUR); } - else if (Comparison.isGap(currentChar)) - { - resBoxColour = GAP_COLOUR; - } - - return resBoxColour; + return seq.setColor(i, + isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR + : shader.findColour(currentChar, i, seq)); } /** @@ -113,21 +107,13 @@ public class OverviewResColourFinder extends ResidueColourFinder */ @Override protected Color getResidueBoxColour(boolean showBoxes, - ResidueShaderI shader, - SequenceGroup[] allGroups, SequenceI seq, int i) + ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq, + int i) { - ResidueShaderI currentShader; SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups, i); - if (currentSequenceGroup != null) - { - currentShader = currentSequenceGroup.getGroupColourScheme(); - } - else - { - currentShader = shader; - } - + ResidueShaderI currentShader = (currentSequenceGroup == null ? shader + : currentSequenceGroup.getGroupColourScheme()); return getBoxColour(currentShader, seq, i); } -- 1.7.10.2