From f0ade845a8f610bc402051d617cec4cfebe9e58a Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 18 Nov 2004 18:38:30 +0000 Subject: [PATCH] allow printing and 3d viewer --- src/jalview/gui/AlignFrame.java | 63 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index b504538..76c483e 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -16,8 +16,10 @@ import jalview.schemes.*; import jalview.datamodel.*; import jalview.analysis.*; import jalview.io.*; -import java.awt.event.*; +import MCview.*; import java.awt.*; +import java.awt.event.*; +import java.awt.print.*; import javax.swing.*; import java.util.*; @@ -72,11 +74,38 @@ public class AlignFrame extends GAlignFrame htmlOutput = null; } - public void saveAsPostscriptMenuItem_actionPerformed(ActionEvent e) + public void printMenuItem_actionPerformed(ActionEvent e) { + //Putting in a thread avoids Swing painting problems + PrintThread thread = new PrintThread(); + thread.start(); + } + + 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(); + } + } + } } + + + public void closeMenuItem_actionPerformed(ActionEvent e) { try{ @@ -671,4 +700,34 @@ public class AlignFrame extends GAlignFrame "Web service", JOptionPane.INFORMATION_MESSAGE); } + public void pdbTest_actionPerformed(ActionEvent e) + { + String reply = JOptionPane.showInputDialog(this, "Enter pdb code", "PDB test viewer", JOptionPane.QUESTION_MESSAGE); + + String url = "http://www.ebi.ac.uk/cgi-bin/pdbfetch?id=1a4u"; + if (reply.length()>1) + url = "http://www.ebi.ac.uk/cgi-bin/pdbfetch?id="+reply; + + try + { + PDBfile pdb = new PDBfile(url, + "URL"); + Sequence seq = (Sequence)viewport.getAlignment().getSequenceAt(0); + seq.setPDBfile(pdb); + ( (PDBChain) pdb.chains.elementAt(seq.maxchain)).isVisible = true; + ( (PDBChain) pdb.chains.elementAt(seq.maxchain)).sequence = seq; + // ( (PDBChain) pdb.chains.elementAt(seq.maxchain)).colourBySequence(); + + rotCanvas rc = new rotCanvas(pdb); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(rc); + Desktop.addInternalFrame(frame, url, 400,400); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + } + } -- 1.7.10.2