package jalview.gui; import java.awt.Component; import java.util.ArrayList; import java.util.List; import java.util.Vector; import javax.swing.JMenuItem; import jalview.gui.ViewSelectionMenu.ViewSetProvider; import jalview.jbgui.GStructureViewer; /** * Base class with common functionality for JMol, Chimera or other structure * viewers. * * @author gmcarstairs * */ public abstract class StructureViewerBase extends GStructureViewer implements Runnable, ViewSetProvider { /** * list of sequenceSet ids associated with the view */ protected List _aps = new ArrayList(); /** * list of alignment panels to use for superposition */ protected Vector _alignwith = new Vector(); /** * list of alignment panels that are used for colouring structures by aligned * sequences */ protected Vector _colourwith = new Vector(); private String viewId = null; private AlignmentPanel ap; /** * * @param ap2 * @return true if this Jmol instance is linked with the given alignPanel */ public boolean isLinkedWith(AlignmentPanel ap2) { return _aps.contains(ap2.av.getSequenceSetId()); } public boolean isUsedforaligment(AlignmentPanel ap2) { return (_alignwith != null) && _alignwith.contains(ap2); } public boolean isUsedforcolourby(AlignmentPanel ap2) { return (_colourwith != null) && _colourwith.contains(ap2); } /** * * @return TRUE if the view is NOT being coloured by the alignment colours. */ public boolean isColouredByViewer() { return !getBinding().isColourBySequence(); } public String getViewId() { if (viewId == null) { viewId = System.currentTimeMillis() + "." + this.hashCode(); } return viewId; } protected void setViewId(String viewId) { this.viewId = viewId; } public String getStateInfo() { return ""; } protected void buildActionMenu() { if (_alignwith == null) { _alignwith = new Vector(); } if (_alignwith.size() == 0 && ap != null) { _alignwith.add(ap); } ; for (Component c : viewerActionMenu.getMenuComponents()) { if (c != alignStructs) { viewerActionMenu.remove((JMenuItem) c); } } } public AlignmentPanel getAlignmentPanel() { return ap; } protected void setAlignmentPanel(AlignmentPanel alp) { this.ap = alp; } }