From 3e313eab680734bb0bd49d3366c5ae6ad8330ef4 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 1 Dec 2004 16:57:15 +0000 Subject: [PATCH] New classes --- src/jalview/gui/Finder.java | 129 +++++++++++++++++++++++++++++++++++++ src/jalview/gui/SplashScreen.java | 81 +++++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100755 src/jalview/gui/Finder.java create mode 100755 src/jalview/gui/SplashScreen.java diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java new file mode 100755 index 0000000..c5a2cf4 --- /dev/null +++ b/src/jalview/gui/Finder.java @@ -0,0 +1,129 @@ +package jalview.gui; + +import jalview.jbgui.GFinder; +import jalview.datamodel.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import java.util.*; + + +public class Finder extends GFinder +{ + AlignViewport av; + AlignmentPanel ap; + JInternalFrame frame; + String searchString; + + int seqIndex = 0; + int resIndex = 0; + public Finder(AlignViewport av, AlignmentPanel ap, JInternalFrame f) + { + this.av = av; + this.ap = ap; + frame = f; + + // all a big pain, but we need to wait until the frame is visible before the textfield can + // obtain the focus///////////////////////// + frame.addInternalFrameListener(new InternalFrameAdapter() + { + public void internalFrameOpened(InternalFrameEvent evt) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + textfield.requestFocus(); + } + }); + } +}); + + } + + public void textfield_actionPerformed(ActionEvent e) + { + doSearch(false); + } + + public void findNext_actionPerformed(ActionEvent e) + { + doSearch(false); + } + + public void findAll_actionPerformed(ActionEvent e) + { + resIndex=0; + seqIndex=0; + doSearch(true); + } + + public void cancel_actionPerformed(ActionEvent e) + { + try{ + frame.setClosed(true); + }catch(Exception ex){} + + } + + void doSearch(boolean findAll) + { + searchString = textfield.getText().toUpperCase(); + + ArrayList searchResults = new ArrayList(); + int [] allResults = null; + + Sequence seq; + String item; + boolean found = false; + while( !found && seqIndex-1) + { + resIndex = item.indexOf(searchString,r); + searchResults.add( Integer.toString(seqIndex) ); + searchResults.add( Integer.toString( resIndex) ); + searchResults.add( Integer.toString( (resIndex+searchString.length()-1) ) ); + if(!findAll) + { + // thats enough, break and display the result + found = true; + resIndex++; + break; + } + } + } + if(!found) + { + seqIndex++; + resIndex = 0; + } + } + + if(searchResults.size()>0) + { + + allResults = new int[searchResults.size()]; + for(int i=0; i 8) + visible = false; + + try{ + Thread.sleep(400); + iframe.setSelected(true); + } + catch(Exception ex){} + } + + closeSplash(); + + } + + public void closeSplash() + { + try + { + iframe.setClosed(true); + Desktop.splashScreenClosing(); + } + catch (Exception ex) + {} + + } + + + public void paintComponent(Graphics g) + { + g.setColor(Color.white); + g.fillRect(0,0,getWidth(),getHeight()); + g.setColor(Color.black); + g.setFont( new Font("Verdana", Font.BOLD, 18)); + if(image!=null) + g.drawImage(image, 5,60,this); + g.drawString("JalView 2005", 50,50); + g.setFont( new Font("Verdana", Font.BOLD, 14)); + g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse and Geoff Barton.",50,70); + g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",50,90); + g.drawString("If you use JalView, please cite:",50,110); + g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",50,130); + + } + +} -- 1.7.10.2