From: amwaterhouse Date: Wed, 2 Feb 2005 17:17:07 +0000 (+0000) Subject: Modified for wrapAlignement X-Git-Tag: Release_2_0~702 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7e0e6d29fbd9fe42b1baa82bc03fb899c4e5e1e2;hp=79d25fa4e3ae375321d8cc29906cff5a507cbab4;p=jalview.git Modified for wrapAlignement --- diff --git a/src/jalview/io/HTMLOutput.java b/src/jalview/io/HTMLOutput.java index d15a6e8..b70ba68 100755 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@ -11,12 +11,14 @@ import java.util.*; public class HTMLOutput { - + AlignViewport av; + SequenceRenderer sr; + Color color; public HTMLOutput(AlignViewport av) { - SequenceRenderer sr = new SequenceRenderer(av); - Color color; + this.av = av; + sr = new SequenceRenderer(av); JFileChooser chooser = new JFileChooser(jalview.bin.Cache.LAST_DIRECTORY); chooser.setDialogTitle("Save as HTML"); chooser.setToolTipText("Save"); @@ -45,80 +47,180 @@ public class HTMLOutput out.println("-->"); out.println(""); out.println(""); - out.println(""); - } - ////////////// - out.println("
\n"); - out.println("\n"); - ////////////// - SequenceGroup [] groups; - SequenceI seq; - ColourSchemeI cs = null; - AlignmentI alignment = av.getAlignment(); - String r,g,b; + if(av.getWrapAlignment()) + drawWrappedAlignment(out); + else + drawUnwrappedAlignment(out); - // draws the top row, the measure rule - out.println(""); - int i=0; - for(i=10; i"+i+"
|
"); + out.println("\n\n"); + out.close(); + jalview.util.BrowserLauncher.openURL( "file:///"+choice ); + } + catch(Exception ex){ex.printStackTrace();} + } + } - out.println(""); - out.println(""); + void drawUnwrappedAlignment(PrintWriter out) + { - for (i = 0; i < alignment.getHeight(); i++) - { - seq = alignment.getSequenceAt(i); - groups = alignment.findAllGroups( seq ); - out.println(""); + out.println("
"+i+"
|
"+seq.getDisplayId()+"  
\n"); + out.println("\n"); + + + ////////////// + SequenceGroup [] groups; + SequenceI seq; + ColourSchemeI cs = null; + AlignmentI alignment = av.getAlignment(); + String r,g,b; + // draws the top row, the measure rule + out.println(""); + int i=0; + for(i=10; i"+i+"
|
"); - for (int res = 0; res < seq.getLength(); res++) - { - cs = av.getGlobalColourScheme(); + out.println(""); + out.println(""); - if(groups!=null) + for (i = 0; i < alignment.getHeight(); i++) + { + seq = alignment.getSequenceAt(i); + groups = alignment.findAllGroups( seq ); + out.println(""); + + + for (int res = 0; res < seq.getLength(); res++) + { + cs = av.getGlobalColourScheme(); + + if(groups!=null) + { + for (int k = 0; k < groups.length; k++) + if (groups[k].getStartRes() <= res && groups[k].getEndRes() >= res) { - for (int k = 0; k < groups.length; k++) - if (groups[k].getStartRes() <= res && groups[k].getEndRes() >= res) + cs = groups[k].cs; + break; + } + } + + + color = sr.getResidueBoxColour(cs, seq, res); + + if(color.getRGB()<-1) + { + r = Integer.toHexString(color.getRed()); + if(r.length()<2) + r = "0"+r; + g = Integer.toHexString(color.getGreen()); + if(g.length()<2) + g = "0"+g; + b = Integer.toHexString(color.getBlue()); + if(b.length()<2) + b = "0"+b; + out.println(""); + } + else + out.println(""); + + } + + out.println(""); + } + ////////////// + out.println("
"+i+"
|
"+seq.getDisplayId()+"  "+seq.getCharAt(res)+""+seq.getCharAt(res)+"
"); + out.println("
"); + + } + + void drawWrappedAlignment(PrintWriter out) + { + //////////////////////////////////// + /// How many sequences and residues can we fit on a printable page? + AlignmentI al = av.getAlignment(); + SequenceGroup [] groups; + SequenceI seq; + ColourSchemeI cs = null; + String r,g,b; + + out.println("
\n"); + out.println("\n"); + + for(int startRes=0; startResal.getWidth()) + endRes = al.getWidth(); + + out.println(""); + out.println(""); + for (int i = startRes+10; i < endRes; i += 10) + out.println(""); + + // out.println(""); + out.println(""); + + + + for (int s = 0; s < al.getHeight(); s++) + { + out.println(""); + seq = al.getSequenceAt(s); + groups = al.findAllGroups( seq ); + out.println(""); + + for (int res = startRes; res < endRes; res++) + { + cs = av.getGlobalColourScheme(); + if(groups!=null) { - cs = groups[k].cs; - break; + for (int k = 0; k < groups.length; k++) + if (groups[k].getStartRes() <= res && groups[k].getEndRes() >= res) + { + cs = groups[k].cs; + break; + } } - } + color = sr.getResidueBoxColour(cs, seq, res); - color = sr.getResidueBoxColour(cs, seq, res); + if(color.getRGB()<-1) + { + r = Integer.toHexString(color.getRed()); + if(r.length()<2) + r = "0"+r; + g = Integer.toHexString(color.getGreen()); + if(g.length()<2) + g = "0"+g; + b = Integer.toHexString(color.getBlue()); + if(b.length()<2) + b = "0"+b; + out.println(""); + } + else + out.println(""); - if(color.getRGB()<-1) - { - r = Integer.toHexString(color.getRed()); - if(r.length()<2) - r = "0"+r; - g = Integer.toHexString(color.getGreen()); - if(g.length()<2) - g = "0"+g; - b = Integer.toHexString(color.getBlue()); - if(b.length()<2) - b = "0"+b; - out.println(""); - } - else - out.println(""); + } - } + out.println(""); + + } + if(endRes"); + + + + } + + out.println("
 " + i + "
|
" + i + + // "
|
"+seq.getDisplayId()+"  "+seq.getCharAt(res)+""+seq.getCharAt(res)+""+seq.getCharAt(res)+""+seq.getCharAt(res)+"
"); + out.println("
"); - out.println("
"); - out.println("\n\n"); - out.close(); - jalview.util.BrowserLauncher.openURL( "file:///"+choice ); - } - catch(Exception ex){ex.printStackTrace();} - } }