allow printing and 3d viewer
authoramwaterhouse <Andrew Waterhouse>
Thu, 18 Nov 2004 18:38:30 +0000 (18:38 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 18 Nov 2004 18:38:30 +0000 (18:38 +0000)
src/jalview/gui/AlignFrame.java

index b504538..76c483e 100755 (executable)
@@ -16,8 +16,10 @@ import jalview.schemes.*;
 import jalview.datamodel.*;\r
 import jalview.analysis.*;\r
 import jalview.io.*;\r
-import java.awt.event.*;\r
+import MCview.*;\r
 import java.awt.*;\r
+import java.awt.event.*;\r
+import java.awt.print.*;\r
 import javax.swing.*;\r
 import java.util.*;\r
 \r
@@ -72,11 +74,38 @@ public class AlignFrame extends GAlignFrame
     htmlOutput = null;\r
   }\r
 \r
-  public void saveAsPostscriptMenuItem_actionPerformed(ActionEvent e)\r
+  public void printMenuItem_actionPerformed(ActionEvent e)\r
   {\r
+    //Putting in a thread avoids Swing painting problems\r
+    PrintThread thread = new PrintThread();\r
+    thread.start();\r
+  }\r
+\r
+  class PrintThread extends Thread\r
+  {\r
+    public void run()\r
+    {\r
+      PrinterJob printJob = PrinterJob.getPrinterJob();\r
+      PageFormat pf = printJob.pageDialog(printJob.defaultPage());\r
+      printJob.setPrintable(alignPanel, pf);\r
+      if (printJob.printDialog())\r
+      {\r
+        try\r
+        {\r
+          printJob.print();\r
+        }\r
+        catch (Exception PrintException)\r
+        {\r
+          PrintException.printStackTrace();\r
+        }\r
+      }\r
+    }\r
 \r
   }\r
 \r
+\r
+\r
+\r
   public void closeMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     try{\r
@@ -671,4 +700,34 @@ public class AlignFrame extends GAlignFrame
                                   "Web service", JOptionPane.INFORMATION_MESSAGE);\r
   }\r
 \r
+  public void pdbTest_actionPerformed(ActionEvent e)\r
+  {\r
+   String reply = JOptionPane.showInputDialog(this, "Enter pdb code", "PDB test viewer", JOptionPane.QUESTION_MESSAGE);\r
+\r
+   String url = "http://www.ebi.ac.uk/cgi-bin/pdbfetch?id=1a4u";\r
+   if (reply.length()>1)\r
+     url = "http://www.ebi.ac.uk/cgi-bin/pdbfetch?id="+reply;\r
+\r
+   try\r
+   {\r
+     PDBfile pdb = new PDBfile(url,\r
+                               "URL");\r
+    Sequence seq = (Sequence)viewport.getAlignment().getSequenceAt(0);\r
+    seq.setPDBfile(pdb);\r
+     ( (PDBChain) pdb.chains.elementAt(seq.maxchain)).isVisible = true;\r
+     ( (PDBChain) pdb.chains.elementAt(seq.maxchain)).sequence = seq;\r
+  // ( (PDBChain) pdb.chains.elementAt(seq.maxchain)).colourBySequence();\r
+\r
+     rotCanvas rc = new rotCanvas(pdb);\r
+     JInternalFrame frame = new JInternalFrame();\r
+     frame.setContentPane(rc);\r
+     Desktop.addInternalFrame(frame, url, 400,400);\r
+   }\r
+   catch (Exception ex)\r
+   {\r
+     ex.printStackTrace();\r
+   }\r
+\r
+  }\r
+\r
 }\r