X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FTreeCanvas.java;h=f7faa6cb5f4ffd64820fe616db5f0d4580899738;hb=470f1621c5e4fa625243067974aa92db3282443c;hp=e60ac8eb479c4e9ded5d32228f641ca819eee9c6;hpb=136c0793b90b72b928c4d77dc109dd5c644e00d3;p=jalview.git diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index e60ac8e..f7faa6c 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -27,6 +27,7 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.datamodel.SequenceNode; +import jalview.gui.JalviewColourChooser.ColourChooserListener; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.schemes.UserColourScheme; @@ -279,8 +280,9 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, g.drawString(nodeLabel, xstart + 2, ypos - 2); } - String name = (markPlaceholders && node.isPlaceholder()) ? (PLACEHOLDER + node - .getName()) : node.getName(); + String name = (markPlaceholders && node.isPlaceholder()) + ? (PLACEHOLDER + node.getName()) + : node.getName(); int charWidth = fm.stringWidth(name) + 3; int charHeight = font.getSize(); @@ -332,10 +334,10 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, g.fillRect(xend - 2, ypos - 2, 4, 4); } - int ystart = (node.left() == null ? 0 : (int) (((SequenceNode) node - .left()).ycount * chunk)) + offy; - int yend = (node.right() == null ? 0 : (int) (((SequenceNode) node - .right()).ycount * chunk)) + int ystart = (node.left() == null ? 0 + : (int) (((SequenceNode) node.left()).ycount * chunk)) + offy; + int yend = (node.right() == null ? 0 + : (int) (((SequenceNode) node.right()).ycount * chunk)) + offy; Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5); @@ -424,8 +426,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, SequenceNode top = tree.getTopNode(); - double wscale = ((width * .8) - (offx * 2)) - / tree.getMaxHeight(); + double wscale = ((width * .8) - (offx * 2)) / tree.getMaxHeight(); if (top.count == 0) { @@ -654,8 +655,9 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, if (tree == null) { - g.drawString(MessageManager.getString("label.calculating_tree") - + "....", 20, getHeight() / 2); + g.drawString( + MessageManager.getString("label.calculating_tree") + "....", + 20, getHeight() / 2); } else { @@ -666,9 +668,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, repaint(); } - if (fitToWindow - || (!fitToWindow && (scrollPane.getHeight() > ((fm - .getHeight() * nameHash.size()) + offy)))) + if (fitToWindow || (!fitToWindow && (scrollPane + .getHeight() > ((fm.getHeight() * nameHash.size()) + offy)))) { draw(g, scrollPane.getWidth(), scrollPane.getHeight()); setPreferredSize(null); @@ -752,7 +753,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, g2.setColor(Color.gray); } - int x = (int) ((threshold * (getWidth() - labelLength - (2 * offx))) + offx); + int x = (int) ((threshold * (getWidth() - labelLength - (2 * offx))) + + offx); g2.drawLine(x, 0, x, getHeight()); } @@ -840,15 +842,17 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, */ void chooseSubtreeColour() { - Color col = JColorChooser.showDialog(this, - MessageManager.getString("label.select_subtree_colour"), - highlightNode.color); - if (col != null) - { - setColor(highlightNode, col); - PaintRefresher.Refresh(tp, ap.av.getSequenceSetId()); - repaint(); - } + String ttl = MessageManager.getString("label.select_subtree_colour"); + ColourChooserListener listener = new ColourChooserListener() { + @Override + public void colourSelected(Color c) + { + setColor(highlightNode, c); + PaintRefresher.Refresh(tp, ap.av.getSequenceSetId()); + repaint(); + } + }; + JalviewColourChooser.showColourChooser(this, ttl, highlightNode.color, listener); } @Override @@ -861,8 +865,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, if (ob instanceof SequenceNode) { highlightNode = (SequenceNode) ob; - this.setToolTipText("" - + MessageManager.getString("label.highlightnode")); + this.setToolTipText( + "" + MessageManager.getString("label.highlightnode")); repaint(); } @@ -961,6 +965,15 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } } colourGroups(groups); + + /* + * clear partition (don't show vertical line) if + * it is to the right of all nodes + */ + if (groups.isEmpty()) + { + threshold = 0f; + } } PaintRefresher.Refresh(tp, ap.av.getSequenceSetId()); @@ -980,7 +993,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Vector l = tree.findLeaves(groups.get(i)); - Vector sequences = new Vector(); + Vector sequences = new Vector<>(); for (int j = 0; j < l.size(); j++) { @@ -1007,9 +1020,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } else { - cs = ColourSchemeProperty.getColourScheme(sg, - ColourSchemeProperty.getColourName(av - .getGlobalColourScheme())); + cs = ColourSchemeProperty.getColourScheme(sg, ColourSchemeProperty + .getColourName(av.getGlobalColourScheme())); } // cs is null if shading is an annotationColourGradient // if (cs != null) @@ -1029,8 +1041,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, for (int a = 0; a < aps.length; a++) { if (aps[a].av.getGlobalColourScheme() != null - && aps[a].av.getResidueShading() - .conservationApplied()) + && aps[a].av.getResidueShading().conservationApplied()) { Conservation c = new Conservation("Group", sg.getSequences(null), sg.getStartRes(), sg.getEndRes());