AlignViewport av;\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
+ int offy;\r
\r
float threshold;\r
\r
Hashtable nameHash = new Hashtable();\r
Hashtable nodeHash = new Hashtable();\r
\r
- public TreeCanvas(AlignViewport av, NJTree tree, ScrollPane scroller,\r
- String label)\r
+ public TreeCanvas(AlignViewport av, ScrollPane scroller)\r
{\r
this.av = av;\r
- this.tree = tree;\r
+ font = av.getFont();\r
scrollPane = scroller;\r
addMouseListener(this);\r
- tree.findHeight(tree.getTopNode());\r
- longestName = label;\r
setLayout(null);\r
\r
PaintRefresher.Register(this, av.alignment);\r
av.setSelectionGroup(selected);\r
}\r
\r
- selected.setEndRes(av.alignment.getWidth());\r
+ selected.setEndRes(av.alignment.getWidth()-1);\r
selected.addOrRemove(sequence, true);\r
\r
-System.out.println("called here");\r
PaintRefresher.Refresh(this, av.alignment);\r
repaint();\r
}\r
{\r
this.tree = tree;\r
tree.findHeight(tree.getTopNode());\r
+\r
+ // Now have to calculate longest name based on the leaves\r
+ Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector());\r
+ boolean has_placeholders = false;\r
+ longestName = "";\r
+\r
+ for (int i = 0; i < leaves.size(); i++)\r
+ {\r
+ SequenceNode lf = (SequenceNode) leaves.elementAt(i);\r
+\r
+ if (lf.isPlaceholder())\r
+ {\r
+ has_placeholders = true;\r
+ }\r
+\r
+ if (longestName.length() < ( (Sequence) lf.element()).getName()\r
+ .length())\r
+ {\r
+ longestName = TreeCanvas.PLACEHOLDER +\r
+ ( (Sequence) lf.element()).getName();\r
+ }\r
+ }\r
+\r
+ setMarkPlaceholders(has_placeholders);\r
}\r
\r
public void drawNode(Graphics g, SequenceNode node, float chunk, float scale,\r
String nodeLabel = "";\r
if (showDistances && node.dist > 0)\r
{\r
- nodeLabel = new Format("%5.2f").form(node.dist);\r
+ nodeLabel = new Format("%-.2f").form(node.dist);\r
}\r
if (showBootstrap)\r
{\r
}\r
if (!nodeLabel.equals(""))\r
{\r
- g.drawString(nodeLabel, xstart, ypos - 10);\r
+ g.drawString(nodeLabel, xstart+2, ypos - 2);\r
}\r
\r
String name = (markPlaceholders && node.isPlaceholder()) ?\r
int charWidth = fm.stringWidth(name) + 3;\r
int charHeight = fm.getHeight();\r
\r
- Rectangle rect = new Rectangle(xend + 20, ypos - charHeight,\r
+ Rectangle rect = new Rectangle(xend + 10, ypos - charHeight,\r
charWidth, charHeight);\r
\r
nameHash.put( (SequenceI) node.element(), rect);\r
\r
if (showDistances && node.dist > 0)\r
{\r
- g.drawString(new Format("%5.2f").form(node.dist), xstart, ypos - 5);\r
+ g.drawString(new Format("%-.2f").form(node.dist), xstart+2, ypos - 2);\r
}\r
\r
}\r
top.count = ( (SequenceNode) top.left()).count +\r
( (SequenceNode) top.right()).count;\r
}\r
- float chunk = (float) (height - offy * 2) / top.count;\r
+ float chunk = (float) (height - offy) / top.count;\r
\r
pickNode(pickBox, top, chunk, wscale, width, offx, offy);\r
}\r
if (node.left() == null && node.right() == null)\r
{\r
float height = node.height;\r
- float dist = node.dist;\r
+ //float dist = node.dist;\r
\r
- int xstart = (int) ( (height - dist) * scale) + offx;\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
public void paint(Graphics g)\r
{\r
\r
- font = new Font("Verdana", Font.PLAIN, fontSize);\r
+ if(tree==null)\r
+ return;\r
+\r
g.setFont(font);\r
\r
+\r
FontMetrics fm = g.getFontMetrics(font);\r
\r
if (nameHash.size() == 0)\r
scrollPane.validate();\r
}\r
\r
- public int getFontSize()\r
- {\r
- return fontSize;\r
- }\r
-\r
- public void setFontSize(int fontSize)\r
- {\r
- this.fontSize = fontSize;\r
- repaint();\r
- }\r
\r
public void draw(Graphics g, int width, int height)\r
{\r
+ offy = font.getSize()+10;\r
\r
g.setColor(Color.white);\r
g.fillRect(0, 0, width, height);\r
top.count = ( (SequenceNode) top.left()).count +\r
( (SequenceNode) top.right()).count;\r
}\r
- float chunk = (float) (height - offy * 2) / top.count;\r
+ float chunk = (float) (height - offy) / top.count;\r
\r
drawNode(g, tree.getTopNode(), chunk, wscale, width, offx, offy);\r
\r
sequences.addElement(s1);\r
}\r
\r
- ColourSchemeI cs = ColourSchemeProperty.getColour(sequences, av.alignment.getWidth(),\r
- ColourSchemeProperty.getColourName(av.getGlobalColourScheme()));\r
+ ColourSchemeI cs = null;\r
\r
+ if (av.getGlobalColourScheme() != null)\r
+ {\r
+ if (av.getGlobalColourScheme() instanceof UserColourScheme)\r
+ {\r
+ cs = new UserColourScheme(\r
+ ( (UserColourScheme) av.getGlobalColourScheme()).getColours());\r
+\r
+ }\r
+ else\r
+ cs = ColourSchemeProperty.getColour(sequences,\r
+ av.alignment.getWidth(),\r
+ ColourSchemeProperty.getColourName(\r
+ av.getGlobalColourScheme()));\r
+\r
+ cs.setThreshold(av.getGlobalColourScheme().getThreshold(),\r
+ av.getIgnoreGapsConsensus());\r
+ }\r
\r
SequenceGroup sg = new SequenceGroup(sequences, "TreeGroup",\r
cs, true, true,\r
- false, 0, av.alignment.getWidth());\r
+ false, 0, av.alignment.getWidth()-1);\r
\r
\r
- if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
- {\r
- ConservationColourScheme ccs = (ConservationColourScheme) av.\r
- getGlobalColourScheme();\r
+ if ( av.getGlobalColourScheme()!=null\r
+ && av.getGlobalColourScheme().conservationApplied())\r
+ {\r
Conservation c = new Conservation("Group",\r
ResidueProperties.propHash, 3,\r
sg.sequences, sg.getStartRes(),\r
\r
c.calculate();\r
c.verdict(false, av.ConsPercGaps);\r
- ccs = new ConservationColourScheme(c, ccs.cs);\r
+ cs.setConservation(c);\r
\r
- sg.cs = ccs;\r
+ sg.cs = cs;\r
\r
}\r
\r