From: amwaterhouse Date: Wed, 24 Jan 2007 17:29:20 +0000 (+0000) Subject: Features output for javascript X-Git-Tag: Release_2_3~450 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7159dfadb2622541b1b39251cabef7e0655ce2b8;p=jalview.git Features output for javascript --- diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 4efab35..ef7f582 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -39,6 +39,75 @@ import jalview.appletgui.FeatureSettings; */ public class JalviewLite extends Applet { + + /////////////////////////////////////////// + //The following public methods maybe called + //externally, eg via javascript in HTML page + public String getSelectedSequences() + { + StringBuffer result = new StringBuffer(""); + + if(initialAlignFrame.viewport.getSelectionGroup()!=null) + { + SequenceI[] seqs = initialAlignFrame.viewport.getSelectionGroup(). + getSequencesInOrder( + initialAlignFrame.viewport.getAlignment()); + + for (int i = 0; i < seqs.length; i++) + result.append(seqs[i].getName() + "¬"); + } + + return result.toString(); + } + + public String getAlignment(String format) + { + return getAlignment(format, "true"); + } + + public String getAlignment(String format, String suffix) + { + try + { + boolean seqlimits = suffix.equalsIgnoreCase("true"); + + String reply = new AppletFormatAdapter().formatSequences(format, + currentAlignFrame.viewport.getAlignment(), seqlimits); + return reply; + } + catch (Exception ex) + { + ex.printStackTrace(); + return "Error retrieving alignment in " + format + " format. "; + } + } + + public String getFeatures(String format) + { + return currentAlignFrame.outputFeatures(false, format); + } + + public void loadAlignment(String text, String title) + { + Alignment al = null; + String format = new IdentifyFile().Identify(text, AppletFormatAdapter.PASTE); + try{ + al = new AppletFormatAdapter().readFile(text, + AppletFormatAdapter.PASTE, + format); + if (al.getHeight() > 0) + new AlignFrame(al, this, title, false); + }catch(java.io.IOException ex) + { + ex.printStackTrace(); + } + } + + + //////////////////////////////////////////////// + //////////////////////////////////////////////// + + static int lastFrameX = 200; static int lastFrameY = 200; boolean fileFound = true; @@ -199,44 +268,7 @@ public class JalviewLite extends Applet frame.setVisible(true); } - public String getSelectedSequences() - { - StringBuffer result = new StringBuffer(""); - - if(initialAlignFrame.viewport.getSelectionGroup()!=null) - { - SequenceI[] seqs = initialAlignFrame.viewport.getSelectionGroup(). - getSequencesInOrder( - initialAlignFrame.viewport.getAlignment()); - - for (int i = 0; i < seqs.length; i++) - result.append(seqs[i].getName() + "¬"); - } - - return result.toString(); - } - public String getAlignment(String format) - { - return getAlignment(format, "true"); - } - - public String getAlignment(String format, String suffix) - { - try - { - boolean seqlimits = suffix.equalsIgnoreCase("true"); - - String reply = new AppletFormatAdapter().formatSequences(format, - currentAlignFrame.viewport.getAlignment().getSequences(), seqlimits); - return reply; - } - catch (Exception ex) - { - ex.printStackTrace(); - return "Error retrieving alignment in " + format + " format. "; - } - } /** * This paints the background surrounding the "Launch Jalview button"