JAL-2422 pull up refactoring in preparation for ChimeraX subclasses
[jalview.git] / src / jalview / ext / jmol / JalviewJmolBinding.java
index 1ceabd1..e19bb29 100644 (file)
@@ -95,7 +95,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
   StringBuffer resetLastRes = new StringBuffer();
 
-  public Viewer viewer;
+  public Viewer jmolViewer;
 
   public JalviewJmolBinding(StructureSelectionManager ssm,
           PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
@@ -116,9 +116,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   {
     super(ssm, seqs);
 
-    viewer = theViewer;
-    viewer.setJmolStatusListener(this);
-    viewer.addSelectionListener(this);
+    jmolViewer = theViewer;
+    jmolViewer.setJmolStatusListener(this);
+    jmolViewer.addSelectionListener(this);
   }
 
   /**
@@ -166,9 +166,9 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   {
     // remove listeners for all structures in viewer
     getSsm().removeStructureViewerListener(this, this.getStructureFiles());
-    viewer.dispose();
+    jmolViewer.dispose();
     lastCommand = null;
-    viewer = null;
+    jmolViewer = null;
     releaseUIResources();
   }
 
@@ -237,7 +237,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public String superposeStructures(AlignmentI[] _alignment,
           int[] _refStructure, HiddenColumns[] _hiddenCols)
   {
-    while (viewer.isScriptExecuting())
+    while (jmolViewer.isScriptExecuting())
     {
       try
       {
@@ -472,7 +472,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     jmolHistory(false);
     if (lastCommand == null || !lastCommand.equals(command))
     {
-      viewer.evalStringQuiet(command + "\n");
+      jmolViewer.evalStringQuiet(command + "\n");
     }
     jmolHistory(true);
     lastCommand = command;
@@ -579,7 +579,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     }
     // TODO: verify atomIndex is selecting correct model.
     // return new Color(viewer.getAtomArgb(atomIndex)); Jmol 12.2.4
-    int colour = viewer.ms.at[atomIndex].atomPropertyInt(T.color);
+    int colour = jmolViewer.ms.at[atomIndex].atomPropertyInt(T.color);
     return new Color(colour);
   }
 
@@ -618,18 +618,18 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public synchronized String[] getStructureFiles()
   {
     List<String> mset = new ArrayList<>();
-    if (viewer == null)
+    if (jmolViewer == null)
     {
       return new String[0];
     }
 
     if (modelFileNames == null)
     {
-      int modelCount = viewer.ms.mc;
+      int modelCount = jmolViewer.ms.mc;
       String filePath = null;
       for (int i = 0; i < modelCount; ++i)
       {
-        filePath = viewer.ms.getModelFileName(i);
+        filePath = jmolViewer.ms.getModelFileName(i);
         if (!mset.contains(filePath))
         {
           mset.add(filePath);
@@ -670,7 +670,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     {
       if (resetLastRes.length() > 0)
       {
-        viewer.evalStringQuiet(resetLastRes.toString());
+        jmolViewer.evalStringQuiet(resetLastRes.toString());
         resetLastRes.setLength(0);
       }
       for (AtomSpec atom : atoms)
@@ -728,7 +728,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
     cmd.append("spacefill 200;select none");
 
-    viewer.evalStringQuiet(cmd.toString());
+    jmolViewer.evalStringQuiet(cmd.toString());
     jmolHistory(true);
 
   }
@@ -737,7 +737,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
   private void jmolHistory(boolean enable)
   {
-    viewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
+    jmolViewer.evalStringQuiet("History " + ((debug || enable) ? "on" : "off"));
   }
 
   public void loadInline(String string)
@@ -751,7 +751,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     // Then, construct pass a reader for the string to Jmol.
     // ((org.jmol.Viewer.Viewer) viewer).loadModelFromFile(fullPathName,
     // fileName, null, reader, false, null, null, 0);
-    viewer.openStringInline(string);
+    jmolViewer.openStringInline(string);
   }
 
   protected void mouseOverStructure(int atomIndex, final String strInfo)
@@ -828,7 +828,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
           if (pdbfilename == null)
           {
-            pdbfilename = new File(viewer.ms.getModelFileName(mnumber))
+            pdbfilename = new File(jmolViewer.ms.getModelFileName(mnumber))
                     .getAbsolutePath();
           }
         }
@@ -915,12 +915,12 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
 
     if (!atomsPicked.contains(picked))
     {
-      viewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
+      jmolViewer.evalStringQuiet("select " + picked + ";label %n %r:%c");
       atomsPicked.addElement(picked);
     }
     else
     {
-      viewer.evalString("select " + picked + ";label off");
+      jmolViewer.evalString("select " + picked + ";label off");
       atomsPicked.removeElement(picked);
     }
     jmolHistory(true);
@@ -1088,7 +1088,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
         // calculate essential attributes for the pdb data imported inline.
         // prolly need to resolve modelnumber properly - for now just use our
         // 'best guess'
-        pdbfile = viewer.getData(
+        pdbfile = jmolViewer.getData(
                 "" + (1 + _modelFileNameMap[modelnum]) + ".0", "PDB");
       }
       // search pdbentries and sequences to find correct pdbentry for this
@@ -1160,7 +1160,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
         // this is a foreign pdb file that jalview doesn't know about - add
         // it to the dataset and try to find a home - either on a matching
         // sequence or as a new sequence.
-        String pdbcontent = viewer.getData("/" + (modelnum + 1) + ".1",
+        String pdbcontent = jmolViewer.getData("/" + (modelnum + 1) + ".1",
                 "PDB");
         // parse pdb file into a chain, etc.
         // locate best match for pdb in associated views and add mapping to
@@ -1179,7 +1179,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     // }
     if (!isLoadingFromArchive())
     {
-      viewer.evalStringQuiet(
+      jmolViewer.evalStringQuiet(
               "model *; select backbone;restrict;cartoon;wireframe off;spacefill off");
     }
     // register ourselves as a listener and notify the gui that it needs to
@@ -1345,12 +1345,12 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     {
       commandOptions = "";
     }
-    viewer = (Viewer) JmolViewer.allocateViewer(renderPanel,
+    jmolViewer = (Viewer) JmolViewer.allocateViewer(renderPanel,
             (jmolfileio ? new SmarterJmolAdapter() : null),
             htmlName + ((Object) this).toString(), documentBase, codeBase,
             commandOptions, this);
 
-    viewer.setJmolStatusListener(this); // extends JmolCallbackListener
+    jmolViewer.setJmolStatusListener(this); // extends JmolCallbackListener
 
     console = createJmolConsole(consolePanel, buttonsToShow);
     if (consolePanel != null)
@@ -1370,7 +1370,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   public void setBackgroundColour(java.awt.Color col)
   {
     jmolHistory(false);
-    viewer.evalStringQuiet("background [" + col.getRed() + ","
+    jmolViewer.evalStringQuiet("background [" + col.getRed() + ","
             + col.getGreen() + "," + col.getBlue() + "];");
     jmolHistory(true);
   }