Warn if out of memory
authoramwaterhouse <Andrew Waterhouse>
Tue, 13 Sep 2005 17:44:08 +0000 (17:44 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 13 Sep 2005 17:44:08 +0000 (17:44 +0000)
src/jalview/gui/PCAPanel.java
src/jalview/ws/JPredClient.java
src/jalview/ws/MsaWSClient.java

index 474a158..d1005c2 100755 (executable)
@@ -28,6 +28,7 @@ import java.awt.*;
 import java.awt.event.*;\r
 \r
 import java.util.*;\r
+import javax.swing.JOptionPane;\r
 \r
 \r
 /**\r
@@ -89,46 +90,59 @@ public class PCAPanel extends GPCAPanel implements Runnable
      */\r
     public void run()\r
     {\r
-                pca = new PCA(seqs);\r
-                pca.run();\r
-\r
-                // Now find the component coordinates\r
-                int ii = 0;\r
-\r
-                while ((ii < seqs.length) && (seqs[ii] != null))\r
-                {\r
-                    ii++;\r
-                }\r
-\r
-                double[][] comps = new double[ii][ii];\r
-\r
-                for (int i = 0; i < ii; i++)\r
-                {\r
-                    if (pca.getEigenvalue(i) > 1e-4)\r
-                    {\r
-                        comps[i] = pca.component(i);\r
-                    }\r
-                }\r
-\r
-                //////////////////\r
-                xCombobox.setSelectedIndex(0);\r
-                yCombobox.setSelectedIndex(1);\r
-                zCombobox.setSelectedIndex(2);\r
-\r
-                top = pca.getM().rows - 1;\r
-\r
-                Vector points = new Vector();\r
-                float[][] scores = pca.getComponents(top - 1, top - 2, top - 3, 100);\r
-\r
-                for (int i = 0; i < pca.getM().rows; i++)\r
-                {\r
-                    SequencePoint sp = new SequencePoint(seqs[i], scores[i]);\r
-                    points.addElement(sp);\r
-                }\r
-\r
-                rc.setPoints(points, pca.getM().rows);\r
-                rc.repaint();\r
-                seqs = null;\r
+      try{\r
+        pca = new PCA(seqs);\r
+        pca.run();\r
+\r
+        // Now find the component coordinates\r
+        int ii = 0;\r
+\r
+        while ( (ii < seqs.length) && (seqs[ii] != null))\r
+        {\r
+          ii++;\r
+        }\r
+\r
+        double[][] comps = new double[ii][ii];\r
+\r
+        for (int i = 0; i < ii; i++)\r
+        {\r
+          if (pca.getEigenvalue(i) > 1e-4)\r
+          {\r
+            comps[i] = pca.component(i);\r
+          }\r
+        }\r
+\r
+        //////////////////\r
+        xCombobox.setSelectedIndex(0);\r
+        yCombobox.setSelectedIndex(1);\r
+        zCombobox.setSelectedIndex(2);\r
+\r
+        top = pca.getM().rows - 1;\r
+\r
+        Vector points = new Vector();\r
+        float[][] scores = pca.getComponents(top - 1, top - 2, top - 3, 100);\r
+\r
+        for (int i = 0; i < pca.getM().rows; i++)\r
+        {\r
+          SequencePoint sp = new SequencePoint(seqs[i], scores[i]);\r
+          points.addElement(sp);\r
+        }\r
+\r
+        rc.setPoints(points, pca.getM().rows);\r
+        rc.repaint();\r
+        seqs = null;\r
+      }\r
+     catch(OutOfMemoryError er)\r
+      { JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+                                              "Out of memory calculating PCA!!"\r
+                                              +\r
+                                              "\nSee help files for increasing Java Virtual Machine memory."\r
+                                              , "Out of memory",\r
+                                              JOptionPane.WARNING_MESSAGE);\r
+        System.out.println("PCAPanel: "+er);\r
+\r
+      }\r
+\r
     }\r
 \r
     /**\r
index 4302df2..80a66c3 100755 (executable)
@@ -248,6 +248,18 @@ public class JPredClient
           {\r
           }\r
         }\r
+        catch (OutOfMemoryError er)\r
+        {\r
+          jobComplete = true;\r
+          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
+          JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+                                                "Out of memory handling result!!"\r
+                                                +\r
+              "\nSee help files for increasing Java Virtual Machine memory."\r
+                                                , "Out of memory",\r
+                                                JOptionPane.WARNING_MESSAGE);\r
+          System.out.println("JPredClient: "+er);\r
+        }\r
       }\r
       if (result!=null)\r
         if (! (result.isJobFailed() || result.isServerError()))\r
index 7f754e0..0d4b2c1 100755 (executable)
@@ -280,8 +280,9 @@ public class MsaWSClient
           {\r
             if (result.getStatus() != null)\r
             {\r
-              wsInfo.setProgressText(OutputHeader + "\n" +\r
-                                     result.getStatus());\r
+              System.out.println("result "+result.getStatus().length());\r
+              wsInfo.setProgressText(OutputHeader + "\n" );\r
+                                //     result.getStatus());\r
             }\r
             if (result.isServerError())\r
             {\r
@@ -325,6 +326,16 @@ public class MsaWSClient
           {\r
           }\r
         }\r
+        catch(OutOfMemoryError er)\r
+        {\r
+          jobComplete = true;\r
+          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
+          JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+              "Out of memory handling result!!"\r
+             +"\nSee help files for increasing Java Virtual Machine memory."\r
+             ,"Out of memory", JOptionPane.WARNING_MESSAGE );\r
+          System.out.println("MsaWSClient: "+er);\r
+        }\r
       }\r
 \r
       if (allowedServerExceptions == 0)\r
@@ -425,18 +436,21 @@ public class MsaWSClient
 \r
         if (result.getStatus() != null)\r
         {\r
-          OutputHeader += ("\n" + result.getStatus());\r
+          System.out.println("get status  " +result.getStatus().length());\r
+         // OutputHeader += ("\n" + result.getStatus());\r
         }\r
 \r
         if (result.getMsa() != null)\r
         {\r
-          OutputHeader += "\nAlignment Object Method Notes\n";\r
+          System.out.println("get msa");\r
+       //   OutputHeader += "\nAlignment Object Method Notes\n";\r
 \r
           String[] lines = result.getMsa().getMethod();\r
 \r
+System.out.println("lines "+lines.length);\r
           for (int line = 0; line < lines.length; line++)\r
           {\r
-            OutputHeader += (lines[line] + "\n");\r
+           // OutputHeader += (lines[line] + "\n");\r
           }\r
 \r
           // JBPNote The returned files from a webservice could be hidden behind icons in the monitor window that, when clicked, pop up their corresponding data\r