From: gmungoc Date: Fri, 9 Aug 2019 11:33:50 +0000 (+0100) Subject: JAL-3390 refactoring tidy of colourBySequence call stack X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=daf9317ba5fc502f8030f5dcdefddae0589ec7f2;p=jalview.git JAL-3390 refactoring tidy of colourBySequence call stack --- diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index f0ae6dc..5243b40 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -486,8 +486,13 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel * @param commands */ @Override - protected void colourBySequence(final String[] commands) + protected void colourBySequence(AlignmentViewPanel viewPanel) { + Map map = StructureCommands.buildColoursMap(this, + viewPanel); + + String[] commands = JmolCommands.getColourBySequenceCommand(map); + if (colourby != null) { colourby.interrupt(); @@ -508,20 +513,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } /** - * @param files - * @param viewPanel - * @return - */ - @Override - protected String[] getColourBySequenceCommands( - String[] files, AlignmentViewPanel viewPanel) - { - Map map = StructureCommands.buildColoursMap(this, viewPanel); - - return JmolCommands.getColourBySequenceCommand(map); - } - - /** * @param command */ protected void executeWhenReady(String command) diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index dd0a75e..2846f32 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -647,13 +647,19 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel String progressMsg); /** - * Sends a set of colour commands to the structure viewer + * Constructs a set of colour commands and sends them to the structure viewer * - * @param commands + * @param viewPanel */ @Override - protected void colourBySequence(String[] commands) + protected void colourBySequence(AlignmentViewPanel viewPanel) { + Map colourMap = StructureCommands + .buildColoursMap(this, viewPanel); + + String[] commands = ChimeraCommands + .getColourBySequenceCommand(colourMap, this); + for (String command : commands) { sendAsynchronousCommand(command, COLOURING_CHIMERA); @@ -661,23 +667,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /** - * Computes and returns a set of commands to colour residues in Chimera the same - * as mapped residues in the alignment - * - * @param files - * @param viewPanel - * @return - */ - @Override - protected String[] getColourBySequenceCommands( - String[] files, AlignmentViewPanel viewPanel) - { - Map colourMap = StructureCommands.buildColoursMap(this, viewPanel); - - return ChimeraCommands.getColourBySequenceCommand(colourMap, this); - } - - /** * @param command */ protected void executeWhenReady(String command) @@ -1022,6 +1011,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel /** * Send a 'focus' command to Chimera to recentre the visible display */ + @Override public void focusView() { sendChimeraCommand("focus", false); diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index af5fd0a..448ed24 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -783,9 +783,6 @@ public abstract class AAStructureBindingModel public abstract void setBackgroundColour(Color col); - protected abstract String[] getColourBySequenceCommands( - String[] files, AlignmentViewPanel avp); - /** * returns the current sequenceRenderer that should be used to colour the * structures @@ -797,8 +794,14 @@ public abstract class AAStructureBindingModel public abstract SequenceRenderer getSequenceRenderer( AlignmentViewPanel alignment); - protected abstract void colourBySequence( - String[] colourBySequenceCommands); + /** + * Recolours mapped residues in the structure viewer to match colours in the + * given alignment panel. Colours should also be applied to any hidden mapped + * residues (so that they are shown correctly if these get unhidden). + * + * @param viewPanel + */ + protected abstract void colourBySequence(AlignmentViewPanel viewPanel); public abstract void colourByChain(); @@ -834,11 +837,8 @@ public abstract class AAStructureBindingModel { return; } - String[] files = getStructureFiles(); - String[] colourBySequenceCommands = getColourBySequenceCommands( - files, alignmentv); - colourBySequence(colourBySequenceCommands); + colourBySequence(alignmentv); } public boolean hasFileLoadingError() diff --git a/test/jalview/ext/jmol/JmolCommandsTest.java b/test/jalview/ext/jmol/JmolCommandsTest.java index 45e66ce..35fd179 100644 --- a/test/jalview/ext/jmol/JmolCommandsTest.java +++ b/test/jalview/ext/jmol/JmolCommandsTest.java @@ -91,13 +91,6 @@ public class JmolCommandsTest } @Override - protected String[] getColourBySequenceCommands(String[] files, - AlignmentViewPanel avp) - { - return null; - } - - @Override public jalview.api.SequenceRenderer getSequenceRenderer( AlignmentViewPanel alignment) { @@ -105,7 +98,7 @@ public class JmolCommandsTest } @Override - protected void colourBySequence(String[] colourBySequenceCommands) + protected void colourBySequence(AlignmentViewPanel avp) { } diff --git a/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java b/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java index fb8626c..d5229c2 100644 --- a/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java +++ b/test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java @@ -90,13 +90,6 @@ public class ChimeraCommandsTest } @Override - protected String[] getColourBySequenceCommands(String[] files, - AlignmentViewPanel avp) - { - return null; - } - - @Override public jalview.api.SequenceRenderer getSequenceRenderer( AlignmentViewPanel alignment) { @@ -104,7 +97,7 @@ public class ChimeraCommandsTest } @Override - protected void colourBySequence(String[] colourBySequenceCommands) + protected void colourBySequence(AlignmentViewPanel avp) { } diff --git a/test/jalview/structures/models/AAStructureBindingModelTest.java b/test/jalview/structures/models/AAStructureBindingModelTest.java index 3992746..0bb1daf 100644 --- a/test/jalview/structures/models/AAStructureBindingModelTest.java +++ b/test/jalview/structures/models/AAStructureBindingModelTest.java @@ -138,21 +138,16 @@ public class AAStructureBindingModelTest @Override public void updateColours(Object source) { - // TODO Auto-generated method stub - } @Override public void releaseReferences(Object svl) { - // TODO Auto-generated method stub - } @Override public String[] getStructureFiles() { - // TODO Auto-generated method stub return null; } @@ -160,72 +155,49 @@ public class AAStructureBindingModelTest public String superposeStructures(AlignmentI[] alignments, int[] structureIndices, HiddenColumns[] hiddenCols) { - // TODO Auto-generated method stub return null; } @Override public void setJalviewColourScheme(ColourSchemeI cs) { - // TODO Auto-generated method stub - } @Override public void setBackgroundColour(Color col) { - // TODO Auto-generated method stub - } @Override public void highlightAtoms(List atoms) { - // TODO Auto-generated method stub - } @Override public SequenceRenderer getSequenceRenderer(AlignmentViewPanel alignment) { - // TODO Auto-generated method stub return null; } @Override public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment) { - // TODO Auto-generated method stub return null; } @Override - protected String[] getColourBySequenceCommands(String[] files, - AlignmentViewPanel avp) + protected void colourBySequence(AlignmentViewPanel avp) { - // TODO Auto-generated method stub - return null; - } - - @Override - protected void colourBySequence(String[] colourBySequenceCommands) - { - // TODO Auto-generated method stub - } @Override public void colourByCharge() { - // TODO Auto-generated method stub - } @Override public void colourByChain() { - // TODO Auto-generated method stub - } }; String[][] chains = binder.getChains(); @@ -313,13 +285,6 @@ public class AAStructureBindingModelTest } @Override - protected String[] getColourBySequenceCommands( - String[] files, AlignmentViewPanel avp) - { - return null; - } - - @Override public SequenceRenderer getSequenceRenderer( AlignmentViewPanel alignment) { @@ -327,7 +292,7 @@ public class AAStructureBindingModelTest } @Override - protected void colourBySequence(String[] colourBySequenceCommands) + protected void colourBySequence(AlignmentViewPanel avp) { }