X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FTreeCanvas.java;h=af1d752897a78d10b230306775b536db3ce67e06;hb=04011072920c5e2587a8d549869ee47e28ad7d81;hp=47bebbea18725d2e5cc5dbd88284e6ddc988600b;hpb=8a5c39442bced20fc95272efe6d3176719ca3f15;p=jalview.git diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index 47bebbe..af1d752 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -37,15 +37,13 @@ public class TreeCanvas AlignViewport av; public static final String PLACEHOLDER = " * "; Font font; - int fontSize = 12; - boolean fitToWindow = true; boolean showDistances = false; boolean showBootstrap = false; boolean markPlaceholders = false; int offx = 20; - int offy = 20; + int offy; float threshold; @@ -62,6 +60,7 @@ public class TreeCanvas public TreeCanvas(AlignViewport av, ScrollPane scroller) { this.av = av; + font = av.getFont(); scrollPane = scroller; addMouseListener(this); setLayout(null); @@ -160,7 +159,7 @@ public class TreeCanvas String nodeLabel = ""; if (showDistances && node.dist > 0) { - nodeLabel = new Format("%5.2f").form(node.dist); + nodeLabel = new Format("%-.2f").form(node.dist); } if (showBootstrap) { @@ -172,7 +171,7 @@ public class TreeCanvas } if (!nodeLabel.equals("")) { - g.drawString(nodeLabel, xstart, ypos - 10); + g.drawString(nodeLabel, xstart+2, ypos - 2); } String name = (markPlaceholders && node.isPlaceholder()) ? @@ -181,7 +180,7 @@ public class TreeCanvas int charWidth = fm.stringWidth(name) + 3; int charHeight = fm.getHeight(); - Rectangle rect = new Rectangle(xend + 20, ypos - charHeight, + Rectangle rect = new Rectangle(xend + 10, ypos - charHeight, charWidth, charHeight); nameHash.put( (SequenceI) node.element(), rect); @@ -189,7 +188,7 @@ public class TreeCanvas // Colour selected leaves differently SequenceGroup selected = av.getSelectionGroup(); if (selected != null && - selected.sequences.contains( (SequenceI) node.element())) + selected.getSequences(false).contains( (SequenceI) node.element())) { g.setColor(Color.gray); @@ -228,7 +227,7 @@ public class TreeCanvas if (showDistances && node.dist > 0) { - g.drawString(new Format("%5.2f").form(node.dist), xstart, ypos - 5); + g.drawString(new Format("%-.2f").form(node.dist), xstart+2, ypos - 2); } } @@ -280,7 +279,7 @@ public class TreeCanvas top.count = ( (SequenceNode) top.left()).count + ( (SequenceNode) top.right()).count; } - float chunk = (float) (height - offy * 2) / top.count; + float chunk = (float) (height - offy) / top.count; pickNode(pickBox, top, chunk, wscale, width, offx, offy); } @@ -296,9 +295,9 @@ public class TreeCanvas if (node.left() == null && node.right() == null) { float height = node.height; - float dist = node.dist; + //float dist = node.dist; - int xstart = (int) ( (height - dist) * scale) + offx; + //int xstart = (int) ( (height - dist) * scale) + offx; int xend = (int) (height * scale) + offx; int ypos = (int) (node.ycount * chunk) + offy; @@ -352,9 +351,12 @@ public class TreeCanvas public void paint(Graphics g) { - font = new Font("Verdana", Font.PLAIN, fontSize); + if(tree==null) + return; + g.setFont(font); + FontMetrics fm = g.getFontMetrics(font); if (nameHash.size() == 0) @@ -378,19 +380,10 @@ public class TreeCanvas scrollPane.validate(); } - public int getFontSize() - { - return fontSize; - } - - public void setFontSize(int fontSize) - { - this.fontSize = fontSize; - repaint(); - } public void draw(Graphics g, int width, int height) { + offy = font.getSize()+10; g.setColor(Color.white); g.fillRect(0, 0, width, height); @@ -406,7 +399,7 @@ public class TreeCanvas top.count = ( (SequenceNode) top.left()).count + ( (SequenceNode) top.right()).count; } - float chunk = (float) (height - offy * 2) / top.count; + float chunk = (float) (height - offy) / top.count; drawNode(g, tree.getTopNode(), chunk, wscale, width, offx, offy); @@ -530,7 +523,8 @@ public class TreeCanvas { Conservation c = new Conservation("Group", ResidueProperties.propHash, 3, - sg.sequences, sg.getStartRes(), + sg.getSequences(false), + sg.getStartRes(), sg.getEndRes()); c.calculate();