*/
package jalview.structures.models;
+import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.SequenceRenderer;
import jalview.api.StructureSelectionManagerProvider;
public String fileLoadingError;
+ private boolean showAlignmentOnly;
+
/**
* Data bean class to simplify parameterisation in superposeStructures
*/
{ Integer.valueOf(pe).toString() }));
}
final String nullChain = "TheNullChain";
- List<SequenceI> s = new ArrayList<SequenceI>();
- List<String> c = new ArrayList<String>();
+ List<SequenceI> s = new ArrayList<>();
+ List<String> c = new ArrayList<>();
if (getChains() == null)
{
setChains(new String[getPdbCount()][]);
public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe,
SequenceI[][] seq, String[][] chns)
{
- List<PDBEntry> v = new ArrayList<PDBEntry>();
- List<int[]> rtn = new ArrayList<int[]>();
+ List<PDBEntry> v = new ArrayList<>();
+ List<int[]> rtn = new ArrayList<>();
for (int i = 0; i < getPdbCount(); i++)
{
v.add(getPdbEntry(i));
public abstract void colourByCharge();
/**
- * colour any structures associated with sequences in the given alignment
- * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
- * if colourBySequence is enabled.
+ * Recolours the displayed structures, if they are coloured by sequence, or
+ * 'show only visible alignment' is selected. This supports updating structure
+ * colours on either change of alignment colours, or change to the visible
+ * region of the alignment.
*/
public void colourBySequence(AlignmentViewPanel alignmentv)
{
- if (!colourBySequence || !isLoadingFinished())
+ if (!isLoadingFinished())
+ {
+ return;
+ }
+ // todo: property change event for visibleAlignment
+ // to avoid unnecessary redraws here
+ if (!colourBySequence && !isShowAlignmentOnly())
{
return;
}
public abstract jalview.api.FeatureRenderer getFeatureRenderer(
AlignmentViewPanel alignment);
+
+ /**
+ * Sets the flag for whether only mapped visible residues in the alignment
+ * should be visible in the structure viewer
+ *
+ * @param b
+ */
+ public void setShowAlignmentOnly(boolean b)
+ {
+ showAlignmentOnly = b;
+ }
+
+ /**
+ * Answers true if only mapped visible residues in the alignment should be
+ * visible in the structure viewer, else false
+ *
+ * @return
+ */
+ public boolean isShowAlignmentOnly()
+ {
+ return showAlignmentOnly;
+ }
+
+ /**
+ * Shows the structures in the viewer, without changing their colouring. This is
+ * to support toggling of whether the whole structure is shown, or only residues
+ * mapped to visible regions of the alignment.
+ *
+ * @param alignViewportI
+ */
+ public void showStructures(AlignViewportI alignViewportI)
+ {
+ // override with implementation
+ }
+
+ @Override
+ public void updateColours(Object source)
+ {
+ AlignmentViewPanel ap = (AlignmentViewPanel) source;
+ // ignore events from panels not used to colour this view
+ if (!getViewer().isUsedforcolourby(ap))
+ {
+ return;
+ }
+ if (!isLoadingFromArchive())
+ {
+ colourBySequence(ap);
+ }
+ }
}