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