JAL-1551 spotlessApply
[jalview.git] / src / jalview / gui / TreePanel.java
index d735402..0e1fd42 100755 (executable)
  */
 package jalview.gui;
 
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Locale;
 
+import javax.swing.ButtonGroup;
+import javax.swing.JMenuItem;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
+
+import org.jibble.epsgraphics.EpsGraphics2D;
+
 import jalview.analysis.AlignmentSorter;
 import jalview.analysis.AverageDistanceTree;
 import jalview.analysis.NJTree;
@@ -35,6 +53,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;
@@ -53,25 +72,6 @@ import jalview.util.ImageMaker.TYPE;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.ButtonGroup;
-import javax.swing.JMenuItem;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.event.InternalFrameAdapter;
-import javax.swing.event.InternalFrameEvent;
-
-import org.jibble.epsgraphics.EpsGraphics2D;
-
 /**
  * DOCUMENT ME!
  * 
@@ -106,6 +106,7 @@ public class TreePanel extends GTreePanel
           SimilarityParamsI options)
   {
     super();
+    this.setFrameIcon(null);
     this.similarityParams = options;
     initTreePanel(ap, type, modelName, null, null);
 
@@ -118,10 +119,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();
@@ -141,6 +176,15 @@ public class TreePanel extends GTreePanel
     this.treeType = type;
     this.scoreModelName = modelName;
 
+    if (columnWise)
+    {
+      bootstrapMenu.setVisible(false);
+      placeholdersMenu.setSelected(false);
+      placeholdersMenu.setVisible(false);
+      fitToWindow.setSelected(false);
+      sortAssocViews.setVisible(false);
+    }
+
     treeCanvas = new TreeCanvas(this, ap, scrollPane);
     scrollPane.setViewportView(treeCanvas);
 
@@ -720,7 +764,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 +806,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);
           }
         }
       }