From 1d0f5219658cdf6ad5e1a1cbe6e1bb8cd12e6d85 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 9 Oct 2018 13:22:48 +0100 Subject: [PATCH] JAL-3127 pass reference to AlignViewportI when creating an instance of ColourSchemeI --- examples/groovy/colourConserved.groovy | 3 +- examples/groovy/colourSchemes.groovy | 3 +- examples/groovy/colourUnconserved.groovy | 1 + src/jalview/appletgui/AlignViewport.java | 6 +-- src/jalview/appletgui/TreeCanvas.java | 5 ++- src/jalview/bin/Jalview.java | 3 +- src/jalview/gui/AlignFrame.java | 1 + src/jalview/gui/AlignViewport.java | 2 +- src/jalview/gui/AnnotationColourChooser.java | 2 +- src/jalview/gui/Jalview2XML.java | 5 ++- src/jalview/gui/Jalview2XML_V1.java | 3 +- src/jalview/gui/PopupMenu.java | 2 +- src/jalview/gui/StructureViewerBase.java | 3 +- src/jalview/gui/TreeCanvas.java | 3 +- src/jalview/schemes/AnnotationColourGradient.java | 6 ++- src/jalview/schemes/Blosum62ColourScheme.java | 4 +- src/jalview/schemes/BuriedColourScheme.java | 4 +- src/jalview/schemes/ClustalxColourScheme.java | 4 +- src/jalview/schemes/ColourSchemeI.java | 7 +++- src/jalview/schemes/ColourSchemeProperty.java | 5 ++- src/jalview/schemes/ColourSchemes.java | 12 ++++-- src/jalview/schemes/CovariationColourScheme.java | 8 ++-- src/jalview/schemes/FollowerColourScheme.java | 4 +- src/jalview/schemes/HelixColourScheme.java | 4 +- src/jalview/schemes/HydrophobicColourScheme.java | 4 +- src/jalview/schemes/NucleotideColourScheme.java | 4 +- src/jalview/schemes/PIDColourScheme.java | 4 +- .../schemes/PurinePyrimidineColourScheme.java | 4 +- src/jalview/schemes/RNAHelicesColour.java | 8 ++-- .../schemes/RNAInteractionColourScheme.java | 4 +- src/jalview/schemes/ScoreColourScheme.java | 4 +- src/jalview/schemes/StrandColourScheme.java | 4 +- src/jalview/schemes/TCoffeeColourScheme.java | 8 ++-- src/jalview/schemes/TaylorColourScheme.java | 4 +- src/jalview/schemes/TurnColourScheme.java | 4 +- src/jalview/schemes/UserColourScheme.java | 4 +- src/jalview/schemes/ZappoColourScheme.java | 4 +- test/jalview/io/Jalview2xmlTests.java | 4 +- .../schemes/AnnotationColourGradientTest.java | 8 ++-- test/jalview/schemes/ColourSchemePropertyTest.java | 43 +++++++++++--------- test/jalview/schemes/ColourSchemesTest.java | 7 +++- 41 files changed, 145 insertions(+), 77 deletions(-) diff --git a/examples/groovy/colourConserved.groovy b/examples/groovy/colourConserved.groovy index 4a15922..35c54d5 100644 --- a/examples/groovy/colourConserved.groovy +++ b/examples/groovy/colourConserved.groovy @@ -24,6 +24,7 @@ import jalview.schemes.ColourSchemes import jalview.datamodel.AnnotatedCollectionI import jalview.datamodel.SequenceI import jalview.datamodel.SequenceCollectionI +import jalview.api.AlignViewportI import jalview.util.Comparison /* @@ -42,7 +43,7 @@ conserved = { -> /* * to make a new instance for each alignment view */ - getInstance: { AnnotatedCollectionI coll, Map map -> conserved() }, + getInstance: { AlignViewportI view, AnnotatedCollectionI coll, Map map -> conserved() }, /* * method only needed if colour scheme has to recalculate diff --git a/examples/groovy/colourSchemes.groovy b/examples/groovy/colourSchemes.groovy index d5ca973..3f1f953 100644 --- a/examples/groovy/colourSchemes.groovy +++ b/examples/groovy/colourSchemes.groovy @@ -4,6 +4,7 @@ import jalview.schemes.ColourSchemes; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceI; import jalview.datamodel.SequenceCollectionI; +import jalview.api.AlignViewportI /* * Example script that registers two new alignment colour schemes @@ -25,7 +26,7 @@ candy = { -> /* * to make a new instance for each alignment view */ - getInstance: { AnnotatedCollectionI coll, Map map -> candy() }, + getInstance: { AlignViewportI view, AnnotatedCollectionI coll, Map map -> candy() }, /* * method only needed if colour scheme has to recalculate diff --git a/examples/groovy/colourUnconserved.groovy b/examples/groovy/colourUnconserved.groovy index 68730f3..e186766 100644 --- a/examples/groovy/colourUnconserved.groovy +++ b/examples/groovy/colourUnconserved.groovy @@ -24,6 +24,7 @@ import jalview.schemes.ColourSchemes import jalview.datamodel.AnnotatedCollectionI import jalview.datamodel.SequenceI import jalview.datamodel.SequenceCollectionI +import jalview.api.AlignViewportI import jalview.util.Comparison /* diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 262948d..055584a 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -25,14 +25,11 @@ import jalview.api.FeatureSettingsModelI; import jalview.bin.JalviewLite; import jalview.commands.CommandI; import jalview.datamodel.AlignmentI; -import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SearchResults; import jalview.datamodel.SearchResultsI; -import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; import jalview.renderer.ResidueShader; import jalview.schemes.ColourSchemeProperty; import jalview.schemes.UserColourScheme; @@ -200,7 +197,8 @@ public class AlignViewport extends AlignmentViewport if (colour != null) { residueShading = new ResidueShader( - ColourSchemeProperty.getColourScheme(alignment, colour)); + ColourSchemeProperty.getColourScheme(this, alignment, + colour)); if (residueShading != null) { residueShading.setConsensus(hconsensus); diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index 6ee75bd..cb26fb5 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -631,7 +631,7 @@ public class TreeCanvas extends Panel Vector l = tree.findLeaves(groups.get(i)); - Vector sequences = new Vector(); + Vector sequences = new Vector<>(); for (int j = 0; j < l.size(); j++) { SequenceI s1 = (SequenceI) l.elementAt(j).element(); @@ -657,7 +657,8 @@ public class TreeCanvas extends Panel } else { - cs = ColourSchemeProperty.getColourScheme(sg, ColourSchemeProperty + cs = ColourSchemeProperty.getColourScheme(av, sg, + ColourSchemeProperty .getColourName(av.getGlobalColourScheme())); } // cs is null if shading is an annotationColourGradient diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 3270144..88b359f 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -541,7 +541,8 @@ public class Jalview data.replaceAll("%20", " "); ColourSchemeI cs = ColourSchemeProperty - .getColourScheme(af.getViewport().getAlignment(), data); + .getColourScheme(af.getViewport(), + af.getViewport().getAlignment(), data); if (cs != null) { diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 94b38ed..4d1f800 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -3328,6 +3328,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * otherwise set the chosen colour scheme (or null for 'None') */ ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name, + viewport, viewport.getAlignment(), viewport.getHiddenRepSequences()); changeColour(cs); } diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 7e77bec..ef24011 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -290,7 +290,7 @@ public class AlignViewport extends AlignmentViewport ResidueColourScheme.NONE); } ColourSchemeI colourScheme = ColourSchemeProperty - .getColourScheme(alignment, schemeName); + .getColourScheme(this, alignment, schemeName); residueShading = new ResidueShader(colourScheme); if (colourScheme instanceof UserColourScheme) diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 384635b..9626309 100644 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -454,7 +454,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter continue; } sg.setColourScheme( - acg.getInstance(sg, ap.av.getHiddenRepSequences())); + acg.getInstance(av, sg, ap.av.getHiddenRepSequences())); } } } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 9285754..0c31a2a 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -4553,7 +4553,8 @@ public class Jalview2XML } else { - cs = ColourSchemeProperty.getColourScheme(al, view.getBgColour()); + cs = ColourSchemeProperty.getColourScheme(af.viewport, al, + view.getBgColour()); } } @@ -4893,7 +4894,7 @@ public class Jalview2XML else { cs = new AnnotationColourGradient(matchedAnnotation, - ColourSchemeProperty.getColourScheme(al, + ColourSchemeProperty.getColourScheme(af.viewport, al, viewAnnColour.getColourScheme()), viewAnnColour.getAboveThreshold()); } diff --git a/src/jalview/gui/Jalview2XML_V1.java b/src/jalview/gui/Jalview2XML_V1.java index 331e738..eb494e3 100755 --- a/src/jalview/gui/Jalview2XML_V1.java +++ b/src/jalview/gui/Jalview2XML_V1.java @@ -400,7 +400,8 @@ public class Jalview2XML_V1 } else { - cs = ColourSchemeProperty.getColourScheme(al, view.getBgColour()); + cs = ColourSchemeProperty.getColourScheme(af.viewport, al, + view.getBgColour()); } // if (cs != null) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index ed3d29a..d114a8a 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -2126,7 +2126,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener * switch to the chosen colour scheme (or null for None) */ ColourSchemeI colourScheme = ColourSchemes.getInstance() - .getColourScheme(colourSchemeName, sg, + .getColourScheme(colourSchemeName, ap.av, sg, ap.av.getHiddenRepSequences()); sg.setColourScheme(colourScheme); if (colourScheme instanceof Blosum62ColourScheme diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 72b0bcc..35a5475 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -564,7 +564,8 @@ public abstract class StructureViewerBase extends GStructureViewer { AlignmentI al = getAlignmentPanel().av.getAlignment(); ColourSchemeI cs = ColourSchemes.getInstance() - .getColourScheme(colourSchemeName, al, null); + .getColourScheme(colourSchemeName, getAlignmentPanel().av, al, + null); getBinding().setJalviewColourScheme(cs); } diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index fa30e13..278e682 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -1017,7 +1017,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } else { - cs = ColourSchemeProperty.getColourScheme(sg, ColourSchemeProperty + cs = ColourSchemeProperty.getColourScheme(av, sg, + ColourSchemeProperty .getColourName(av.getGlobalColourScheme())); } // cs is null if shading is an annotationColourGradient diff --git a/src/jalview/schemes/AnnotationColourGradient.java b/src/jalview/schemes/AnnotationColourGradient.java index c28ea5f..334998f 100755 --- a/src/jalview/schemes/AnnotationColourGradient.java +++ b/src/jalview/schemes/AnnotationColourGradient.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; @@ -76,7 +77,8 @@ public class AnnotationColourGradient extends FollowerColourScheme private IdentityHashMap seqannot = null; @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { AnnotationColourGradient acg = new AnnotationColourGradient(annotation, @@ -185,7 +187,7 @@ public class AnnotationColourGradient extends FollowerColourScheme } else { - seqannot = new IdentityHashMap(); + seqannot = new IdentityHashMap<>(); } // resolve the context containing all the annotation for the sequence AnnotatedCollectionI alcontext = alignment instanceof AlignmentI diff --git a/src/jalview/schemes/Blosum62ColourScheme.java b/src/jalview/schemes/Blosum62ColourScheme.java index 02f9b3e..202fc25 100755 --- a/src/jalview/schemes/Blosum62ColourScheme.java +++ b/src/jalview/schemes/Blosum62ColourScheme.java @@ -21,6 +21,7 @@ package jalview.schemes; import jalview.analysis.scoremodels.ScoreModels; +import jalview.api.AlignViewportI; import jalview.api.analysis.PairwiseScoreModelI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; @@ -46,7 +47,8 @@ public class Blosum62ColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new Blosum62ColourScheme(); diff --git a/src/jalview/schemes/BuriedColourScheme.java b/src/jalview/schemes/BuriedColourScheme.java index a3b85b9..290ace8 100755 --- a/src/jalview/schemes/BuriedColourScheme.java +++ b/src/jalview/schemes/BuriedColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -75,7 +76,8 @@ public class BuriedColourScheme extends ScoreColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new BuriedColourScheme(); diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index ec13343..3a9f8f7 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -335,7 +336,8 @@ public class ClustalxColourScheme extends ResidueColourScheme } @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { ClustalxColourScheme css = new ClustalxColourScheme(sg, diff --git a/src/jalview/schemes/ColourSchemeI.java b/src/jalview/schemes/ColourSchemeI.java index d70b4e2..02ea887 100755 --- a/src/jalview/schemes/ColourSchemeI.java +++ b/src/jalview/schemes/ColourSchemeI.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -62,11 +63,15 @@ public interface ColourSchemeI * new instance for each call to this method, as different instances may have * differing shading by consensus or percentage identity applied. * + * @param viewport + * - the parent viewport * @param sg + * - the collection of sequences to be coloured * @param hiddenRepSequences * @return copy of current scheme with any inherited settings transferred */ - ColourSchemeI getInstance(AnnotatedCollectionI sg, + ColourSchemeI getInstance(AlignViewportI viewport, + AnnotatedCollectionI sg, Map hiddenRepSequences); /** diff --git a/src/jalview/schemes/ColourSchemeProperty.java b/src/jalview/schemes/ColourSchemeProperty.java index fc92cd9..2d5b23d 100755 --- a/src/jalview/schemes/ColourSchemeProperty.java +++ b/src/jalview/schemes/ColourSchemeProperty.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.util.ColorUtils; @@ -75,7 +76,8 @@ public class ColourSchemeProperty * @param name * @return */ - public static ColourSchemeI getColourScheme(AnnotatedCollectionI forData, + public static ColourSchemeI getColourScheme(AlignViewportI view, + AnnotatedCollectionI forData, String name) { if (ResidueColourScheme.NONE.equalsIgnoreCase(name)) @@ -89,6 +91,7 @@ public class ColourSchemeProperty * create a new instance of it */ ColourSchemeI scheme = ColourSchemes.getInstance().getColourScheme(name, + view, forData, null); if (scheme != null) { diff --git a/src/jalview/schemes/ColourSchemes.java b/src/jalview/schemes/ColourSchemes.java index 99e9759..c3d0ea0 100644 --- a/src/jalview/schemes/ColourSchemes.java +++ b/src/jalview/schemes/ColourSchemes.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -65,7 +66,7 @@ public class ColourSchemes * store in an order-preserving map, so items can be added to menus * in the order in which they are 'discovered' */ - schemes = new LinkedHashMap(); + schemes = new LinkedHashMap<>(); for (JalviewColourScheme cs : JalviewColourScheme.values()) { @@ -76,6 +77,7 @@ public class ColourSchemes { System.err.println("Error instantiating colour scheme for " + cs.toString() + " " + e.getMessage()); + e.printStackTrace(); } } } @@ -126,6 +128,7 @@ public class ColourSchemes * * @param name * name of the colour scheme + * @param viewport * @param forData * the data to be coloured * @param optional @@ -134,7 +137,7 @@ public class ColourSchemes * @return */ public ColourSchemeI getColourScheme(String name, - AnnotatedCollectionI forData, + AlignViewportI viewport, AnnotatedCollectionI forData, Map hiddenRepSequences) { if (name == null) @@ -142,7 +145,8 @@ public class ColourSchemes return null; } ColourSchemeI cs = schemes.get(name.toLowerCase()); - return cs == null ? null : cs.getInstance(forData, hiddenRepSequences); + return cs == null ? null + : cs.getInstance(viewport, forData, hiddenRepSequences); } /** @@ -158,7 +162,7 @@ public class ColourSchemes public ColourSchemeI getColourScheme(String name, AnnotatedCollectionI forData) { - return getColourScheme(name, forData, null); + return getColourScheme(name, null, forData, null); } /** diff --git a/src/jalview/schemes/CovariationColourScheme.java b/src/jalview/schemes/CovariationColourScheme.java index 923bd85..41acef3 100644 --- a/src/jalview/schemes/CovariationColourScheme.java +++ b/src/jalview/schemes/CovariationColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; @@ -38,9 +39,9 @@ import java.util.Map; */ public class CovariationColourScheme extends ResidueColourScheme { - public Map helixcolorhash = new Hashtable(); + public Map helixcolorhash = new Hashtable<>(); - public Map positionsToHelix = new Hashtable(); + public Map positionsToHelix = new Hashtable<>(); int numHelix = 0; @@ -51,7 +52,8 @@ public class CovariationColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new CovariationColourScheme(coll.getAlignmentAnnotation()[0]); diff --git a/src/jalview/schemes/FollowerColourScheme.java b/src/jalview/schemes/FollowerColourScheme.java index 57c19e5..2cfb072 100644 --- a/src/jalview/schemes/FollowerColourScheme.java +++ b/src/jalview/schemes/FollowerColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -53,7 +54,8 @@ public class FollowerColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new FollowerColourScheme(); diff --git a/src/jalview/schemes/HelixColourScheme.java b/src/jalview/schemes/HelixColourScheme.java index 7123d93..d260ce6 100755 --- a/src/jalview/schemes/HelixColourScheme.java +++ b/src/jalview/schemes/HelixColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -58,7 +59,8 @@ public class HelixColourScheme extends ScoreColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new HelixColourScheme(); diff --git a/src/jalview/schemes/HydrophobicColourScheme.java b/src/jalview/schemes/HydrophobicColourScheme.java index 69af3c9..fcdc10f 100755 --- a/src/jalview/schemes/HydrophobicColourScheme.java +++ b/src/jalview/schemes/HydrophobicColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -75,7 +76,8 @@ public class HydrophobicColourScheme extends ScoreColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new HydrophobicColourScheme(); diff --git a/src/jalview/schemes/NucleotideColourScheme.java b/src/jalview/schemes/NucleotideColourScheme.java index abae733..be672e3 100755 --- a/src/jalview/schemes/NucleotideColourScheme.java +++ b/src/jalview/schemes/NucleotideColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -59,7 +60,8 @@ public class NucleotideColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new NucleotideColourScheme(); diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index fc922b9..6275b74 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceGroup; @@ -92,7 +93,8 @@ public class PIDColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new PIDColourScheme(); diff --git a/src/jalview/schemes/PurinePyrimidineColourScheme.java b/src/jalview/schemes/PurinePyrimidineColourScheme.java index 1b36f30..5c0cc1a 100644 --- a/src/jalview/schemes/PurinePyrimidineColourScheme.java +++ b/src/jalview/schemes/PurinePyrimidineColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -59,7 +60,8 @@ public class PurinePyrimidineColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new PurinePyrimidineColourScheme(); diff --git a/src/jalview/schemes/RNAHelicesColour.java b/src/jalview/schemes/RNAHelicesColour.java index dbc9c03..0011d5c 100644 --- a/src/jalview/schemes/RNAHelicesColour.java +++ b/src/jalview/schemes/RNAHelicesColour.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; @@ -45,7 +46,7 @@ public class RNAHelicesColour extends ResidueColourScheme * Maps sequence positions to the RNA helix they belong to. Key: position, * Value: helix TODO: Revise or drop in favour of annotation position numbers */ - public Hashtable positionsToHelix = new Hashtable(); + public Hashtable positionsToHelix = new Hashtable<>(); /** * Number of helices in the RNA secondary structure @@ -132,7 +133,7 @@ public class RNAHelicesColour extends ResidueColourScheme annotation.getRNAStruc(); lastrefresh = annotation._rnasecstr.hashCode(); numHelix = 0; - positionsToHelix = new Hashtable(); + positionsToHelix = new Hashtable<>(); // Figure out number of helices // Length of rnasecstr is the number of pairs of positions that base pair @@ -206,7 +207,8 @@ public class RNAHelicesColour extends ResidueColourScheme } @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { return new RNAHelicesColour(sg); diff --git a/src/jalview/schemes/RNAInteractionColourScheme.java b/src/jalview/schemes/RNAInteractionColourScheme.java index d236803..c2bdd96 100644 --- a/src/jalview/schemes/RNAInteractionColourScheme.java +++ b/src/jalview/schemes/RNAInteractionColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -73,7 +74,8 @@ public class RNAInteractionColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new RNAInteractionColourScheme(); diff --git a/src/jalview/schemes/ScoreColourScheme.java b/src/jalview/schemes/ScoreColourScheme.java index e1b60ca..e0011be 100755 --- a/src/jalview/schemes/ScoreColourScheme.java +++ b/src/jalview/schemes/ScoreColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -119,7 +120,8 @@ public class ScoreColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new ScoreColourScheme(symbolIndex, scores, min, max); diff --git a/src/jalview/schemes/StrandColourScheme.java b/src/jalview/schemes/StrandColourScheme.java index 5f11c29..f318b42 100755 --- a/src/jalview/schemes/StrandColourScheme.java +++ b/src/jalview/schemes/StrandColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -75,7 +76,8 @@ public class StrandColourScheme extends ScoreColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new StrandColourScheme(); diff --git a/src/jalview/schemes/TCoffeeColourScheme.java b/src/jalview/schemes/TCoffeeColourScheme.java index 812dca7..f901892 100644 --- a/src/jalview/schemes/TCoffeeColourScheme.java +++ b/src/jalview/schemes/TCoffeeColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; @@ -83,10 +84,10 @@ public class TCoffeeColourScheme extends ResidueColourScheme // assume only one set of TCOFFEE scores - but could have more than one // potentially. - List annots = new ArrayList(); + List annots = new ArrayList<>(); // Search alignment to get all tcoffee annotation and pick one set of // annotation to use to colour seqs. - seqMap = new IdentityHashMap(); + seqMap = new IdentityHashMap<>(); AnnotatedCollectionI alcontext = alignment instanceof AlignmentI ? alignment : alignment.getContext(); @@ -143,7 +144,8 @@ public class TCoffeeColourScheme extends ResidueColourScheme } @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { return new TCoffeeColourScheme(sg); diff --git a/src/jalview/schemes/TaylorColourScheme.java b/src/jalview/schemes/TaylorColourScheme.java index ac8abbc..74448e3 100755 --- a/src/jalview/schemes/TaylorColourScheme.java +++ b/src/jalview/schemes/TaylorColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -50,7 +51,8 @@ public class TaylorColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new TaylorColourScheme(); diff --git a/src/jalview/schemes/TurnColourScheme.java b/src/jalview/schemes/TurnColourScheme.java index 67116b8..0af913b 100755 --- a/src/jalview/schemes/TurnColourScheme.java +++ b/src/jalview/schemes/TurnColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -75,7 +76,8 @@ public class TurnColourScheme extends ScoreColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new TurnColourScheme(); diff --git a/src/jalview/schemes/UserColourScheme.java b/src/jalview/schemes/UserColourScheme.java index bf62e45..16c9f78 100755 --- a/src/jalview/schemes/UserColourScheme.java +++ b/src/jalview/schemes/UserColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -56,7 +57,8 @@ public class UserColourScheme extends ResidueColourScheme } @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { return new UserColourScheme(this); diff --git a/src/jalview/schemes/ZappoColourScheme.java b/src/jalview/schemes/ZappoColourScheme.java index c32a39c..ee3bae6 100755 --- a/src/jalview/schemes/ZappoColourScheme.java +++ b/src/jalview/schemes/ZappoColourScheme.java @@ -20,6 +20,7 @@ */ package jalview.schemes; +import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -59,7 +60,8 @@ public class ZappoColourScheme extends ResidueColourScheme * be coloured */ @Override - public ColourSchemeI getInstance(AnnotatedCollectionI coll, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI coll, Map hrs) { return new ZappoColourScheme(); diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index 53bb0e7..8b65c3d 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -139,7 +139,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null); assertSame(af.getViewport().getGlobalColourScheme().getClass(), TCoffeeColourScheme.class, "Didn't set T-coffee colourscheme"); - assertNotNull(ColourSchemeProperty.getColourScheme(af.getViewport() + assertNotNull( + ColourSchemeProperty.getColourScheme(af.getViewport(), + af.getViewport() .getAlignment(), af.getViewport().getGlobalColourScheme() .getSchemeName()), "Recognise T-Coffee score from string"); diff --git a/test/jalview/schemes/AnnotationColourGradientTest.java b/test/jalview/schemes/AnnotationColourGradientTest.java index b7a5164..4a5e057 100644 --- a/test/jalview/schemes/AnnotationColourGradientTest.java +++ b/test/jalview/schemes/AnnotationColourGradientTest.java @@ -184,7 +184,7 @@ public class AnnotationColourGradientTest { AnnotationColourGradient testee = new AnnotationColourGradient(ann, minColour, maxColour, AnnotationColourGradient.ABOVE_THRESHOLD); - testee = (AnnotationColourGradient) testee.getInstance(al, null); + testee = (AnnotationColourGradient) testee.getInstance(null, al, null); for (int col = 0; col < WIDTH; col++) { @@ -226,7 +226,7 @@ public class AnnotationColourGradientTest { AnnotationColourGradient testee = new AnnotationColourGradient(ann, minColour, maxColour, AnnotationColourGradient.BELOW_THRESHOLD); - testee = (AnnotationColourGradient) testee.getInstance(al, null); + testee = (AnnotationColourGradient) testee.getInstance(null, al, null); for (int col = 0; col < WIDTH; col++) { @@ -259,7 +259,7 @@ public class AnnotationColourGradientTest { AnnotationColourGradient testee = new AnnotationColourGradient(ann, minColour, maxColour, AnnotationColourGradient.NO_THRESHOLD); - testee = (AnnotationColourGradient) testee.getInstance(al, null); + testee = (AnnotationColourGradient) testee.getInstance(null, al, null); for (int col = 0; col < WIDTH; col++) { @@ -278,7 +278,7 @@ public class AnnotationColourGradientTest { AnnotationColourGradient testee = new AnnotationColourGradient(ann, minColour, maxColour, AnnotationColourGradient.NO_THRESHOLD); - testee = (AnnotationColourGradient) testee.getInstance(al, null); + testee = (AnnotationColourGradient) testee.getInstance(null, al, null); /* * flag corresponding to 'use original colours' checkbox diff --git a/test/jalview/schemes/ColourSchemePropertyTest.java b/test/jalview/schemes/ColourSchemePropertyTest.java index 11562b8..f71d647 100644 --- a/test/jalview/schemes/ColourSchemePropertyTest.java +++ b/test/jalview/schemes/ColourSchemePropertyTest.java @@ -76,51 +76,54 @@ public class ColourSchemePropertyTest SequenceI seq = new Sequence("Seq1", "abcd"); AlignmentI al = new Alignment(new SequenceI[] { seq }); // the strings here correspond to JalviewColourScheme.toString() values - ColourSchemeI cs = ColourSchemeProperty.getColourScheme(al, "Clustal"); + ColourSchemeI cs = ColourSchemeProperty.getColourScheme(null, al, + "Clustal"); assertTrue(cs instanceof ClustalxColourScheme); // not case-sensitive - cs = ColourSchemeProperty.getColourScheme(al, "CLUSTAL"); + cs = ColourSchemeProperty.getColourScheme(null, al, "CLUSTAL"); assertTrue(cs instanceof ClustalxColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "clustal"); + cs = ColourSchemeProperty.getColourScheme(null, al, "clustal"); assertTrue(cs instanceof ClustalxColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Blosum62"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Blosum62"); assertTrue(cs instanceof Blosum62ColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "% Identity"); + cs = ColourSchemeProperty.getColourScheme(null, al, "% Identity"); assertTrue(cs instanceof PIDColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Zappo"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Zappo"); assertTrue(cs instanceof ZappoColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Taylor"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Taylor"); assertTrue(cs instanceof TaylorColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Hydrophobic"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Hydrophobic"); assertTrue(cs instanceof HydrophobicColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Helix Propensity"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Helix Propensity"); assertTrue(cs instanceof HelixColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Strand Propensity"); + cs = ColourSchemeProperty.getColourScheme(null, al, + "Strand Propensity"); assertTrue(cs instanceof StrandColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Turn Propensity"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Turn Propensity"); assertTrue(cs instanceof TurnColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Buried Index"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Buried Index"); assertTrue(cs instanceof BuriedColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Nucleotide"); + cs = ColourSchemeProperty.getColourScheme(null, al, "Nucleotide"); assertTrue(cs instanceof NucleotideColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "Purine/Pyrimidine"); + cs = ColourSchemeProperty.getColourScheme(null, al, + "Purine/Pyrimidine"); assertTrue(cs instanceof PurinePyrimidineColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "T-Coffee Scores"); + cs = ColourSchemeProperty.getColourScheme(null, al, "T-Coffee Scores"); assertTrue(cs instanceof TCoffeeColourScheme); - cs = ColourSchemeProperty.getColourScheme(al, "RNA Helices"); + cs = ColourSchemeProperty.getColourScheme(null, al, "RNA Helices"); assertTrue(cs instanceof RNAHelicesColour); // 'None' is a special value - assertNull(ColourSchemeProperty.getColourScheme(al, "None")); - assertNull(ColourSchemeProperty.getColourScheme(al, "none")); + assertNull(ColourSchemeProperty.getColourScheme(null, al, "None")); + assertNull(ColourSchemeProperty.getColourScheme(null, al, "none")); // default is to convert the name into a fixed colour - cs = ColourSchemeProperty.getColourScheme(al, "elephants"); + cs = ColourSchemeProperty.getColourScheme(null, al, "elephants"); assertTrue(cs instanceof UserColourScheme); /* * explicit aa colours */ UserColourScheme ucs = (UserColourScheme) ColourSchemeProperty - .getColourScheme(al, + .getColourScheme(null, al, "R,G=red;C=blue;c=green;Q=10,20,30;S,T=11ffdd"); assertEquals(ucs.findColour('H'), Color.white); assertEquals(ucs.findColour('R'), Color.red); diff --git a/test/jalview/schemes/ColourSchemesTest.java b/test/jalview/schemes/ColourSchemesTest.java index 0aaa38c..f6f1953 100644 --- a/test/jalview/schemes/ColourSchemesTest.java +++ b/test/jalview/schemes/ColourSchemesTest.java @@ -5,6 +5,7 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; +import jalview.api.AlignViewportI; import jalview.bin.Cache; import jalview.bin.Jalview; import jalview.datamodel.AnnotatedCollectionI; @@ -54,7 +55,8 @@ public class ColourSchemesTest } @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { final ColourSchemeI cs1 = ColourSchemes.getInstance() @@ -144,7 +146,8 @@ public class ColourSchemesTest } @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, + public ColourSchemeI getInstance(AlignViewportI view, + AnnotatedCollectionI sg, Map hiddenRepSequences) { return new MyClustal(sg, hiddenRepSequences); -- 1.7.10.2