X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FTreeCanvas.java;h=c38b1a5d5a1aa0564c401169e4f8a3a33c5646d2;hb=ad52f1ddcaefa09c6a3e85329b28dad155613f49;hp=5f707d59294389bb66febe7bc255eec94c45e130;hpb=3e6b14950a06bb87c147493e4dfff0c4491ea25b;p=jalview.git diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index 5f707d5..c38b1a5 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -55,7 +55,6 @@ public class TreeCanvas SequenceNode highlightNode; - public TreeCanvas(AlignViewport av, ScrollPane scroller) { this.av = av; @@ -77,7 +76,7 @@ public class TreeCanvas av.setSelectionGroup(selected); } - selected.setEndRes(av.alignment.getWidth()-1); + selected.setEndRes(av.alignment.getWidth() - 1); selected.addOrRemove(sequence, true); } @@ -168,7 +167,7 @@ public class TreeCanvas } if (!nodeLabel.equals("")) { - g.drawString(nodeLabel, xstart+2, ypos - 2); + g.drawString(nodeLabel, xstart + 2, ypos - 2); } String name = (markPlaceholders && node.isPlaceholder()) ? @@ -212,9 +211,13 @@ public class TreeCanvas // Draw horizontal line g.drawLine(xstart, ypos, xend, ypos); if (node == highlightNode) + { g.fillRect(xend - 3, ypos - 3, 6, 6); + } else + { g.fillRect(xend - 2, ypos - 2, 4, 4); + } int ystart = (int) ( ( (SequenceNode) node.left()).ycount * chunk) + offy; int yend = (int) ( ( (SequenceNode) node.right()).ycount * chunk) + offy; @@ -227,7 +230,7 @@ public class TreeCanvas if (showDistances && node.dist > 0) { - g.drawString(new Format("%-.2f").form(node.dist), xstart+2, ypos - 2); + g.drawString(new Format("%-.2f").form(node.dist), xstart + 2, ypos - 2); } } @@ -337,7 +340,7 @@ public class TreeCanvas if (node.element() instanceof SequenceI) { - av.setSequenceColour((SequenceI) node.element(), c); + av.setSequenceColour( (SequenceI) node.element(), c); } } else @@ -355,8 +358,10 @@ public class TreeCanvas public void paint(Graphics g) { - if(tree==null) + if (tree == null) + { return; + } if (nameHash.size() == 0) { @@ -365,20 +370,19 @@ public class TreeCanvas int width = scrollPane.getSize().width; int height = scrollPane.getSize().height; - if(!fitToWindow) + if (!fitToWindow) { height = g.getFontMetrics(font).getHeight() * nameHash.size(); } - if(getSize().width>width) + if (getSize().width > width) { - setSize(new Dimension(width,height)); + setSize(new Dimension(width, height)); scrollPane.validate(); return; } - setSize(new Dimension(width,height)); - + setSize(new Dimension(width, height)); g.setFont(font); @@ -386,10 +390,9 @@ public class TreeCanvas } - public void draw(Graphics g, int width, int height) { - offy = font.getSize()+10; + offy = font.getSize() + 10; g.setColor(Color.white); g.fillRect(0, 0, width, height); @@ -468,7 +471,6 @@ public class TreeCanvas public void mouseDragged(MouseEvent ect) {} - public void mouseMoved(MouseEvent evt) { av.setCurrentTree(tree); @@ -506,7 +508,7 @@ public class TreeCanvas repaint(); return; } - else if ( !(ob instanceof SequenceNode)) + else if (! (ob instanceof SequenceNode)) { // Find threshold @@ -521,7 +523,7 @@ public class TreeCanvas av.setSelectionGroup(null); av.alignment.deleteAllGroups(); - av.sequenceColours=null; + av.sequenceColours = null; colourGroups(); @@ -536,71 +538,76 @@ public class TreeCanvas void colourGroups() { for (int i = 0; i < tree.getGroups().size(); i++) - { + { - Color col = new Color( (int) (Math.random() * 255), - (int) (Math.random() * 255), - (int) (Math.random() * 255)); - setColor( (SequenceNode) tree.getGroups().elementAt(i), col.brighter()); + Color col = new Color( (int) (Math.random() * 255), + (int) (Math.random() * 255), + (int) (Math.random() * 255)); + setColor( (SequenceNode) tree.getGroups().elementAt(i), col.brighter()); - Vector l = tree.findLeaves( (SequenceNode) tree.getGroups().elementAt( - i), new Vector()); + Vector l = tree.findLeaves( (SequenceNode) tree.getGroups().elementAt( + i), new Vector()); - Vector sequences = new Vector(); - for (int j = 0; j < l.size(); j++) - { - SequenceI s1 = (SequenceI) ( (SequenceNode) l.elementAt(j)).element(); - if(!sequences.contains(s1)) - sequences.addElement(s1); - } + Vector sequences = new Vector(); + for (int j = 0; j < l.size(); j++) + { + SequenceI s1 = (SequenceI) ( (SequenceNode) l.elementAt(j)).element(); + if (!sequences.contains(s1)) + { + sequences.addElement(s1); + } + } - ColourSchemeI cs = null; + ColourSchemeI cs = null; - if (av.getGlobalColourScheme() != null) - { - if (av.getGlobalColourScheme() instanceof UserColourScheme) - { - cs = new UserColourScheme( - ( (UserColourScheme) av.getGlobalColourScheme()).getColours()); - - } - else - cs = ColourSchemeProperty.getColour(sequences, - av.alignment.getWidth(), - ColourSchemeProperty.getColourName( - av.getGlobalColourScheme())); - - cs.setThreshold(av.getGlobalColourScheme().getThreshold(), - av.getIgnoreGapsConsensus()); - } + if (av.getGlobalColourScheme() != null) + { + if (av.getGlobalColourScheme() instanceof UserColourScheme) + { + cs = new UserColourScheme( + ( (UserColourScheme) av.getGlobalColourScheme()).getColours()); + + } + else + { + cs = ColourSchemeProperty.getColour(sequences, + av.alignment.getWidth(), + ColourSchemeProperty. + getColourName( + av.getGlobalColourScheme())); + } - SequenceGroup sg = new SequenceGroup(sequences, "", - cs, true, true, - false, 0, av.alignment.getWidth()-1); + cs.setThreshold(av.getGlobalColourScheme().getThreshold(), + av.getIgnoreGapsConsensus()); + } - sg.setName("JTreeGroup:"+sg.hashCode()); + SequenceGroup sg = new SequenceGroup(sequences, "", + cs, true, true, + false, 0, + av.alignment.getWidth() - 1); + sg.setName("JTreeGroup:" + sg.hashCode()); - if ( av.getGlobalColourScheme()!=null - && av.getGlobalColourScheme().conservationApplied()) - { - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.getSequences(null), - sg.getStartRes(), - sg.getEndRes()); + if (av.getGlobalColourScheme() != null + && av.getGlobalColourScheme().conservationApplied()) + { + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, + sg.getSequences(null), + sg.getStartRes(), + sg.getEndRes()); - c.calculate(); - c.verdict(false, av.ConsPercGaps); - cs.setConservation(c); + c.calculate(); + c.verdict(false, av.ConsPercGaps); + cs.setConservation(c); - sg.cs = cs; + sg.cs = cs; - } + } - av.alignment.addGroup(sg); + av.alignment.addGroup(sg); - } + } }