X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FStructureViewerBase.java;h=13af0e8a9d33749afff88a65026c2a1c03c4fb5a;hb=041905b00ec635c1764f565a22b2ecf762a9a75b;hp=34398fe4cc2963cd243bc38d275eee56a42c3c4e;hpb=c4ec878c9cb59fc40a88ed8ecdf5fda46f3de111;p=jalview.git diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 34398fe..13af0e8 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -1,5 +1,8 @@ package jalview.gui; +import jalview.gui.ViewSelectionMenu.ViewSetProvider; +import jalview.jbgui.GStructureViewer; + import java.awt.Component; import java.util.ArrayList; import java.util.List; @@ -7,9 +10,6 @@ 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. @@ -81,10 +81,7 @@ public abstract class StructureViewerBase extends GStructureViewer this.viewId = viewId; } - public String getStateInfo() - { - return ""; - } + public abstract String getStateInfo(); protected void buildActionMenu() { @@ -115,4 +112,114 @@ public abstract class StructureViewerBase extends GStructureViewer { this.ap = alp; } + + public AlignmentPanel[] getAllAlignmentPanels() + { + AlignmentPanel[] t, list = new AlignmentPanel[0]; + for (String setid : _aps) + { + AlignmentPanel[] panels = PaintRefresher.getAssociatedPanels(setid); + if (panels != null) + { + t = new AlignmentPanel[list.length + panels.length]; + System.arraycopy(list, 0, t, 0, list.length); + System.arraycopy(panels, 0, t, list.length, panels.length); + list = t; + } + } + + return list; + } + + /** + * set the primary alignmentPanel reference and add another alignPanel to the + * list of ones to use for colouring and aligning + * + * @param nap + */ + public void addAlignmentPanel(AlignmentPanel nap) + { + if (getAlignmentPanel() == null) + { + setAlignmentPanel(nap); + } + if (!_aps.contains(nap.av.getSequenceSetId())) + { + _aps.add(nap.av.getSequenceSetId()); + } + } + + /** + * remove any references held to the given alignment panel + * + * @param nap + */ + public void removeAlignmentPanel(AlignmentPanel nap) + { + try + { + _alignwith.remove(nap); + _colourwith.remove(nap); + if (getAlignmentPanel() == nap) + { + setAlignmentPanel(null); + for (AlignmentPanel aps : getAllAlignmentPanels()) + { + if (aps != nap) + { + setAlignmentPanel(aps); + break; + } + } + } + } catch (Exception ex) + { + } + if (getAlignmentPanel() != null) + { + buildActionMenu(); + } + } + + public void useAlignmentPanelForSuperposition(AlignmentPanel nap) + { + addAlignmentPanel(nap); + if (!_alignwith.contains(nap)) + { + _alignwith.add(nap); + } + } + + public void excludeAlignmentPanelForSuperposition(AlignmentPanel nap) + { + if (_alignwith.contains(nap)) + { + _alignwith.remove(nap); + } + } + + public void useAlignmentPanelForColourbyseq(AlignmentPanel nap, boolean enableColourBySeq) + { + useAlignmentPanelForColourbyseq(nap); + getBinding().setColourBySequence(enableColourBySeq); + seqColour.setSelected(enableColourBySeq); + viewerColour.setSelected(!enableColourBySeq); + } + + public void useAlignmentPanelForColourbyseq(AlignmentPanel nap) + { + addAlignmentPanel(nap); + if (!_colourwith.contains(nap)) + { + _colourwith.add(nap); + } + } + + public void excludeAlignmentPanelForColourbyseq(AlignmentPanel nap) + { + if (_colourwith.contains(nap)) + { + _colourwith.remove(nap); + } + } }