private void setColourScheme(ColourSchemeI cs)
{
- jmb.setJalviewColourScheme(cs, ap);
+ jmb.setJalviewColourScheme(cs, ap, ap.av.isShowSequenceFeatures());
}
/**
else if (evt.getSource() == seqColour)
{
setEnabled(seqColour);
- jmb.colourBySequence(ap);
+ jmb.colourBySequence(ap, ap.av.isShowSequenceFeatures());
}
else if (!allChainsSelected)
{
public void updateColours(Object source)
{
AlignmentPanel panel = (AlignmentPanel) source;
- jmb.colourBySequence(panel);
+ jmb.colourBySequence(panel, ap.av.isShowSequenceFeatures());
}
public void updateTitleAndMenus()
return;
}
setChainMenuItems(jmb.getChainNames());
- jmb.colourBySequence(ap);
+ jmb.colourBySequence(ap, ap.av.isShowSequenceFeatures());
setTitle(jmb.getViewerTitle());
}
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
- colourBySequence(ap);
+ colourBySequence(ap, ap.av.isShowSequenceFeatures());
}
@Override
@Override
public void colourByChain()
{
- super.colourByChain();
+ super.colourByChain();
// TODO: colour by chain should colour each chain distinctly across all
// visible models
// TODO: http://issues.jalview.org/browse/JAL-628
*/
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRendererI sr, AlignmentViewPanel viewPanel)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel viewPanel, boolean showFeatures)
{
return JmolCommands.getColourBySequenceCommand(getSsm(), files,
- getSequence(), sr, viewPanel);
+ getSequence(), sr, viewPanel, showFeatures);
}
/**
/**
* Jmol utility which constructs the commands to colour chains by the given
* alignment
+ * @param showFeatures
*
* @returns Object[] { Object[] { <model being coloured>,
*
public static StructureMappingcommandSet[] getColourBySequenceCommand(
StructureSelectionManager ssm, String[] files,
SequenceI[][] sequence, SequenceRendererI sr,
- AlignmentViewPanel viewPanel)
+ AlignmentViewPanel viewPanel, boolean showFeatures)
{
FeatureRenderer fr = viewPanel.getFeatureRenderer();
- FeatureColourFinder finder = new FeatureColourFinder(fr);
+ FeatureColourFinder finder = showFeatures ? new FeatureColourFinder(fr) : null;
AlignViewportI viewport = viewPanel.getAlignViewport();
HiddenColumns cs = viewport.getAlignment().getHiddenColumns();
AlignmentI al = viewport.getAlignment();
public static StructureMappingcommandSet[] getColourBySequenceCommand(
StructureSelectionManager ssm, String[] files,
SequenceI[][] sequence, SequenceRendererI sr,
- AlignmentViewPanel viewPanel)
+ AlignmentViewPanel viewPanel, boolean showFeatures)
{
Map<Object, AtomSpecModel> colourMap = buildColoursMap(ssm, files,
- sequence, sr, viewPanel);
+ sequence, sr, viewPanel, showFeatures);
List<String> colourCommands = buildColourCommands(colourMap);
protected static Map<Object, AtomSpecModel> buildColoursMap(
StructureSelectionManager ssm, String[] files,
SequenceI[][] sequence, SequenceRendererI sr,
- AlignmentViewPanel viewPanel)
+ AlignmentViewPanel viewPanel, boolean showFeatures)
{
FeatureRenderer fr = viewPanel.getFeatureRenderer();
- FeatureColourFinder finder = new FeatureColourFinder(fr);
+ FeatureColourFinder finder = showFeatures ? new FeatureColourFinder(fr) : null;
AlignViewportI viewport = viewPanel.getAlignViewport();
HiddenColumns cs = viewport.getAlignment().getHiddenColumns();
AlignmentI al = viewport.getAlignment();
*/
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRendererI sr, AlignmentViewPanel viewPanel)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel viewPanel, boolean showFeatures)
{
return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
- getSequence(), sr, viewPanel);
+ getSequence(), sr, viewPanel, showFeatures);
}
/**
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
+import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JColorChooser;
*/
protected volatile boolean seqColoursApplied = false;
+ private JCheckBoxMenuItem showFeatures;
+
/**
* Default constructor
*/
return (_alignwith != null) && _alignwith.contains(ap2);
}
- public boolean isUsedForColourBy(Object o)
+ @Override
+public boolean isUsedForColourBy(Object o)
{
return (_colourwith != null) && _colourwith.contains(o);
}
@Override
public void changeColour_actionPerformed(String colourSchemeName)
{
+ showFeatures.setEnabled(true);
AlignmentI al = getAlignmentPanel().av.getAlignment();
ColourSchemeI cs = ColourSchemes.getInstance()
.getColourScheme(colourSchemeName, al, null);
- getBinding().setJalviewColourScheme(cs, getAlignmentPanel());
+ getBinding().setJalviewColourScheme(cs, getAlignmentPanel(), showFeatures.isSelected());
}
/**
colourMenu.removeAll();
AlignmentI al = getAlignmentPanel().av.getAlignment();
- colourMenu.addSeparator();
+ showFeatures = new JCheckBoxMenuItem(MessageManager.getString(
+ "label.show_sequence_features"));
+ colourMenu.add(showFeatures);
+ colourMenu.addSeparator();
/*
* add colour by sequence, by chain, by charge and cysteine
colourMenu.add(chargeColour);
chargeColour.setEnabled(!al.isNucleotide());
- /*
- * add all colour schemes registered to Jalview
- */
+ /*
+ * add all colour schemes registered to Jalview
+ */
ButtonGroup itemGroup = ColourMenuHelper.addMenuItems(colourMenu, this,
al);
itemGroup.add(chainColour);
itemGroup.add(chargeColour);
itemGroup.add(viewerColour);
+
+ /*
+ * action on show/hide features is to 'click' the currently
+ * selected colour in order to update the display
+ */
+ showFeatures.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ Enumeration<AbstractButton> items = itemGroup.getElements();
+ while (items.hasMoreElements())
+ {
+ AbstractButton item = items.nextElement();
+ if (item.isSelected())
+ {
+ item.doClick();
+ return;
+ }
+ }
+ }});
}
/**
@Override
public void viewerColour_actionPerformed(ActionEvent actionEvent)
{
- if (viewerColour.isSelected())
- {
- // disable automatic sequence colouring.
- getBinding().setColourBy(ColourBy.Viewer);
- }
+ showFeatures.setEnabled(false);
+ getBinding().setColourBy(ColourBy.Viewer);
}
@Override
public void chainColour_actionPerformed(ActionEvent actionEvent)
{
- chainColour.setSelected(true);
+ showFeatures.setEnabled(false);
getBinding().colourByChain();
}
@Override
public void chargeColour_actionPerformed(ActionEvent actionEvent)
{
- chargeColour.setSelected(true);
+ showFeatures.setEnabled(false);
getBinding().colourByCharge();
}
@Override
public void seqColour_actionPerformed(ActionEvent actionEvent)
{
+ showFeatures.setEnabled(false);
AAStructureBindingModel binding = getBinding();
- boolean colourBySequence = seqColour.isSelected();
if (_colourwith == null)
{
_colourwith = new Vector<>();
}
- if (colourBySequence)
+
+ if (!binding.isLoadingFromArchive())
{
- if (!binding.isLoadingFromArchive())
+ if (_colourwith.isEmpty() && ap != null)
{
- if (_colourwith.size() == 0 && getAlignmentPanel() != null)
- {
- // Make the currently displayed alignment panel the associated view
- _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
- }
- }
- // Set the colour using the current view for the associated alignframe
- for (AlignmentPanel alignPanel : _colourwith)
- {
- binding.colourBySequence(alignPanel);
+ // Make the currently displayed alignment panel the associated view
+ _colourwith.add(ap);//.alignFrame.alignPanel); ?!?
}
- seqColoursApplied = true;
}
+
+ showFeatures.setSelected(ap == null ? false : ap.av.isShowSequenceFeatures());
+
+ // Set the colour using the current view for the associated alignframe
+ for (AlignmentPanel alignPanel : _colourwith)
+ {
+ binding.colourBySequence(alignPanel, showFeatures.isSelected());
+ }
+ seqColoursApplied = true;
}
@Override
ArrayList<String> pdbfn = new ArrayList<String>();
StructureMappingcommandSet[] colcommands = JmolCommands
.getColourBySequenceCommand(ssm, modelSet, sequence, sr,
- (AlignmentViewPanel) source);
+ (AlignmentViewPanel) source, true);
if (colcommands == null)
{
return;
import java.util.BitSet;
import java.util.List;
+import org.springframework.web.filter.ShallowEtagHeaderFilter;
+
/**
*
* A base class to hold common function for protein structure model binding.
*/
private ColourSchemeI colourScheme;
+ /*
+ * flag for whether to include feature colouring, if using a Jalview colour
+ * scheme (independently of whether features are shown on alignment)
+ */
+ private boolean showFeatures;
+
private StructureSelectionManager ssm;
/*
public void setColourBy(ColourBy option)
{
- colourBy = option;
+ colourBy = option;
}
public boolean isColourBySequence()
protected boolean isJalviewColourScheme()
{
- return colourBy == ColourBy.Jalview;
+ return colourBy == ColourBy.Jalview;
}
protected void addSequenceAndChain(int pe, SequenceI[] seq,
*
* @param cs
* @param ap
+ * @param showFeats
*/
- public void setJalviewColourScheme(ColourSchemeI cs, AlignmentViewPanel ap)
+ public void setJalviewColourScheme(ColourSchemeI cs, AlignmentViewPanel ap,
+ boolean showFeats)
{
colourBy = ColourBy.Jalview;
colourScheme = cs;
+ showFeatures = showFeats;
- if (cs == null || cs.isSimple())
+ if (!showFeats && (cs == null || cs.isSimple()))
{
setSimpleColourScheme(cs);
}
else
{
- colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(), cs));
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(), cs), showFeatures);
}
}
public abstract void setBackgroundColour(Color col);
protected abstract StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRendererI sr, AlignmentViewPanel avp);
+ String[] files, SequenceRendererI sr, AlignmentViewPanel avp, boolean showFeatures);
protected abstract void colourBySequence(
StructureMappingcommandSet[] colourBySequenceCommands);
public void colourByCharge()
{
- colourBy = ColourBy.ChargeAndCysteine;
+ colourBy = ColourBy.ChargeAndCysteine;
}
- public void colourBySequence(AlignmentViewPanel alignmentv)
+ public void colourBySequence(AlignmentViewPanel alignmentv, boolean showFeatures)
{
- colourBySequence(alignmentv, alignmentv.getSequenceRenderer());
+ colourBySequence(alignmentv, alignmentv.getSequenceRenderer(), showFeatures);
}
/**
* Colours any structures associated with sequences in the given alignment view
* using the getFeatureRenderer() and getSequenceRenderer() renderers
*/
- public void colourBySequence(AlignmentViewPanel alignmentv, SequenceRendererI sr)
+ public void colourBySequence(AlignmentViewPanel alignmentv, SequenceRendererI sr, boolean showFeats)
{
+ showFeatures = showFeats;
if (!isLoadingFinished())
{
return;
String[] files = getStructureFiles();
StructureMappingcommandSet[] colourBySequenceCommands = getColourBySequenceCommands(
- files, sr, alignmentv);
+ files, sr, alignmentv, showFeatures);
colourBySequence(colourBySequenceCommands);
}
{
return;
}
- if (colourScheme == null || colourScheme.isSimple())
+ if (!showFeatures && (colourScheme == null || colourScheme.isSimple()))
{
return;
}
{
if (isColourBySequence())
{
- colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport()));
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport()),
+ showFeatures);
}
else
{
- colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(), colourScheme));
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(),
+ colourScheme), showFeatures);
}
}
}
// need some mappings!
StructureMappingcommandSet[] commands = JmolCommands
- .getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel);
+ .getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel, false);
}
@Test(groups = { "Functional" })
ssm.addStructureMapping(sm2);
StructureMappingcommandSet[] commands = JmolCommands
- .getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel);
+ .getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel, false);
assertEquals(commands.length, 2);
assertEquals(commands[0].commands.length, 1);
ssm.addStructureMapping(sm2);
StructureMappingcommandSet[] commands = ChimeraCommands
- .getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel);
+ .getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel, false);
assertEquals(1, commands.length);
assertEquals(1, commands[0].commands.length);
String theCommand = commands[0].commands[0];
new SequenceI[][]
{ new SequenceI[] { pdb_viewseq } },
new SequenceRenderer(alf.alignPanel.getAlignViewport()),
- alf.alignPanel);
+ alf.alignPanel, false);
// Expected - all residues are white
for (StructureMappingcommandSet smm : smcr)
{
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRendererI sr, AlignmentViewPanel avp)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel avp,
+ boolean showFeatures)
{
return null;
}
@Override
protected StructureMappingcommandSet[] getColourBySequenceCommands(
- String[] files, SequenceRendererI sr, AlignmentViewPanel avp)
+ String[] files, SequenceRendererI sr, AlignmentViewPanel avp,
+ boolean showFeatures)
{
return null;
}