JAL-1925 update source version in license
[jalview.git] / src / jalview / appletgui / AppletJmol.java
index b48070c..d894a47 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
+ * Copyright (C) 2015 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -60,6 +60,7 @@ import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Vector;
 
 public class AppletJmol extends EmbmenuFrame implements
@@ -129,7 +130,8 @@ public class AppletJmol extends EmbmenuFrame implements
 
   AlignmentPanel ap;
 
-  ArrayList _aps = new ArrayList();
+  List<AlignmentPanel> _aps = new ArrayList<AlignmentPanel>(); // remove? never
+                                                               // added to
 
   String fileLoadingError;
 
@@ -177,10 +179,8 @@ public class AppletJmol extends EmbmenuFrame implements
   {
     this.ap = ap;
     jmb = new AppletJmolBinding(this, ap.getStructureSelectionManager(),
-            new PDBEntry[]
-            { pdbentry }, new SequenceI[][]
-            { seq }, new String[][]
-            { chains }, protocol);
+            new PDBEntry[] { pdbentry }, new SequenceI[][] { seq },
+            new String[][] { chains }, protocol);
     jmb.setColourBySequence(true);
     if (pdbentry.getId() == null || pdbentry.getId().length() < 1)
     {
@@ -279,7 +279,7 @@ public class AppletJmol extends EmbmenuFrame implements
       dispose();
       return;
     }
-    jmb.newJmolPopup(true, "Jmol", true);
+    // jmb.newJmolPopup(true, "Jmol", true);
 
     this.addWindowListener(new WindowAdapter()
     {
@@ -345,7 +345,9 @@ public class AppletJmol extends EmbmenuFrame implements
           }
           if (freader == null)
           {
-            throw new Exception(MessageManager.getString("exception.invalid_datasource_couldnt_obtain_reader"));
+            throw new Exception(
+                    MessageManager
+                            .getString("exception.invalid_datasource_couldnt_obtain_reader"));
           }
           jmb.viewer.openReader(pdbentry.getFile(), pdbentry.getId(),
                   freader);
@@ -369,7 +371,7 @@ public class AppletJmol extends EmbmenuFrame implements
     jmb.loadInline(string);
   }
 
-  void setChainMenuItems(Vector chains)
+  void setChainMenuItems(Vector<String> chains)
   {
     chainMenu.removeAll();
 
@@ -379,10 +381,9 @@ public class AppletJmol extends EmbmenuFrame implements
     chainMenu.add(menuItem);
 
     CheckboxMenuItem menuItemCB;
-    for (int c = 0; c < chains.size(); c++)
+    for (String ch : chains)
     {
-      menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(),
-              true);
+      menuItemCB = new CheckboxMenuItem(ch, true);
       menuItemCB.addItemListener(this);
       chainMenu.add(menuItemCB);
     }
@@ -392,9 +393,7 @@ public class AppletJmol extends EmbmenuFrame implements
 
   void centerViewer()
   {
-    Vector toshow = new Vector();
-    String lbl;
-    int mlength, p, mnum;
+    Vector<String> toshow = new Vector<String>();
     for (int i = 0; i < chainMenu.getItemCount(); i++)
     {
       if (chainMenu.getItem(i) instanceof CheckboxMenuItem)
@@ -546,7 +545,7 @@ public class AppletJmol extends EmbmenuFrame implements
     else if (evt.getSource() == seqColour)
     {
       setEnabled(seqColour);
-      jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+      jmb.colourBySequence(ap);
     }
     else if (!allChainsSelected)
     {
@@ -559,7 +558,7 @@ public class AppletJmol extends EmbmenuFrame implements
     if (evt.getKeyCode() == KeyEvent.VK_ENTER && scriptWindow.isVisible())
     {
       jmb.eval(inputLine.getText());
-      history.append("\n$ " + inputLine.getText());
+      addToHistory("$ " + inputLine.getText());
       inputLine.setText("");
     }
 
@@ -575,8 +574,8 @@ public class AppletJmol extends EmbmenuFrame implements
 
   public void updateColours(Object source)
   {
-    AlignmentPanel ap = (AlignmentPanel) source;
-    jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+    AlignmentPanel panel = (AlignmentPanel) source;
+    jmb.colourBySequence(panel);
   }
 
   public void updateTitleAndMenus()
@@ -587,7 +586,7 @@ public class AppletJmol extends EmbmenuFrame implements
       return;
     }
     setChainMenuItems(jmb.chainNames);
-    jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+    jmb.colourBySequence(ap);
 
     setTitle(jmb.getViewerTitle());
   }
@@ -695,11 +694,25 @@ public class AppletJmol extends EmbmenuFrame implements
   {
     for (int i = 0; i < _aps.size(); i++)
     {
-      if (((AlignmentPanel) _aps.get(i)).av.getAlignment() == alignment)
+      if (_aps.get(i).av.getAlignment() == alignment)
       {
-        return ((AlignmentPanel) _aps.get(i));
+        return (_aps.get(i));
       }
     }
     return ap;
   }
+
+  /**
+   * Append the given text to the history object
+   * 
+   * @param text
+   */
+  public void addToHistory(String text)
+  {
+    // actually currently never initialised
+    if (history != null)
+    {
+      history.append("\n" + text);
+    }
+  }
 }