Merge branch 'features/JAL-2177_update_jmol_to_14.6.4_2016.10.26' into develop
authorJim Procter <jprocter@issues.jalview.org>
Tue, 22 Nov 2016 17:14:38 +0000 (17:14 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 22 Nov 2016 17:14:38 +0000 (17:14 +0000)
1  2 
THIRDPARTYLIBS
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AppletJmolBinding.java
src/jalview/ext/jmol/JalviewJmolBinding.java

diff --combined THIRDPARTYLIBS
@@@ -6,14 -6,11 +6,14 @@@ A number of sources have also been adap
  
  ext.edu.ucsf.rbvi.strucviz2 includes sources originally developed by Scooter Morris and Nadezhda Doncheva for the Cytoscape StructureViz2 plugin. It is released under the Berkley license and we hereby acknowledge its original copyright is held by the UCSF Computer Graphics Laboratory
   and the software was developed with support by the NIH National Center for Research Resources, grant P41-RR01081. 
 + 
 + jalview.ext.android includes code taken from the Android Open Source Project (https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/util).
 + The Apache 2.0 Licence (http://www.apache.org/licenses/LICENSE-2.0) is acknowledged in the source code.
  
 -Licencing information for each library is given below:
 +Licensing information for each library is given below:
  
  JGoogleAnalytics_0.3.jar      APL 2.0 License - http://code.google.com/p/jgoogleanalytics/
- Jmol-14.2.14_2015.06.11.jar   GPL/LGPLv2 http://sourceforge.net/projects/jmol/files/
+ Jmol-14.6.4_2016.10.26.jar    GPL/LGPLv2 http://sourceforge.net/projects/jmol/files/
  VARNAv3-93.jar GPL licenced software by K�vin Darty, Alain Denise and Yann Ponty. http://varna.lri.fr
  activation.jar        
  apache-mime4j-0.6.jar
@@@ -61,5 -58,4 +61,5 @@@ Additional dependencie
  examples/javascript/deployJava.js : http://java.com/js/deployJava.js
  examples/javascript/jquery*.js : BSD license
  examples/javascript/jshashtable-2.1.js : Apache License
 +examples/javascript/facebox-1.3.js : MTI License - http://www.opensource.org/licenses/mit-license.php
  
@@@ -29,6 -29,7 +29,6 @@@ import jalview.commands.EditCommand
  import jalview.commands.EditCommand.Action;
  import jalview.datamodel.AlignmentAnnotation;
  import jalview.datamodel.AlignmentI;
 -import jalview.datamodel.DBRefEntry;
  import jalview.datamodel.PDBEntry;
  import jalview.datamodel.SequenceFeature;
  import jalview.datamodel.SequenceGroup;
@@@ -58,7 -59,6 +58,7 @@@ import java.awt.event.ActionListener
  import java.awt.event.ItemEvent;
  import java.awt.event.ItemListener;
  import java.util.Arrays;
 +import java.util.Collection;
  import java.util.Collections;
  import java.util.LinkedHashMap;
  import java.util.List;
@@@ -253,9 -253,122 +253,9 @@@ public class APopupMenu extends java.aw
  
      if (links != null && links.size() > 0)
      {
 -      Menu linkMenu = new Menu(MessageManager.getString("action.link"));
 -      for (int i = 0; i < links.size(); i++)
 -      {
 -        String link = links.elementAt(i);
 -        UrlLink urlLink = new UrlLink(link);
 -        if (!urlLink.isValid())
 -        {
 -          System.err.println(urlLink.getInvalidMessage());
 -          continue;
 -        }
 -        final String target = urlLink.getTarget(); // link.substring(0,
 -        // link.indexOf("|"));
 -        final String label = urlLink.getLabel();
 -        if (seq != null && urlLink.isDynamic())
 -        {
 -
 -          // collect matching db-refs
 -          DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
 -                  seq.getDBRefs(), new String[] { target });
 -          // collect id string too
 -          String id = seq.getName();
 -          String descr = seq.getDescription();
 -          if (descr != null && descr.length() < 1)
 -          {
 -            descr = null;
 -          }
 -          if (dbr != null)
 -          {
 -            for (int r = 0; r < dbr.length; r++)
 -            {
 -              if (id != null && dbr[r].getAccessionId().equals(id))
 -              {
 -                // suppress duplicate link creation for the bare sequence ID
 -                // string with this link
 -                id = null;
 -              }
 -              // create Bare ID link for this RUL
 -              String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
 -                      true);
 -              if (urls != null)
 -              {
 -                for (int u = 0; u < urls.length; u += 2)
 -                {
 -                  addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]);
 -                }
 -              }
 -            }
 -          }
 -          if (id != null)
 -          {
 -            // create Bare ID link for this RUL
 -            String[] urls = urlLink.makeUrls(id, true);
 -            if (urls != null)
 -            {
 -              for (int u = 0; u < urls.length; u += 2)
 -              {
 -                addshowLink(linkMenu, label, urls[u + 1]);
 -              }
 -            }
 -            // addshowLink(linkMenu, target, url_pref + id + url_suff);
 -          }
 -          // Now construct URLs from description but only try to do it for regex
 -          // URL links
 -          if (descr != null && urlLink.getRegexReplace() != null)
 -          {
 -            // create link for this URL from description only if regex matches
 -            String[] urls = urlLink.makeUrls(descr, true);
 -            if (urls != null)
 -            {
 -              for (int u = 0; u < urls.length; u += 2)
 -              {
 -                addshowLink(linkMenu, label, urls[u + 1]);
 -              }
 -            }
 -          }
 -        }
 -        else
 -        {
 -          addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1));
 -        }
 -        /*
 -         * final String url;
 -         * 
 -         * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID
 -         * string and any matching database reference accessions String url_pref
 -         * = link.substring(link.indexOf("|") + 1,
 -         * link.indexOf("$SEQUENCE_ID$"));
 -         * 
 -         * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
 -         * // collect matching db-refs DBRefEntry[] dbr =
 -         * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new
 -         * String[]{target}); // collect id string too String id =
 -         * seq.getName(); if (id.indexOf("|") > -1) { id =
 -         * id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) { for (int
 -         * r=0;r<dbr.length; r++) { if (dbr[r].getAccessionId().equals(id)) { //
 -         * suppress duplicate link creation for the bare sequence ID string with
 -         * this link id = null; } addshowLink(linkMenu,
 -         * dbr[r].getSource()+"|"+dbr[r].getAccessionId(), target,
 -         * url_pref+dbr[r].getAccessionId()+url_suff); } } if (id!=null) { //
 -         * create Bare ID link for this RUL addshowLink(linkMenu, target,
 -         * url_pref + id + url_suff); } } else { addshowLink(linkMenu, target,
 -         * link.substring(link.lastIndexOf("|")+1)); }
 -         */
 -      }
 -      if (linkMenu.getItemCount() > 0)
 -      {
 -        if (seq != null)
 -        {
 -          seqMenu.add(linkMenu);
 -        }
 -        else
 -        {
 -          add(linkMenu);
 -        }
 -      }
 +      addFeatureLinks(seq, links);
      }
 +
      // TODO: add group link menu entry here
      if (seq != null)
      {
    }
  
    /**
 +   * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided.
 +   * 
 +   * @param seq
 +   * @param links
 +   */
 +  void addFeatureLinks(final SequenceI seq, List<String> links)
 +  {
 +    Menu linkMenu = new Menu(MessageManager.getString("action.link"));
 +    Map<String, List<String>> linkset = new LinkedHashMap<String, List<String>>();
 +
 +    for (String link : links)
 +    {
 +      UrlLink urlLink = null;
 +      try
 +      {
 +        urlLink = new UrlLink(link);
 +      } catch (Exception foo)
 +      {
 +        System.err.println("Exception for URLLink '" + link + "': "
 +                + foo.getMessage());
 +        continue;
 +      }
 +
 +      if (!urlLink.isValid())
 +      {
 +        System.err.println(urlLink.getInvalidMessage());
 +        continue;
 +      }
 +
 +      urlLink.createLinksFromSeq(seq, linkset);
 +    }
 +
 +    addshowLinks(linkMenu, linkset.values());
 +
 +    // disable link menu if there are no valid entries
 +    if (linkMenu.getItemCount() > 0)
 +    {
 +      linkMenu.setEnabled(true);
 +    }
 +    else
 +    {
 +      linkMenu.setEnabled(false);
 +    }
 +
 +    if (seq != null)
 +    {
 +      seqMenu.add(linkMenu);
 +    }
 +    else
 +    {
 +      add(linkMenu);
 +    }
 +
 +  }
 +
 +  private void addshowLinks(Menu linkMenu, Collection<List<String>> linkset)
 +  {
 +    for (List<String> linkstrset : linkset)
 +    {
 +      // split linkstr into label and url
 +      addshowLink(linkMenu, linkstrset.get(1), linkstrset.get(3));
 +    }
 +  }
 +
 +  /**
     * Build menus for annotation types that may be shown or hidden, and for
     * 'reference annotations' that may be added to the alignment.
     */
  
      CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame);
  
 -    StringBuffer contents = new StringBuffer();
 +    StringBuilder contents = new StringBuilder(128);
      for (SequenceI seq : sequences)
      {
        contents.append(MessageManager.formatMessage(
                seq,
                true,
                true,
 -              false,
                (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr
                        .getMinMax() : null);
        contents.append("</p>");
  
    void addPDB()
    {
-     if (seq.getAllPDBEntries() != null)
+     Vector<PDBEntry> pdbs = seq.getAllPDBEntries();
+     if (pdbs != null&& !pdbs.isEmpty())
      {
-       PDBEntry entry = seq.getAllPDBEntries().firstElement();
+       PDBEntry entry = pdbs.firstElement();
  
        if (ap.av.applet.jmolAvailable)
        {
  
      if (conservationMenuItem.getState())
      {
 -
 -      sg.cs.setConservation(Conservation.calculateConservation("Group", 3,
 -              sg.getSequences(ap.av.getHiddenRepSequences()), 0, ap.av
 -                      .getAlignment().getWidth(), false, ap.av
 -                      .getConsPercGaps(), false));
 +      sg.cs.setConservation(Conservation.calculateConservation("Group", sg
 +              .getSequences(ap.av.getHiddenRepSequences()), 0, ap.av
 +              .getAlignment().getWidth(), false, ap.av.getConsPercGaps(),
 +              false));
        SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
        SliderPanel.showConservationSlider();
      }
@@@ -29,8 -29,6 +29,6 @@@ import jalview.structure.StructureSelec
  import java.awt.Container;
  import java.util.Map;
  
- import javajs.awt.Dimension;
  import org.jmol.api.JmolAppConsoleInterface;
  import org.jmol.console.AppletConsole;
  import org.jmol.java.BS;
@@@ -45,9 -43,9 +43,9 @@@ class AppletJmolBinding extends Jalview
  
    public AppletJmolBinding(AppletJmol appletJmol,
            StructureSelectionManager sSm, PDBEntry[] pdbentry,
 -          SequenceI[][] seq, String[][] chains, String protocol)
 +          SequenceI[][] seq, String protocol)
    {
 -    super(sSm, pdbentry, seq, chains, protocol);
 +    super(sSm, pdbentry, seq, protocol);
      appletJmolBinding = appletJmol;
    }
  
    }
  
    @Override
-   public Dimension resizeInnerPanel(String data)
+   public int[] resizeInnerPanel(String data)
    {
      // TODO Auto-generated method stub
      return null;
@@@ -49,8 -49,6 +49,6 @@@ import java.util.List
  import java.util.Map;
  import java.util.Vector;
  
- import javajs.awt.Dimension;
  import org.jmol.adapter.smarter.SmarterJmolAdapter;
  import org.jmol.api.JmolAppConsoleInterface;
  import org.jmol.api.JmolSelectionListener;
@@@ -74,7 -72,7 +72,7 @@@ public abstract class JalviewJmolBindin
  
    Vector<String> atomsPicked = new Vector<String>();
  
 -  public Vector<String> chainNames;
 +  private List<String> chainNames;
  
    Hashtable<String, String> chainFile;
  
    public Viewer viewer;
  
    public JalviewJmolBinding(StructureSelectionManager ssm,
 -          PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
 +          PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
            String protocol)
    {
 -    super(ssm, pdbentry, sequenceIs, chains, protocol);
 +    super(ssm, pdbentry, sequenceIs, protocol);
      /*
       * viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter(),
       * "jalviewJmol", ap.av.applet .getDocumentBase(),
      fileLoadingError = null;
      String[] oldmodels = modelFileNames;
      modelFileNames = null;
 -    chainNames = new Vector<String>();
 +    chainNames = new ArrayList<String>();
      chainFile = new Hashtable<String, String>();
      boolean notifyLoaded = false;
      String[] modelfilenames = getPdbFile();
        for (int pe = 0; pe < getPdbCount(); pe++)
        {
          boolean matches = false;
 +        addSequence(pe, getSequence()[pe]);
          if (fileName == null)
          {
            if (false)
              String chid = new String(pdb.getId() + ":"
                      + pdb.getChains().elementAt(i).id);
              chainFile.put(chid, fileName);
 -            chainNames.addElement(chid);
 +            chainNames.add(chid);
            }
            notifyLoaded = true;
          }
      setLoadingFromArchive(false);
    }
  
 +  @Override
 +  public List<String> getChainNames()
 +  {
 +    return chainNames;
 +  }
 +
    public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
    {
      notifyAtomPicked(iatom, strMeasure, null);
    }
  
    @Override
-   public Dimension resizeInnerPanel(String data)
+   public int[] resizeInnerPanel(String data)
    {
      // Jalview doesn't honour resize panel requests
      return null;