JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / appletgui / AppletJmol.java
index 0db3e30..c9f275b 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -48,7 +48,6 @@ import java.awt.Menu;
 import java.awt.MenuBar;
 import java.awt.MenuItem;
 import java.awt.Panel;
-import java.awt.Rectangle;
 import java.awt.TextArea;
 import java.awt.TextField;
 import java.awt.event.ActionEvent;
@@ -61,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
@@ -130,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;
 
@@ -178,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)
     {
@@ -280,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()
     {
@@ -346,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);
@@ -370,7 +371,7 @@ public class AppletJmol extends EmbmenuFrame implements
     jmb.loadInline(string);
   }
 
-  void setChainMenuItems(Vector chains)
+  void setChainMenuItems(Vector<String> chains)
   {
     chainMenu.removeAll();
 
@@ -380,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);
     }
@@ -393,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)
@@ -429,12 +427,7 @@ public class AppletJmol extends EmbmenuFrame implements
       StringBuffer sb = new StringBuffer();
       try
       {
-        for (int s = 0; s < jmb.getPdbCount(); s++)
-        {
-          sb.append(jmb.printMapping(jmb.getPdbEntry(s).getFile()));
-          sb.append("\n");
-        }
-        cap.setText(sb.toString());
+        cap.setText(jmb.printMappings());
       } catch (OutOfMemoryError ex)
       {
         frame.dispose();
@@ -552,7 +545,7 @@ public class AppletJmol extends EmbmenuFrame implements
     else if (evt.getSource() == seqColour)
     {
       setEnabled(seqColour);
-      jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap);
+      jmb.colourBySequence(ap);
     }
     else if (!allChainsSelected)
     {
@@ -565,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("");
     }
 
@@ -581,8 +574,8 @@ public class AppletJmol extends EmbmenuFrame implements
 
   public void updateColours(Object source)
   {
-    AlignmentPanel ap = (AlignmentPanel) source;
-    jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap);
+    AlignmentPanel panel = (AlignmentPanel) source;
+    jmb.colourBySequence(panel);
   }
 
   public void updateTitleAndMenus()
@@ -593,7 +586,7 @@ public class AppletJmol extends EmbmenuFrame implements
       return;
     }
     setChainMenuItems(jmb.chainNames);
-    jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap);
+    jmb.colourBySequence(ap);
 
     setTitle(jmb.getViewerTitle());
   }
@@ -648,8 +641,6 @@ public class AppletJmol extends EmbmenuFrame implements
   {
     Dimension currentSize = new Dimension();
 
-    Rectangle rectClip = new Rectangle();
-
     public void update(Graphics g)
     {
       paint(g);
@@ -658,7 +649,6 @@ public class AppletJmol extends EmbmenuFrame implements
     public void paint(Graphics g)
     {
       currentSize = this.getSize();
-      rectClip = g.getClipBounds();
 
       if (jmb.viewer == null)
       {
@@ -671,7 +661,8 @@ public class AppletJmol extends EmbmenuFrame implements
       }
       else
       {
-        jmb.viewer.renderScreenImage(g, currentSize, rectClip);
+        jmb.viewer.renderScreenImage(g, currentSize.width,
+                currentSize.height);
       }
     }
   }
@@ -703,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);
+    }
+  }
 }