\r
public void clustalAlignMenuItem_actionPerformed(ActionEvent e)\r
{\r
- // JBPNote\r
- // Should check to see if the server settings are valid\r
- // Need visual-delay indication here.\r
- jalview.ws.Jemboss jemboss = new jalview.ws.Jemboss();\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, 300, 80);\r
\r
- Vector sv = viewport.getAlignment().getSequences();\r
- SequenceI[] seqs = new SequenceI[sv.size()];\r
+ }\r
\r
- int i=0;\r
- do\r
+ class ClustalThread extends JPanel implements Runnable\r
+ {\r
+ Image [] image;\r
+ int imageIndex = 0;\r
+ boolean webServiceRunning = false;\r
+ JInternalFrame frame;\r
+ public ClustalThread(JInternalFrame frame)\r
{\r
- seqs[i] = (SequenceI) sv.elementAt(i);\r
- } while (++i<sv.size());\r
-\r
- SequenceI[] alignment = jemboss.clustalW(seqs); // gaps removed within method\r
+ this.frame = frame;\r
+ image = new Image[9];\r
+ for(int i=0; i<9; i++)\r
+ {\r
+ java.net.URL url = getClass().getResource("/dna" + (i+1) + ".gif");\r
+ if (url != null)\r
+ {\r
+ image[i] = java.awt.Toolkit.getDefaultToolkit().createImage(url);\r
+ MediaTracker mt = new MediaTracker(this);\r
+ mt.addImage(image[i], i);\r
+ try{mt.waitForID(i);}\r
+ catch(Exception ex){}\r
+ }\r
+ }\r
+ DNATwirler twirler = new DNATwirler();\r
+ twirler.start();\r
+ webServiceRunning = true;\r
+ }\r
\r
- if (alignment != null)\r
+ class DNATwirler extends Thread\r
{\r
- AlignFrame af = new AlignFrame(new Alignment(alignment));\r
- Desktop.addInternalFrame(af, getTitle().concat(" - ClustalW Alignment"),\r
- 700, 500); // JBPNote - is there a new window geom. property ?\r
+ public void run()\r
+ {\r
+ while(webServiceRunning)\r
+ {\r
+ try{\r
+ Thread.sleep(100);\r
+ imageIndex++;\r
+ imageIndex %=9;\r
+ repaint();\r
+ }\r
+ catch(Exception ex){}\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"),\r
+ 700, 500); // JBPNote - is there a new window geom. property ?\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 g)\r
+ {\r
+ g.setColor(Color.white);\r
+ g.fillRect(0,0,getWidth(), getHeight());\r
+ if(image!=null)\r
+ {\r
+ g.drawImage(image[imageIndex],10,10,this);\r
+ }\r
+ g.setFont(new Font("Arial", Font.BOLD, 12));\r
+ g.setColor(Color.black);\r
+ g.drawString("Clustal Alignment Web Service running", 30,30);\r
+ }\r
+\r
+\r
}\r
\r
\r