use webservice info to display web service state
authoramwaterhouse <Andrew Waterhouse>
Thu, 14 Apr 2005 15:04:13 +0000 (15:04 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 14 Apr 2005 15:04:13 +0000 (15:04 +0000)
src/jalview/gui/AlignFrame.java

index c1a7105..9ec2f23 100755 (executable)
@@ -785,7 +785,6 @@ public class AlignFrame extends GAlignFrame
           c.calculate();\r
           c.verdict(false, viewport.ConsPercGaps);\r
           ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
-\r
           sg.cs = ccs;\r
         }\r
 \r
@@ -824,17 +823,13 @@ if ( viewport.getConservationSelected() )
    Conservation c = new Conservation("All",\r
                                      ResidueProperties.propHash, 3,\r
                                      al.getSequences(), 0,\r
-                                     al.getWidth());\r
+                                     al.getWidth()-1);\r
 \r
    c.calculate();\r
    c.verdict(false, viewport.ConsPercGaps);\r
 \r
    ccs = new ConservationColourScheme(c, cs);\r
 \r
- //  int threshold = Desktop.setConservationSliderSource(alignPanel, ccs,    "Background");\r
-\r
- //  ccs.inc = threshold;\r
-\r
    viewport.setGlobalColourScheme(ccs);\r
 \r
   }\r
@@ -846,11 +841,13 @@ if ( viewport.getConservationSelected() )
 \r
   protected void modifyPID_actionPerformed(ActionEvent e)\r
   {\r
+    if(viewport.getAbovePIDThreshold())\r
     Desktop.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(), "Background");\r
   }\r
 \r
   protected void modifyConservation_actionPerformed(ActionEvent e)\r
   {\r
+    if(viewport.getConservationSelected())\r
     Desktop.setConservationSliderSource(alignPanel, viewport.globalColourScheme,    "Background");\r
   }\r
 \r
@@ -1074,126 +1071,64 @@ if ( viewport.getConservationSelected() )
 \r
   public void clustalAlignMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    JInternalFrame frame = new JInternalFrame();\r
-    ClustalThread ct = new ClustalThread(frame);\r
-    Thread t = new Thread(ct);\r
-    t.start();\r
-    frame.setContentPane(ct);\r
-     Desktop.addInternalFrame(frame, title, 320, 90);\r
+     WebserviceInfo info = new WebserviceInfo("Clustal web service",\r
+     "\"Thompson, J.D., Higgins, D.G. and Gibson, T.J. (1994) CLUSTAL W: improving the sensitivity of progressive multiple"+\r
+     " sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice."\r
+    +" Nucleic Acids Research, submitted, June 1994.",\r
+     450, 150);\r
 \r
+    ClustalThread thread = new ClustalThread(info);\r
+    thread.start();\r
   }\r
 \r
-  class ClustalThread extends JPanel implements Runnable\r
-  {\r
-    Image image;\r
-    int angle = 0;\r
-    boolean webServiceRunning = false;\r
-    JInternalFrame frame;\r
-    public ClustalThread(JInternalFrame frame)\r
+    class ClustalThread extends Thread\r
     {\r
-      this.frame = frame;\r
+      WebserviceInfo info;\r
+      public ClustalThread(WebserviceInfo info)\r
+      {this.info = info; }\r
 \r
-      java.net.URL url = getClass().getResource("/images/logo.gif");\r
-      if (url != null)\r
+      public void run()\r
       {\r
-        image = java.awt.Toolkit.getDefaultToolkit().createImage(url);\r
-        MediaTracker mt = new MediaTracker(this);\r
-        mt.addImage(image, 0);\r
-        try\r
+        info.setStatus(WebserviceInfo.STATE_RUNNING);\r
+        jalview.ws.Jemboss jemboss = new jalview.ws.Jemboss();\r
+        Vector sv = viewport.getAlignment().getSequences();\r
+        SequenceI[] seqs = new SequenceI[sv.size()];\r
+\r
+        int i = 0;\r
+        do\r
         {\r
-          mt.waitForID(0);\r
+          seqs[i] = (SequenceI) sv.elementAt(i);\r
         }\r
-        catch (Exception ex)\r
-        {}\r
-      }\r
+        while (++i < sv.size());\r
 \r
-      ImageSpinner spinner = new ImageSpinner();\r
-      spinner.start();\r
-      webServiceRunning = true;\r
-    }\r
-\r
-    class ImageSpinner extends Thread\r
-    {\r
-      public void run()\r
-      {\r
-        while(webServiceRunning)\r
+        SequenceI[] alignment = jemboss.clustalW(seqs); // gaps removed within method\r
+        if (alignment != null)\r
+        {\r
+          AlignFrame af = new AlignFrame(new Alignment(alignment));\r
+          Desktop.addInternalFrame(af, title.concat(" - ClustalW Alignment"),\r
+                                   NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
+          af.clustalColour_actionPerformed(null);\r
+          af.clustalColour.setSelected(true);\r
+          info.setStatus(WebserviceInfo.STATE_STOPPED_OK);\r
+        }\r
+        else\r
         {\r
-          try{\r
-            Thread.sleep(10);\r
-            angle+=1;\r
-            angle %=360;\r
-            repaint();\r
-          }\r
-          catch(Exception ex){}\r
+            info.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
+            info.appendProgressText("Problem obtaining clustal alignment");\r
         }\r
       }\r
     }\r
 \r
-    // JBPNote\r
-    // Should check to see if the server settings are valid\r
-    // Need visual-delay indication here.\r
-    public void run()\r
-       {\r
-         jalview.ws.Jemboss jemboss = new jalview.ws.Jemboss();\r
-         Vector sv = viewport.getAlignment().getSequences();\r
-         SequenceI[] seqs = new SequenceI[sv.size()];\r
-\r
-         int i = 0;\r
-         do\r
-         {\r
-           seqs[i] = (SequenceI) sv.elementAt(i);\r
-         }\r
-         while (++i < sv.size());\r
-\r
-         SequenceI[] alignment = jemboss.clustalW(seqs); // gaps removed within method\r
-\r
-         if (alignment != null)\r
-         {\r
-           AlignFrame af = new AlignFrame(new Alignment(alignment));\r
-           Desktop.addInternalFrame(af, getTitle().concat(" - ClustalW Alignment"),NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
-           af.clustalColour_actionPerformed(null);\r
-           af.clustalColour.setSelected(true);\r
-         }\r
-         else\r
-           JOptionPane.showMessageDialog(Desktop.desktop, "Problem obtaining clustal alignment", "Web service error",\r
-                                         JOptionPane.WARNING_MESSAGE);\r
-\r
-         webServiceRunning = false;\r
-         try{\r
-           frame.setClosed(true);\r
-         }catch(Exception ex){}\r
-       }\r
-\r
-       public void paintComponent(Graphics g1)\r
-       {\r
-         Graphics2D g = (Graphics2D)g1;\r
-         g.setColor(Color.white);\r
-         g.fillRect(0,0,getWidth(), getHeight());\r
-         if(image!=null)\r
-         {\r
-\r
-           g.rotate (Math.toRadians(angle), 28, 28);\r
-\r
-           g.drawImage(image,10,10,this);\r
-           g.rotate (-Math.toRadians(angle), 28, 28 );\r
-         }\r
-         g.setFont(new Font("Arial", Font.BOLD, 12));\r
-         g.setColor(Color.black);\r
-         g.drawString("Clustal Alignment Web Service running", 60,30);\r
-       }\r
-  }\r
   protected void jpred_actionPerformed(ActionEvent e)\r
 {\r
 \r
-    JInternalFrame frame = new JInternalFrame();\r
     if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize()>0)\r
     {\r
       // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!\r
       SequenceGroup seqs = viewport.getSelectionGroup();\r
       if (seqs.getSize() == 1 || !viewport.alignment.isAligned())\r
       {\r
-        JPredClient ct = new JPredClient( (SequenceI)\r
-                                         seqs.getSequenceAt(0));\r
+        JPredClient ct = new JPredClient( (SequenceI)seqs.getSequenceAt(0));\r
       }\r
       else\r
       {\r