+
+ /**
+ * Returns a list of chains mapped in this viewer.
+ *
+ * @return
+ */
+ public abstract List<String> getChainNames();
+
+ /**
+ * Returns the Jalview panel hosting the structure viewer (if any)
+ *
+ * @return
+ */
+ public JalviewStructureDisplayI getViewer()
+ {
+ return null;
+ }
+
+ /**
+ * Sets the selected colour scheme, possibly with reference to the given
+ * alignment view
+ *
+ * @param cs
+ * @param ap
+ * @param showFeats
+ */
+ public void setJalviewColourScheme(ColourSchemeI cs, AlignmentViewPanel ap,
+ boolean showFeats)
+ {
+ colourBy = ColourBy.Jalview;
+ colourScheme = cs;
+ showFeatures = showFeats;
+
+ if (!showFeats && (cs == null || cs.isSimple()))
+ {
+ setSimpleColourScheme(cs);
+ }
+ else
+ {
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(), cs), showFeatures);
+ }
+ }
+
+ /**
+ * Sets a colour scheme which is determined solely by the residue at each
+ * position
+ *
+ * @param cs
+ */
+ protected abstract void setSimpleColourScheme(ColourSchemeI cs);
+
+ /**
+ * Constructs and sends a command to align structures against a reference
+ * structure, based on one or more sequence alignments. May optionally return
+ * an error or warning message for the alignment command.
+ *
+ * @param alignments
+ * an array of alignments to process
+ * @param structureIndices
+ * an array of corresponding reference structures (index into pdb
+ * file array); if a negative value is passed, the first PDB file
+ * mapped to an alignment sequence is used as the reference for
+ * superposition
+ * @param hiddenCols
+ * an array of corresponding hidden columns for each alignment
+ * @return
+ */
+ public abstract String superposeStructures(AlignmentI[] alignments,
+ int[] structureIndices, HiddenColumns[] hiddenCols);
+
+ public abstract void setBackgroundColour(Color col);
+
+ protected abstract StructureMappingcommandSet[] getColourBySequenceCommands(
+ String[] files, SequenceRendererI sr, AlignmentViewPanel avp, boolean showFeatures);
+
+ protected abstract void colourBySequence(
+ StructureMappingcommandSet[] colourBySequenceCommands);
+
+ public void colourByChain()
+ {
+ colourBy = ColourBy.Chain;
+ }
+
+ public void colourByCharge()
+ {
+ colourBy = ColourBy.ChargeAndCysteine;
+ }
+
+ public void colourBySequence(AlignmentViewPanel alignmentv, boolean showFeatures)
+ {
+ 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, boolean showFeats)
+ {
+ showFeatures = showFeats;
+ if (!isLoadingFinished())
+ {
+ return;
+ }
+ if (getSsm() == null)
+ {
+ return;
+ }
+ String[] files = getStructureFiles();
+
+ StructureMappingcommandSet[] colourBySequenceCommands = getColourBySequenceCommands(
+ files, sr, alignmentv, showFeatures);
+ colourBySequence(colourBySequenceCommands);
+ }
+
+ public boolean hasFileLoadingError()
+ {
+ return fileLoadingError != null && fileLoadingError.length() > 0;
+ }
+
+ public abstract jalview.api.FeatureRenderer getFeatureRenderer(
+ AlignmentViewPanel alignment);
+
+@Override
+public void updateColours(Object source) {
+ AlignmentPanel ap = (AlignmentPanel) source;
+
+ /*
+ * ignore events from panels not used to colour this view
+ */
+ if (!getViewer().isUsedForColourBy(ap))
+ {
+ return;
+ }
+
+ /*
+ * no need to update colours if structure colouring is not
+ * viewport dependent
+ */
+ if (!isColourBySequence() && !isJalviewColourScheme())
+ {
+ return;
+ }
+ if (!showFeatures && (colourScheme == null || colourScheme.isSimple()))
+ {
+ return;
+ }
+
+ if (!isLoadingFromArchive())
+ {
+ if (isColourBySequence())
+ {
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport()),
+ showFeatures);
+ }
+ else
+ {
+ colourBySequence(ap, new SequenceRenderer(ap.getAlignViewport(),
+ colourScheme), showFeatures);
+ }
+ }
+ }