X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FTreePanel.java;h=0a0c1b80dac1005d7ddff4e223cf23a9154569d2;hb=8dca84768d848bc368985a8f0938a6c7ac059952;hp=fd85779fd54b75d805e69130cdae9ca7e24ea352;hpb=c1f5dd54ab8caa7e76ca50f9c3a85f2731b66862;p=jalview.git diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index fd85779..0a0c1b8 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -24,6 +24,8 @@ import java.awt.Font; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; @@ -53,6 +55,7 @@ import jalview.bin.Console; import jalview.commands.CommandI; import jalview.commands.OrderCommand; import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.BinaryNode; @@ -66,6 +69,7 @@ import jalview.gui.ImageExporter.ImageWriterI; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; import jalview.io.NewickFile; +import jalview.io.exceptions.ImageOutputException; import jalview.jbgui.GTreePanel; import jalview.util.ImageMaker.TYPE; import jalview.util.MessageManager; @@ -118,10 +122,44 @@ public class TreePanel extends GTreePanel String theTitle, AlignmentView inputData) { super(); + this.setFrameIcon(null); this.treeTitle = theTitle; initTreePanel(alignPanel, null, null, newtree, inputData); } + /** + * columnwise tree associated with positions in aa + * + * @param alignPanel + * @param fin + * @param title + * @param aa + */ + public TreePanel(AlignmentPanel alignPanel, NewickFile fin, + AlignmentAnnotation aa, String title) + { + super(); + columnWise = true; + assocAnnotation = aa; + this.setFrameIcon(null); + this.treeTitle = title; + initTreePanel(alignPanel, null, null, fin, null); + } + + boolean columnWise = false; + + AlignmentAnnotation assocAnnotation = null; + + public boolean isColumnWise() + { + return columnWise; + } + + public AlignmentAnnotation getAssocAnnotation() + { + return assocAnnotation; + } + public AlignmentI getAlignment() { return getTreeCanvas().getViewport().getAlignment(); @@ -143,7 +181,33 @@ public class TreePanel extends GTreePanel treeCanvas = new TreeCanvas(this, ap, scrollPane); scrollPane.setViewportView(treeCanvas); + + if (columnWise) + { + bootstrapMenu.setVisible(false); + placeholdersMenu.setState(false); + placeholdersMenu.setVisible(false); + fitToWindow.setState(false); + sortAssocViews.setVisible(false); + } + + addKeyListener(new KeyAdapter() + { + @Override + public void keyPressed(KeyEvent e) + { + switch (e.getKeyCode()) + { + case 27: // escape + treeCanvas.clearSelectedLeaves(); + e.consume(); + break; + + } + + } + }); PaintRefresher.Register(this, ap.av.getSequenceSetId()); buildAssociatedViewMenu(); @@ -197,7 +261,7 @@ public class TreePanel extends GTreePanel { if (tree == null) { - System.out.println("tree is null"); + jalview.bin.Console.outPrintln("tree is null"); // TODO: deal with case when a change event is received whilst a // tree is still being calculated - should save reference for // processing message later. @@ -205,7 +269,7 @@ public class TreePanel extends GTreePanel } if (evt.getNewValue() == null) { - System.out.println( + jalview.bin.Console.outPrintln( "new alignment sequences vector value is null"); } @@ -328,9 +392,9 @@ public class TreePanel extends GTreePanel ? new NJTree(av, sm, similarityParams) : new AverageDistanceTree(av, sm, similarityParams); tree = new TreeModel(njtree); - showDistances(true); + // don't display distances for columnwise trees } - + showDistances(!columnWise); tree.reCount(tree.getTopNode()); tree.findHeight(tree.getTopNode()); treeCanvas.setTree(tree); @@ -695,8 +759,12 @@ public class TreePanel extends GTreePanel String tree = MessageManager.getString("label.tree"); ImageExporter exporter = new ImageExporter(writer, null, imageFormat, tree); + try { exporter.doExport(null, this, width, height, tree.toLowerCase(Locale.ROOT)); + } catch (ImageOutputException ioex) { + Console.error("Unexpected error whilst writing "+imageFormat.toString(),ioex); + } } /** @@ -720,7 +788,7 @@ public class TreePanel extends GTreePanel && !((SequenceNode) node).isDummy()) { String newname = null; - SequenceI sq = (SequenceI) ((SequenceNode) node).element(); + SequenceI sq = (SequenceI) ((BinaryNode) node).element(); if (sq != null) { // search dbrefs, features and annotation @@ -762,7 +830,7 @@ public class TreePanel extends GTreePanel { // String oldname = ((SequenceNode) node).getName(); // TODO : save oldname in the undo object for this modification. - ((SequenceNode) node).setName(newname); + ((BinaryNode) node).setName(newname); } } } @@ -828,7 +896,7 @@ public class TreePanel extends GTreePanel pg.close(); } catch (Exception ex) { - System.err.println("Error writing tree as EPS"); + jalview.bin.Console.errPrintln("Error writing tree as EPS"); ex.printStackTrace(); } }