From: amwaterhouse Date: Tue, 8 Mar 2005 16:36:48 +0000 (+0000) Subject: Tree fits to window by default X-Git-Tag: Release_2_0~622 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=764f4139569c1135e41348b24943c3e6d22f74ef;p=jalview.git Tree fits to window by default --- diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index fd9619e..de84902 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -20,6 +20,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print Font font; int fontSize = 12; + boolean fitToWindow = true; boolean showDistances = false; boolean showBootstrap = false; @@ -331,15 +332,15 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print repaint(); - if( scrollPane.getHeight() > fm.getHeight() * nameHash.size()+offy) + if( fitToWindow || (!fitToWindow && scrollPane.getHeight() > fm.getHeight() * nameHash.size()+offy ) ) { draw(g,scrollPane.getWidth(),scrollPane.getHeight()); - setPreferredSize(new Dimension(scrollPane.getWidth(), scrollPane.getHeight())); + setPreferredSize(null); } else { - setPreferredSize(new Dimension(getWidth(), fm.getHeight() * nameHash.size())); - draw( g,getWidth(), fm.getHeight() * nameHash.size()); + setPreferredSize(new Dimension(scrollPane.getWidth(), fm.getHeight() * nameHash.size())); + draw( g,scrollPane.getWidth(), fm.getHeight() * nameHash.size()); } diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index 4b605bf..f723fdc 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -266,6 +266,13 @@ public void propertiesInit() { treeCanvas.startPrinting(); } + protected void fitToWindow_actionPerformed(ActionEvent e) + { + treeCanvas.fitToWindow = fitToWindow.isSelected(); + repaint(); + } + + protected void fontSize_actionPerformed(ActionEvent e) { if( treeCanvas==null ) diff --git a/src/jalview/jbgui/GTreePanel.java b/src/jalview/jbgui/GTreePanel.java index 4b18fd3..e67518b 100755 --- a/src/jalview/jbgui/GTreePanel.java +++ b/src/jalview/jbgui/GTreePanel.java @@ -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) + { + + } +