From: James Procter Date: Tue, 5 Sep 2023 16:03:02 +0000 (+0100) Subject: JAL-629 use JalviewStructureDisplayI in place of StructureViewerBase X-Git-Tag: Release_2_11_4_0~195 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b8ee563aafbad9f5a0812cd1f5588ee8e9055570;p=jalview.git JAL-629 use JalviewStructureDisplayI in place of StructureViewerBase --- diff --git a/src/jalview/api/structures/JalviewStructureDisplayI.java b/src/jalview/api/structures/JalviewStructureDisplayI.java index a1b92df..532e545 100644 --- a/src/jalview/api/structures/JalviewStructureDisplayI.java +++ b/src/jalview/api/structures/JalviewStructureDisplayI.java @@ -20,9 +20,13 @@ */ package jalview.api.structures; +import java.io.File; + import jalview.api.AlignmentViewPanel; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; +import jalview.gui.AlignmentPanel; +import jalview.gui.StructureViewer; import jalview.structures.models.AAStructureBindingModel; public interface JalviewStructureDisplayI @@ -172,4 +176,20 @@ public interface JalviewStructureDisplayI */ boolean hasViewerActionsMenu(); + String getViewId(); + + StructureViewer.ViewerType getViewerType(); + + boolean isUsedforaligment(AlignmentViewPanel ap); + + boolean isColouredByViewer(); + + int getHeight(); + + int getWidth(); + + int getY(); + + File saveSession(); + } diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 6ebbf89..ff615c8 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -47,6 +47,7 @@ import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; import jalview.api.AlignmentViewPanel; +import jalview.api.structures.JalviewStructureDisplayI; import jalview.bin.Cache; import jalview.bin.Console; import jalview.datamodel.AlignmentI; @@ -87,12 +88,20 @@ public abstract class StructureViewerBase extends GStructureViewer BySequence, ByChain, ChargeCysteine, ByViewer } - private static List svbs = new ArrayList<>(); + /** + * Singleton list of all (open) instances of structureViewerBase + * TODO: JAL-3362 - review and adopt the swingJS-safe singleton pattern so each structure viewer base instance is kept to its own JalviewJS parent + */ + private static List svbs = new ArrayList<>(); - public static List getAllStructureViewerBases() + /** + * + * @return list with all existing StructureViewers instance + */ + public static List getAllStructureViewerBases() { - List goodSvbs = new ArrayList<>(); - for (StructureViewerBase s : svbs) + List goodSvbs = new ArrayList<>(); + for (JalviewStructureDisplayI s : svbs) { if (s != null && !goodSvbs.contains(s)) { @@ -196,6 +205,7 @@ public abstract class StructureViewerBase extends GStructureViewer return _aps.contains(ap2.av.getSequenceSetId()); } + @Override public boolean isUsedforaligment(AlignmentViewPanel ap2) { diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 9499acd..af3b2c8 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -1140,7 +1140,7 @@ public class Jalview2XML * only view *should* be coped with sensibly. */ // This must have been loaded, is it still visible? - List viewFrames = new ArrayList<>(); + List viewFrames = new ArrayList<>(); if (Desktop.desktop != null) { JInternalFrame[] jifs = Desktop.desktop.getAllFrames(); @@ -1148,9 +1148,9 @@ public class Jalview2XML { for (JInternalFrame jif : jifs) { - if (jif instanceof StructureViewerBase) + if (jif instanceof JalviewStructureDisplayI) { - viewFrames.add((StructureViewerBase) jif); + viewFrames.add((JalviewStructureDisplayI) jif); } } } @@ -1163,7 +1163,7 @@ public class Jalview2XML } String matchedFile = null; - for (StructureViewerBase viewFrame : viewFrames) + for (JalviewStructureDisplayI viewFrame : viewFrames) { matchedFile = saveStructureViewer(ap, jds, pdb, entry, viewIds, matchedFile, viewFrame); @@ -2165,7 +2165,7 @@ public class Jalview2XML */ protected String saveStructureViewer(AlignmentPanel ap, SequenceI jds, Pdbids pdb, PDBEntry entry, List viewIds, - String matchedFile, StructureViewerBase viewFrame) + String matchedFile, JalviewStructureDisplayI viewFrame) { final AAStructureBindingModel bindingModel = viewFrame.getBinding(); @@ -2210,7 +2210,7 @@ public class Jalview2XML { StructureState state = new StructureState(); state.setVisible(true); - state.setXpos(viewFrame.getX()); + state.setXpos(viewFrame.getY()); state.setYpos(viewFrame.getY()); state.setWidth(viewFrame.getWidth()); state.setHeight(viewFrame.getHeight());