-public void drawPostscript(PostscriptProperties pp) {\r
- try {\r
- int width = 0;\r
- int height = 0;\r
-\r
- printout("%!\n");\r
-\r
- printout("/" + pp.font + " findfont\n");\r
- printout(pp.fsize + " scalefont setfont\n");\r
-\r
- int offx = pp.xoffset;\r
- int offy = pp.yoffset;\r
-\r
- if (pp.orientation == PostscriptProperties.PORTRAIT) {\r
- width = PostscriptProperties.SHORTSIDE;\r
- height = PostscriptProperties.LONGSIDE;\r
- } else {\r
- height = PostscriptProperties.SHORTSIDE;\r
- width = PostscriptProperties.LONGSIDE;\r
- printout(height + " 0 translate\n90 rotate\n");\r
- }\r
- float wscale = (float)(width*.8-offx*2)/tree.getMaxHeight();\r
- SequenceNode top = tree.getTopNode();\r
-\r
- if (top.count == 0) {\r
- top.count = ((SequenceNode)top.left()).count + ((SequenceNode)top.right()).count ;\r
- }\r
-\r
- float chunk = (float)(height-offy*2)/(((SequenceNode)top).count+1);\r
-\r
- drawPostscriptNode(top,chunk,wscale,width,offx,offy);\r
-\r
- printout("showpage\n");\r
- } catch (java.io.IOException e) {\r
- System.out.println("Exception " + e);\r
- }\r
-}\r
-\r
-public void drawPostscriptNode(SequenceNode node, float chunk, float scale, int width, int offx, int offy) throws java.io.IOException {\r
- if (node == null) {\r
- return;\r
- }\r
-\r
- if (node.left() == null && node.right() == null) {\r
- // Drawing leaf node\r
-\r
- float height = node.height;\r
- float dist = node.dist;\r
-\r
- int xstart = (int)((height-dist)*scale) + offx;\r
- int xend = (int)(height*scale) + offx;\r
-\r
- int ypos = (int)(node.ycount * chunk) + offy;\r
-\r
- // g.setColor(Color.black);\r
- printout("\n" + new Format("%5.3f").form((double)node.color.getRed()/255) + " " +\r
- new Format("%5.3f").form((double)node.color.getGreen()/255) + " " +\r
- new Format("%5.3f").form((double)node.color.getBlue()/255) + " setrgbcolor\n");\r
-\r
- // Draw horizontal line\r
- // g.drawLine(xstart,ypos,xend,ypos);\r
- printout(xstart + " " + ypos + " moveto " + xend + " " + ypos + " lineto stroke \n");\r
-\r
- if (treeCanvas.showDistances && node.dist > 0) {\r
- // g.drawString(new Format("%5.2f").form(node.dist),xstart,ypos - 5);\r
- printout("(" + new Format("%5.2f").form(node.dist) + ") " + xstart + " " + (ypos+5) + " moveto show\n");\r
- }\r
- //g.drawString((String)node.element(),xend+20,ypos);\r
- printout("(" + (((SequenceI)node.element()).getName()) + ") " + (xend+20) + " " + (ypos) + " moveto show\n");\r
- } else {\r
- drawPostscriptNode((SequenceNode)node.left(),chunk,scale,width,offx,offy);\r
- drawPostscriptNode((SequenceNode)node.right(),chunk,scale,width,offx,offy);\r
-\r
-\r
- float height = node.height;\r
- float dist = node.dist;\r
-\r
- int xstart = (int)((height-dist)*scale) + offx;\r
- int xend = (int)(height*scale) + offx;\r
- int ypos = (int)(node.ycount * chunk) + offy;\r
-\r
- printout("\n" + new Format("%5.3f").form((double)node.color.getRed()/255) + " " +\r
- new Format("%5.3f").form((double)node.color.getGreen()/255) + " " +\r
- new Format("%5.3f").form((double)node.color.getBlue()/255) + " setrgbcolor\n");\r
- // g.setColor(Color.black);\r
- // bw.append("\nblack setrgbcolor\n");\r
- // Draw horizontal line\r
- // g.drawLine(xstart,ypos,xend,ypos);\r
- printout(xstart + " " + ypos + " moveto " + xend + " " + ypos + " lineto stroke\n");\r
- int ystart = (int)(((SequenceNode)node.left()).ycount * chunk) + offy;\r
- int yend = (int)(((SequenceNode)node.right()).ycount * chunk) + offy;\r
-\r
- // g.drawLine((int)(height*scale) + offx, ystart,\r
- // (int)(height*scale) + offx, yend);\r
- printout\r
- (((int)(height*scale) + offx) + " " + ystart + " moveto " + ((int)(height*scale) + offx) + " " +\r
- yend + " lineto stroke\n");\r
- if (treeCanvas.showDistances && node.dist > 0) {\r
- // g.drawString(new Format("%5.2f").form(node.dist),xstart,ypos - 5);\r
- printout("(" +new Format("%5.2f").form(node.dist) + ") " + (xstart) + " " + (ypos+5) + " moveto show\n");\r
- }\r
- }\r
-}\r
-\r
-public void printout(String s) throws IOException {\r
- if (bw != null) {\r
- bw.write(s);\r
- }\r
- if (ps != null) {\r
- ps.print(s);\r
- }\r
- if (makeString == true) {\r
- out.append(s);\r
- }\r
-}\r
-\r
-\r
-public PostscriptProperties getPostscriptProperties() {\r
- return pp;\r
-}\r
-\r
-public FileProperties getFileProperties() {\r
- return fp;\r
-}\r
-\r
-public void setPostscriptProperties(PostscriptProperties pp) {\r
- this.pp = pp;\r
-}\r
-\r
-public void setFileProperties(FileProperties fp) {\r
- this.fp = fp;\r
-}\r