Merge branch 'Release_2_7_Branch_hotfix_JAL-962' into develop
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 21 Oct 2011 12:13:45 +0000 (13:13 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 21 Oct 2011 12:13:45 +0000 (13:13 +0100)
1  2 
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/FeatureRenderer.java
src/jalview/appletgui/FeatureSettings.java
src/jalview/bin/JalviewLite.java
src/jalview/javascript/JalviewLiteJsApi.java

@@@ -1,6 -1,6 +1,6 @@@
  /*\r
   * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
 - * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
 + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
   * \r
   * This file is part of Jalview.\r
   * \r
@@@ -161,14 -161,26 +161,26 @@@ public class AlignFrame extends Embmenu
    }\r
  \r
    /**\r
-    * DOCUMENT ME!\r
+    * Load a features file onto the alignment\r
     * \r
-    * @param String\r
-    *          DOCUMENT ME!\r
+    * @param file file URL, content, or other resolvable path\r
+    * @param type is protocol for accessing data referred to by file\r
     */\r
  \r
    public void parseFeaturesFile(String file, String type)\r
    {\r
+     parseFeaturesFile(file, type, true);\r
+   }\r
+   \r
+   /**\r
+    * Load a features file onto the alignment\r
+    * \r
+    * @param file file URL, content, or other resolvable path\r
+    * @param type is protocol for accessing data referred to by file\r
+    * @param autoenabledisplay when true, display features flag will be automatically enabled if features are loaded\r
+    */\r
+   public void parseFeaturesFile(String file, String type, boolean autoenabledisplay)\r
+   {    \r
      Hashtable featureLinks = new Hashtable();\r
      boolean featuresFile = false;\r
      try\r
        {\r
          alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks;\r
        }\r
-       viewport.showSequenceFeatures = true;\r
-       sequenceFeatures.setState(true);\r
+       if (autoenabledisplay)\r
+       {\r
+         viewport.showSequenceFeatures = true;\r
+         sequenceFeatures.setState(true);\r
+       }\r
        if (viewport.featureSettings != null)\r
        {\r
          viewport.featureSettings.refreshTable();\r
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
 - * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
 + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
   * 
   * This file is part of Jalview.
   * 
@@@ -1064,9 -1064,9 +1064,9 @@@ public class FeatureRenderer implement
        for (int i = 0; i < toset.length; i++)
        {
          Object st = featureGroups.get(toset[i]);
+         featureGroups.put(toset[i], new Boolean(visible));
          if (st != null)
          {
-           featureGroups.put(toset[i], new Boolean(visible));
            rdrw = rdrw || (visible != ((Boolean) st).booleanValue());
          }
        }
      }
    }
  
+   ArrayList<String> hiddenGroups=new ArrayList<String>();
    /**
     * analyse alignment for groups and hash tables (used to be embedded in
     * FeatureSettings.setTableData)
      {
        featureGroups = new Hashtable();
      }
-     Vector allFeatures = new Vector();
-     Vector allGroups = new Vector();
+     hiddenGroups =new ArrayList<String>();
+     hiddenGroups.addAll(featureGroups.keySet());
+     ArrayList allFeatures = new ArrayList();
+     ArrayList allGroups = new ArrayList();
      SequenceFeature[] tmpfeatures;
      String group;
      for (int i = 0; i < av.alignment.getHeight(); i++)
          if (tmpfeatures[index].getFeatureGroup() != null)
          {
            group = tmpfeatures[index].featureGroup;
+           // Remove group from the hiddenGroup list
+           hiddenGroups.remove(group);
            if (!allGroups.contains(group))
            {
-             allGroups.addElement(group);
+             allGroups.add(group);
  
              boolean visible = true;
              if (featureGroups.containsKey(group))
  
          if (!allFeatures.contains(tmpfeatures[index].getType()))
          {
-           allFeatures.addElement(tmpfeatures[index].getType());
+           allFeatures.add(tmpfeatures[index].getType());
          }
          index++;
        }
@@@ -1,6 -1,6 +1,6 @@@
  /*
   * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
 - * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
 + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
   * 
   * This file is part of Jalview.
   * 
@@@ -118,8 -118,10 +118,10 @@@ public class FeatureSettings extends Pa
  
      if (groupPanel != null)
      {
-       groupPanel.setLayout(new GridLayout(fr.featureGroups.size() / 4 + 1,
-               4));
+       groupPanel
+               .setLayout(new GridLayout(
+                       (fr.featureGroups.size() - fr.hiddenGroups.size()) / 4 + 1,
+                       4));
        groupPanel.validate();
  
        add(groupPanel, BorderLayout.NORTH);
        rdrw = true;
        groupPanel.removeAll();
      }
+     // TODO: JAL-964 - smoothly incorporate new group entries if panel already displayed and new groups present
      Enumeration gps = fr.featureGroups.keys();
      while (gps.hasMoreElements())
      {
        check.addMouseListener(this);
        check.setFont(new Font("Serif", Font.BOLD, 12));
        check.addItemListener(this);
+       check.setVisible(fr.hiddenGroups.contains(group));
        groupPanel.add(check);
      }
      if (rdrw)
@@@ -1,6 -1,6 +1,6 @@@
  /*\r
   * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
 - * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
 + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
   * \r
   * This file is part of Jalview.\r
   * \r
@@@ -716,6 -716,29 +716,29 @@@ public class JalviewLite extends Apple
    /*\r
     * (non-Javadoc)\r
     * \r
+    * @see jalview.bin.JalviewLiteJsApi#loadAnnotation(java.lang.String)\r
+    */\r
+   public void loadFeatures(String features, boolean autoenabledisplay)\r
+   {\r
+     loadFeaturesFrom(getDefaultTargetFrame(), features, autoenabledisplay);\r
+   }\r
\r
+   /*\r
+    * (non-Javadoc)\r
+    * \r
+    * @see\r
+    * jalview.bin.JalviewLiteJsApi#loadAnnotationFrom(jalview.appletgui.AlignFrame\r
+    * , java.lang.String)\r
+    */\r
+   public void loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay)\r
+   {\r
+     alf.parseFeaturesFile(features, AppletFormatAdapter.PASTE, autoenabledisplay);\r
+   }\r
\r
\r
+   /*\r
+    * (non-Javadoc)\r
+    * \r
     * @see jalview.bin.JalviewLiteJsApi#getFeatures(java.lang.String)\r
     */\r
    public String getFeatures(String format)\r
            }\r
          }\r
  \r
-         String param = applet.getParameter("features");\r
+         // ///////////////////////////\r
+         // modify display of features\r
+         // we do this before any features have been loaded, ensuring any hidden groups are hidden when features first displayed\r
+         //\r
+         // hide specific groups\r
+         // \r
+         String param = applet.getParameter("hidefeaturegroups");\r
+         if (param != null)\r
+         {\r
+           newAlignFrame.setFeatureGroupState(separatorListToArray(param), false);        \r
+ //          applet.setFeatureGroupStateOn(newAlignFrame, param, false);\r
+         }\r
+         // show specific groups\r
+         param = applet.getParameter("showfeaturegroups");\r
+         if (param != null)\r
+         {\r
+           newAlignFrame.setFeatureGroupState(separatorListToArray(param), true);        \r
+ //          applet.setFeatureGroupStateOn(newAlignFrame, param, true);\r
+         }\r
+         // and now load features\r
+         param = applet.getParameter("features");\r
          if (param != null)\r
          {\r
            param = setProtocolState(param);\r
                    protocols);\r
  \r
          }\r
-         // ///////////////////////////\r
-         // modify display of features\r
-         //\r
-         // hide specific groups\r
-         param = applet.getParameter("hidefeaturegroups");\r
-         if (param != null)\r
-         {\r
-           applet.setFeatureGroupStateOn(newAlignFrame, param, false);\r
-         }\r
-         // show specific groups\r
-         param = applet.getParameter("showfeaturegroups");\r
-         if (param != null)\r
-         {\r
-           applet.setFeatureGroupStateOn(newAlignFrame, param, true);\r
-         }\r
        }\r
        else\r
        {\r
@@@ -1,6 -1,6 +1,6 @@@
  /*******************************************************************************
   * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
 - * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
 + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
   *
   * This file is part of Jalview.
   *
@@@ -280,6 -280,21 +280,21 @@@ public interface JalviewLiteJsAp
    public abstract void loadAnnotationFrom(AlignFrame alf, String annotation);
  
    /**
+    * parse the given string as a jalview feature or GFF annotation file and optionally enable feature display on the current alignFrame
+    * @param features - gff or features file
+    * @param autoenabledisplay - when true, feature display will be enabled if any features can be parsed from the string.
+    */
+   public abstract void loadFeatures(String features, boolean autoenabledisplay);
+   /**
+    * parse the given string as a jalview feature or GFF annotation file and optionally enable feature display on the given alignFrame.
+    * @param alf
+    * @param features - gff or features file
+    * @param autoenabledisplay - when true, feature display will be enabled if any features can be parsed from the string.
+    */
+   public abstract void loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay);
+   /**
     * get the sequence features in the given format (Jalview or GFF)
     * @param format
     * @return