Tree fits to window by default
authoramwaterhouse <Andrew Waterhouse>
Tue, 8 Mar 2005 16:36:48 +0000 (16:36 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 8 Mar 2005 16:36:48 +0000 (16:36 +0000)
src/jalview/gui/TreeCanvas.java
src/jalview/gui/TreePanel.java
src/jalview/jbgui/GTreePanel.java

index fd9619e..de84902 100755 (executable)
@@ -20,6 +20,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
   Font font;\r
   int  fontSize = 12;\r
 \r
+  boolean fitToWindow = true;\r
   boolean showDistances = false;\r
   boolean showBootstrap = false;\r
 \r
@@ -331,15 +332,15 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print
       repaint();\r
 \r
 \r
-    if( scrollPane.getHeight() > fm.getHeight() * nameHash.size()+offy)\r
+    if( fitToWindow || (!fitToWindow && scrollPane.getHeight() > fm.getHeight() * nameHash.size()+offy ) )\r
      {\r
          draw(g,scrollPane.getWidth(),scrollPane.getHeight());\r
-         setPreferredSize(new Dimension(scrollPane.getWidth(), scrollPane.getHeight()));\r
+         setPreferredSize(null);\r
      }\r
     else\r
      {\r
-         setPreferredSize(new Dimension(getWidth(), fm.getHeight() * nameHash.size()));\r
-         draw( g,getWidth(), fm.getHeight() * nameHash.size());\r
+         setPreferredSize(new Dimension(scrollPane.getWidth(), fm.getHeight() * nameHash.size()));\r
+         draw( g,scrollPane.getWidth(), fm.getHeight() * nameHash.size());\r
      }\r
 \r
 \r
index 4b605bf..f723fdc 100755 (executable)
@@ -266,6 +266,13 @@ public void propertiesInit() {
     treeCanvas.startPrinting();\r
   }\r
 \r
+  protected void fitToWindow_actionPerformed(ActionEvent e)\r
+  {\r
+    treeCanvas.fitToWindow = fitToWindow.isSelected();\r
+    repaint();\r
+  }\r
+\r
+\r
   protected void fontSize_actionPerformed(ActionEvent e)\r
   {\r
     if( treeCanvas==null )\r
index 4b18fd3..e67518b 100755 (executable)
@@ -16,6 +16,7 @@ public class GTreePanel extends JInternalFrame
   protected JMenuItem fontSize = new JMenuItem();
   protected JCheckBoxMenuItem bootstrapMenu = new JCheckBoxMenuItem();
   protected JCheckBoxMenuItem distanceMenu = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem fitToWindow = new JCheckBoxMenuItem();
 
   public GTreePanel()
   {
@@ -35,7 +36,6 @@ public class GTreePanel extends JInternalFrame
     this.getContentPane().setLayout(borderLayout1);
     this.setBackground(Color.white);
     this.setFont(new java.awt.Font("Verdana", 0, 12));
-    this.setMinimumSize(new Dimension(530, 60));
     scrollPane.setOpaque(false);
     jMenu1.setText("File");
     saveMenu.setEnabled(false);
@@ -80,11 +80,21 @@ public class GTreePanel extends JInternalFrame
         distanceMenu_actionPerformed(e);
       }
     });
+    fitToWindow.setSelected(true);
+    fitToWindow.setText("Fit to window");
+    fitToWindow.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        fitToWindow_actionPerformed(e);
+      }
+    });
     this.getContentPane().add(scrollPane, BorderLayout.CENTER);
     jMenuBar1.add(jMenu1);
     jMenuBar1.add(jMenu2);
     jMenu1.add(saveMenu);
     jMenu1.add(printMenu);
+    jMenu2.add(fitToWindow);
     jMenu2.add(fontSize);
     jMenu2.add(distanceMenu);
     jMenu2.add(bootstrapMenu);
@@ -115,6 +125,11 @@ public class GTreePanel extends JInternalFrame
 
   }
 
+  protected void fitToWindow_actionPerformed(ActionEvent e)
+  {
+
+  }
+