Page setup added
authoramwaterhouse <Andrew Waterhouse>
Wed, 24 Jan 2007 10:48:38 +0000 (10:48 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 24 Jan 2007 10:48:38 +0000 (10:48 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/jbgui/GAlignFrame.java

index f813457..b2fa937 100755 (executable)
@@ -825,6 +825,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     alignPanel.makeEPS(f);
   }
 
+
+  public void pageSetup_actionPerformed(ActionEvent e)
+  {
+    PrinterJob printJob = PrinterJob.getPrinterJob();
+    PrintThread.pf = printJob.pageDialog(printJob.defaultPage());
+  }
+
   /**
    * DOCUMENT ME!
    *
@@ -833,7 +840,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
   public void printMenuItem_actionPerformed(ActionEvent e)
   {
     //Putting in a thread avoids Swing painting problems
-    PrintThread thread = new PrintThread();
+    PrintThread thread = new PrintThread(alignPanel);
     thread.start();
   }
 
@@ -2932,28 +2939,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     return tp;
   }
 
-  class PrintThread
-      extends Thread
-  {
-    public void run()
-    {
-      PrinterJob printJob = PrinterJob.getPrinterJob();
-      PageFormat pf = printJob.pageDialog(printJob.defaultPage());
-      printJob.setPrintable(alignPanel, pf);
-
-      if (printJob.printDialog())
-      {
-        try
-        {
-          printJob.print();
-        }
-        catch (Exception PrintException)
-        {
-          PrintException.printStackTrace();
-        }
-      }
-    }
-  }
 
   /**
    * Generates menu items and listener event actions for web service clients
@@ -3356,3 +3341,34 @@ public void drop(DropTargetDropEvent evt)
     return viewport;
   }
 }
+
+class PrintThread extends Thread
+{
+  AlignmentPanel ap;
+  public PrintThread(AlignmentPanel ap)
+  {
+   this.ap = ap;
+  }
+  static PageFormat pf;
+  public void run()
+  {
+    PrinterJob printJob = PrinterJob.getPrinterJob();
+
+    if (pf != null)
+      printJob.setPrintable(ap, pf);
+    else
+      printJob.setPrintable(ap);
+
+    if (printJob.printDialog())
+    {
+      try
+      {
+        printJob.print();
+      }
+      catch (Exception PrintException)
+      {
+        PrintException.printStackTrace();
+      }
+    }
+  }
+}
index b5a0d30..47d4137 100755 (executable)
@@ -148,6 +148,7 @@ public class GAlignFrame
   protected JCheckBoxMenuItem idRightAlign = new JCheckBoxMenuItem();\r
   protected JMenuItem gatherViews = new JMenuItem();\r
   protected JMenuItem expandViews = new JMenuItem();\r
+  JMenuItem pageSetup = new JMenuItem();\r
   public GAlignFrame()\r
   {\r
     try\r
@@ -722,7 +723,7 @@ public class GAlignFrame
         wrapMenuItem_actionPerformed(e);\r
       }\r
     });\r
-    printMenuItem.setText("Print");\r
+    printMenuItem.setText("Print ...");\r
     printMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.\r
         event.KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));\r
     printMenuItem.addActionListener(new java.awt.event.ActionListener()\r
@@ -1220,6 +1221,14 @@ public class GAlignFrame
         expandViews_actionPerformed(e);\r
       }\r
     });\r
+    pageSetup.setText("Page Setup ...");\r
+    pageSetup.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        pageSetup_actionPerformed(e);\r
+      }\r
+    });\r
 \r
     alignFrameMenuBar.add(fileMenu);\r
     alignFrameMenuBar.add(editMenu);\r
@@ -1237,6 +1246,7 @@ public class GAlignFrame
     fileMenu.add(save);\r
     fileMenu.add(saveAs);\r
     fileMenu.add(outputTextboxMenu);\r
+    fileMenu.add(pageSetup);\r
     fileMenu.add(printMenuItem);\r
     fileMenu.addSeparator();\r
     fileMenu.add(jMenu2);\r
@@ -1796,4 +1806,9 @@ public class GAlignFrame
   {\r
 \r
   }\r
+\r
+  public void pageSetup_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
 }\r