View Properties
authoramwaterhouse <Andrew Waterhouse>
Wed, 25 Apr 2007 14:06:31 +0000 (14:06 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 25 Apr 2007 14:06:31 +0000 (14:06 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/jbgui/GAlignFrame.java

index c60355c..bcb5771 100755 (executable)
@@ -911,7 +911,8 @@ public class AlignFrame
     new AnnotationExporter().exportAnnotations(
       alignPanel,
         viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null,
-      viewport.alignment.getGroups()
+      viewport.alignment.getGroups(),
+      ((Alignment)viewport.alignment).alignmentProperties
         );
   }
 
@@ -2266,6 +2267,51 @@ public class AlignFrame
     alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected());
   }
 
+  public void alignmentProperties()
+  {
+    JEditorPane editPane = new JEditorPane("text/html","");
+    editPane.setEditable(false);
+    StringBuffer contents = new StringBuffer("<html>");
+
+    float avg  = 0;
+    int min=Integer.MAX_VALUE, max=0;
+    for(int i=0; i<viewport.alignment.getHeight(); i++)
+    {
+      int size = viewport.alignment.getSequenceAt(i).getEnd()
+          -viewport.alignment.getSequenceAt(i).getStart();
+      avg += size;
+      if(size>max)
+        max = size;
+      if(size<min)
+        min = size;
+    }
+    avg = avg/(float)viewport.alignment.getHeight();
+
+    contents.append("<br>Sequences: "+ viewport.alignment.getHeight());
+    contents.append("<br>Minimum Sequence Length: "+min);
+    contents.append("<br>Maximum Sequence Length: "+max);
+    contents.append("<br>Average Length: "+(int)avg);
+
+    if (((Alignment)viewport.alignment).alignmentProperties != null)
+    {
+      Hashtable props = ((Alignment)viewport.alignment).alignmentProperties;
+      Enumeration en = props.keys();
+      contents.append("<br><br><table border=\"1\">");
+      while(en.hasMoreElements())
+      {
+        String key = en.nextElement().toString();
+        contents.append("<tr><td>"+key+"</td><td>"+props.get(key)+"</td></tr>");
+      }
+      contents.append("</table>");
+    }
+    editPane.setText(contents.toString()+"</html>");
+    JInternalFrame frame = new JInternalFrame();
+    frame.add(editPane);
+
+    Desktop.instance.addInternalFrame(frame,"Alignment Properties: "+getTitle(),500,400);
+  }
+
+
   /**
    * DOCUMENT ME!
    *
index 1b89d71..bf45112 100755 (executable)
@@ -145,6 +145,7 @@ public class GAlignFrame
   protected JMenuItem gatherViews = new JMenuItem();\r
   protected JMenuItem expandViews = new JMenuItem();\r
   JMenuItem pageSetup = new JMenuItem();\r
+  JMenuItem alignmentProperties = new JMenuItem();\r
   public GAlignFrame()\r
   {\r
     try\r
@@ -1236,6 +1237,14 @@ public class GAlignFrame
         pageSetup_actionPerformed(e);\r
       }\r
     });\r
+    alignmentProperties.setText("Alignment Properties...");\r
+    alignmentProperties.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent actionEvent)\r
+      {\r
+        alignmentProperties();\r
+      }\r
+    });\r
 \r
     alignFrameMenuBar.add(fileMenu);\r
     alignFrameMenuBar.add(editMenu);\r
@@ -1289,6 +1298,8 @@ public class GAlignFrame
     viewMenu.add(showSeqFeatures);\r
     viewMenu.add(featureSettings);\r
     viewMenu.addSeparator();\r
+    viewMenu.add(alignmentProperties);\r
+    viewMenu.addSeparator();\r
     viewMenu.add(overviewMenuItem);\r
     colourMenu.add(applyToAllGroups);\r
     colourMenu.add(textColour);\r
@@ -1814,4 +1825,9 @@ public class GAlignFrame
   {\r
 \r
   }\r
+\r
+  public void alignmentProperties()\r
+  {\r
+\r
+  }\r
 }\r