NJTree tree;\r
JScrollPane scrollPane;\r
AlignViewport av;\r
-\r
+ public static final String PLACEHOLDER=" * ";\r
Font font;\r
int fontSize = 12;\r
\r
boolean fitToWindow = true;\r
boolean showDistances = false;\r
boolean showBootstrap = false;\r
+ boolean markPlaceholders = false;\r
\r
int offx = 20;\r
int offy = 20;\r
\r
- int threshold;\r
+ float threshold;\r
\r
String longestName;\r
int labelLength=-1;\r
g.drawString(nodeLabel,xstart,ypos - 10);\r
}\r
\r
- // Colour selected leaves differently\r
- String name = node.getName();\r
+ String name = (markPlaceholders && node.isPlaceholder()) ? (PLACEHOLDER+node.getName()) : node.getName();\r
FontMetrics fm = g.getFontMetrics(font);\r
- int charWidth = fm.stringWidth(node.getName()) + 3;\r
+ int charWidth = fm.stringWidth(name) + 3;\r
int charHeight = fm.getHeight();\r
\r
Rectangle rect = new Rectangle(xend+20,ypos-charHeight,\r
\r
nameHash.put((SequenceI)node.element(),rect);\r
\r
+ // Colour selected leaves differently\r
SequenceGroup selected = av.getSelectionGroup();\r
if (selected!=null && selected.sequences.contains((SequenceI)node.element())) {\r
g.setColor(Color.gray);\r
g.fillRect(xend + 10, ypos - charHeight + 3,charWidth,charHeight);\r
g.setColor(Color.white);\r
}\r
- g.drawString(node.getName(),xend+10,ypos);\r
+ g.drawString(name,xend+10,ypos);\r
g.setColor(Color.black);\r
} else {\r
drawNode(g,(SequenceNode)node.left(), chunk,scale,width,offx,offy);\r
{\r
PrinterJob printJob = PrinterJob.getPrinterJob();\r
PageFormat pf = printJob.pageDialog(printJob.defaultPage());\r
+\r
printJob.setPrintable(this, pf);\r
if (printJob.printDialog())\r
{\r
\r
public int print(Graphics pg, PageFormat pf, int pi) throws PrinterException\r
{\r
- pg.setFont(font);\r
- FontMetrics fm = pg.getFontMetrics(font);\r
\r
+ pg.setFont(font);\r
pg.translate((int)pf.getImageableX(), (int)pf.getImageableY());\r
-\r
int pwidth = (int) pf.getImageableWidth();\r
int pheight = (int) pf.getImageableHeight();\r
\r
- // adjust pheight to row height\r
- pheight -= (pheight%fm.getHeight());\r
- pg.setClip(0,0, pwidth, pheight);\r
-\r
- int noPages = (fm.getHeight() * nameHash.size()) / pheight;\r
-\r
+ int noPages = getHeight() / pheight;\r
if(pi>noPages)\r
return Printable.NO_SUCH_PAGE;\r
\r
- pg.translate(0, -pheight*pi );\r
- draw(pg, pwidth, fm.getHeight() * nameHash.size());\r
+\r
+ if (pwidth > getWidth())\r
+ pwidth = getWidth();\r
+\r
+ if(fitToWindow)\r
+ {\r
+ if (pheight > getHeight())\r
+ pheight = getHeight();\r
+\r
+ noPages = 0;\r
+ }\r
+ else\r
+ {\r
+\r
+ FontMetrics fm = pg.getFontMetrics(font);\r
+ int height = fm.getHeight() * nameHash.size();\r
+ pg.translate(0, -pi*pheight );\r
+ pg.setClip(0,pi*pheight, pwidth,pi*pheight + pheight);\r
+ // translate number of pages,\r
+ // height is screen size as this is the\r
+ // non overlapping text size\r
+ pheight = height;\r
+ }\r
+\r
+ draw(pg, pwidth, pheight);\r
\r
return Printable.PAGE_EXISTS;\r
\r
draw( g,scrollPane.getWidth(), fm.getHeight() * nameHash.size());\r
}\r
\r
-\r
- if (threshold != 0)\r
- {\r
- g.setColor(Color.red);\r
- g.drawLine(threshold,0,threshold,getHeight());\r
- }\r
-\r
scrollPane.revalidate();\r
}\r
public int getFontSize() {\r
this.fontSize = fontSize;\r
repaint();\r
}\r
- public void draw(Graphics g, int width, int height) {\r
- g.setColor(Color.white);\r
- g.fillRect(0,0,width,height);\r
+ public void draw(Graphics g1, int width, int height) {\r
+\r
+ Graphics2D g2 = (Graphics2D)g1;\r
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\r
+ g2.setColor(Color.white);\r
+ g2.fillRect(0,0,width,height);\r
\r
\r
- labelLength = g.getFontMetrics(font).stringWidth(longestName)+ 20;//20 allows for scrollbar\r
+ labelLength = g2.getFontMetrics(font).stringWidth(longestName)+ 20;//20 allows for scrollbar\r
\r
float wscale =(float)(width - labelLength -offx*2)/tree.getMaxHeight();\r
\r
}\r
float chunk = (float)(height-offy*2)/top.count ;\r
\r
- drawNode(g,tree.getTopNode(),chunk,wscale,width,offx,offy);\r
+ drawNode(g2,tree.getTopNode(),chunk,wscale,width,offx,offy);\r
+\r
+ if (threshold != 0)\r
+ {\r
+ if(av.getCurrentTree() == tree)\r
+ g2.setColor(Color.red);\r
+ else\r
+ g2.setColor(Color.gray);\r
+\r
+ int x = (int)( threshold * (float)(getWidth()-labelLength - 2*offx) +offx ) ;\r
+\r
+ g2.drawLine(x,0,x,getHeight());\r
+ }\r
+\r
}\r
\r
public void mouseReleased(MouseEvent e) { }\r
}\r
\r
public void mousePressed(MouseEvent e) {\r
+\r
+ av.setCurrentTree(tree);\r
+\r
int x = e.getX();\r
int y = e.getY();\r
\r
// Find threshold\r
\r
if (tree.getMaxHeight() != 0) {\r
- float fthreshold = (float)(x - offx)/(float)(getWidth()-labelLength - 2*offx);\r
- this.threshold = x;\r
+ threshold = (float)(x - offx)/(float)(getWidth()-labelLength - 2*offx);\r
+\r
tree.getGroups().removeAllElements();\r
- tree.groupNodes(tree.getTopNode(),fthreshold);\r
+ tree.groupNodes(tree.getTopNode(),threshold);\r
setColor(tree.getTopNode(),Color.black);\r
\r
av.setSelectionGroup(null);\r
sg.getEndRes());\r
\r
c.calculate();\r
- c.verdict(false, 100);\r
+ c.verdict(false, av.ConsPercGaps);\r
ccs = new ConservationColourScheme(c, ccs.cs);\r
\r
sg.cs = ccs;\r
this.showBootstrap = state;\r
repaint();\r
}\r
+ public void setMarkPlaceholders(boolean state) {\r
+ this.markPlaceholders = state;\r
+ repaint();\r
+ }\r
\r
}\r
\r