From: gmungoc Date: Thu, 26 Sep 2019 15:36:29 +0000 (+0100) Subject: JAL-3383 removing colour caching (to a separate branch) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f5974107dd25f8122ebb924e400335e62b1e5daf;p=jalview.git JAL-3383 removing colour caching (to a separate branch) --- diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 599d3a9..7b97d49 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -2034,13 +2034,4 @@ public class Alignment implements AlignmentI } } - @Override - public void resetColors() - { - for (int i = getHeight(); --i >= 0;) - { - sequences.get(i).resetColors(); - } - } - } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index ebf4da3..93a2456 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -624,10 +624,4 @@ public interface AlignmentI extends AnnotatedCollectionI public HiddenColumns propagateInsertions(SequenceI profileseq, AlignmentView input); - /** - * Remove all color already assigned to sequences, causing them to be be - * recalculated. - */ - void resetColors(); - } diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 47a7ead..6c0e528 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -118,11 +118,6 @@ public class Sequence extends ASequence implements SequenceI */ private int changeCount; - /* - * cached rgb colours for each position of the aligned sequence (column) - */ - private int[] argb; - /** * Creates a new Sequence object. * @@ -2022,7 +2017,6 @@ public class Sequence extends ASequence implements SequenceI @Override public void sequenceChanged() { - argb = null; changeCount++; } @@ -2125,28 +2119,6 @@ public class Sequence extends ASequence implements SequenceI return 0; } - @Override - public int getColor(int i) - { - return argb == null ? 0 : argb[i]; - } - - @Override - public int setColor(int i, int rgb) - { - if (argb == null) - { - argb = new int[this.sequence.length]; - } - return (argb[i] = rgb); - } - - @Override - public void resetColors() - { - argb = null; - } - /** * Answers a (possibly empty) list of features of the specified type that * overlap the specified column position. If parameter {@code result} is not diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index ca12c83..851ef79 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -591,30 +591,6 @@ public interface SequenceI extends ASequenceI public int firstResidueOutsideIterator(Iterator it); /** - * @author Bob Hanson 2019.07.30 - * - * get a 4-byte color, with caching - * - */ - public int getColor(int i); - - /** - * @author Bob Hanson 2019.07.30 - * - * set a 4-byte color, with caching - * - */ - public int setColor(int i, int argb); - - /** - * @author Bob Hanson 2019.07.30 - * - * allows resetting the color cache - * - */ - public void resetColors(); - - /** * Answers a (possibly empty) list of features of the specified type that * overlap the specified column position. If parameter {@code result} is not * null, features are appended to it and the (possibly extended) list is diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 597eb5b..0b84e9b 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4528,7 +4528,6 @@ public class AlignFrame extends GAlignFrame { viewport.setShowSequenceFeatures(true); showSeqFeatures.setSelected(true); - alignPanel.getAlignment().resetColors(); } } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index b636fa7..2f5d83b 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -845,7 +845,6 @@ public class AlignmentPanel extends GAlignmentPanel implements if (overviewPanel != null) { - getAlignment().resetColors(); overviewPanel.updateOverviewImage(); } } diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index 8d7980a..7207dea 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -124,20 +124,13 @@ public class OverviewResColourFinder extends ResidueColourFinder SequenceGroup[] allGroups, final SequenceI seq, int i, FeatureColourFinder finder) { - - int c = seq.getColor(i); - if (c != 0) - { - return c; - } - 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 seq.setColor(i, col); + return col; } @Override diff --git a/test/jalview/renderer/OverviewRendererTest.java b/test/jalview/renderer/OverviewRendererTest.java index 159c814..0a77b65 100644 --- a/test/jalview/renderer/OverviewRendererTest.java +++ b/test/jalview/renderer/OverviewRendererTest.java @@ -82,13 +82,11 @@ public class OverviewRendererTest fr.findAllFeatures(true); av.setShowSequenceFeatures(true); fr.setColour("Pfam", new FeatureColour(Color.yellow)); - seq1.resetColors(); assertEquals(or.getColumnColourFromSequence(null, seq1, 0), Color.yellow.getRGB()); // don't show sequence features av.setShowSequenceFeatures(false); - seq1.resetColors(); assertEquals(or.getColumnColourFromSequence(null, seq1, 0), Color.magenta.getRGB()); } diff --git a/test/jalview/renderer/OverviewResColourFinderTest.java b/test/jalview/renderer/OverviewResColourFinderTest.java index bf1237d..76beab8 100644 --- a/test/jalview/renderer/OverviewResColourFinderTest.java +++ b/test/jalview/renderer/OverviewResColourFinderTest.java @@ -137,7 +137,6 @@ public class OverviewResColourFinderTest } av.setGlobalColourScheme(new UserColourScheme(newColours)); - seq.resetColors(); // gap colour not specified so gaps are lightGray assertEquals(Color.lightGray, rcf @@ -146,7 +145,6 @@ public class OverviewResColourFinderTest newColours[23] = Color.pink; av.setGlobalColourScheme(new UserColourScheme(newColours)); - seq.resetColors(); // gap colour specified as pink assertEquals(Color.pink, rcf.getResidueColour(true, @@ -156,14 +154,12 @@ public class OverviewResColourFinderTest // unaffected by showBoxes setting // gap colour not specified so gaps are lightGray newColours[23] = null; - seq.resetColors(); assertEquals(Color.lightGray, rcf.getResidueColour(false, av.getResidueShading(), null, seq, 3, null)); newColours[23] = Color.pink; av.setGlobalColourScheme(new UserColourScheme(newColours)); - seq.resetColors(); // gap colour specified as pink assertEquals(Color.pink, rcf.getResidueColour(false, @@ -202,8 +198,6 @@ public class OverviewResColourFinderTest // use legacy colouring rcf = new OverviewResColourFinder(true, Color.blue, Color.red); - - seq.resetColors(); // G in group specified as magenta in Zappo assertEquals(Color.magenta, rcf.getResidueColour(false, @@ -220,8 +214,6 @@ public class OverviewResColourFinderTest // use new colouring rcf = new OverviewResColourFinder(false, Color.blue, Color.red); - seq.resetColors(); - // G in group specified as magenta in Zappo assertEquals(Color.magenta, rcf.getResidueColour(false, av.getResidueShading(), groups, seq, 7, null)); @@ -247,8 +239,6 @@ public class OverviewResColourFinderTest ResidueColourFinder rcf = new OverviewResColourFinder(); ResidueShaderI shader = new ResidueShader(); - seq.resetColors(); - // residues white Color c = rcf.getBoxColour(shader, seq, 0); assertEquals(Color.white, c); @@ -263,8 +253,6 @@ public class OverviewResColourFinderTest rcf = new OverviewResColourFinder(true, Color.blue, Color.red); shader = new ResidueShader(); - seq.resetColors(); - // residues light gray c = rcf.getBoxColour(shader, seq, 0); assertEquals(Color.lightGray, c); @@ -277,8 +265,6 @@ public class OverviewResColourFinderTest rcf = new OverviewResColourFinder(); shader = new ResidueShader(); - seq.resetColors(); - // residues white c = rcf.getBoxColour(shader, seq, 0); assertEquals(Color.white, c); @@ -293,8 +279,6 @@ public class OverviewResColourFinderTest rcf = new OverviewResColourFinder(false, Color.blue, Color.red); shader = new ResidueShader(new ZappoColourScheme()); - seq.resetColors(); - // M residue pink c = rcf.getBoxColour(shader, seq, 0); assertEquals(Color.pink, c); @@ -306,8 +290,6 @@ public class OverviewResColourFinderTest // legacy colouring with colour scheme rcf = new OverviewResColourFinder(true, Color.blue, Color.red); - seq.resetColors(); - // M residue pink c = rcf.getBoxColour(shader, seq, 0); assertEquals(Color.pink, c);