From: Jim Procter Date: Mon, 23 Jun 2014 15:21:02 +0000 (+0100) Subject: JAL-1526 simple function to write a snapshot of the desktop. X-Git-Tag: Release_2_8_2b1^2~62^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d8ddf2968124b3518e567a91411357b1d291ff77;p=jalview.git JAL-1526 simple function to write a snapshot of the desktop. --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index f8f4019..b7057d1 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -26,6 +26,7 @@ import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; +import jalview.util.ImageMaker; import jalview.util.MessageManager; import jalview.ws.params.ParamManager; @@ -2771,4 +2772,20 @@ public class Desktop extends jalview.jbgui.GDesktop implements dialogPause = false; block.release(); } + @Override + protected void snapShotWindow_actionPerformed(ActionEvent e) + { + invalidate(); + File of; + ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.EPS, "View of Desktop", getWidth(), getHeight(), of=new File("Jalview_snapshot"+System.currentTimeMillis()+".eps"), "View of desktop"); + try { + paintAll(im.getGraphics()); + im.writeImage(); + } catch (Exception q) + { + Cache.log.error("Couldn't write snapshot to "+of.getAbsolutePath(),q); + return; + } + Cache.log.info("Successfully written snapshot to file "+of.getAbsolutePath()); + } } diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 0b9d779..4751d25 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -68,7 +68,7 @@ public class GDesktop extends JFrame JMenuItem saveState = new JMenuItem(); JMenuItem loadState = new JMenuItem(); - + JMenu inputMenu = new JMenu(); protected JMenuItem vamsasStart = new JMenuItem(); @@ -94,7 +94,8 @@ public class GDesktop extends JFrame protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem(); - + + protected JMenuItem snapShotWindow = new JMenuItem(); /** * Creates a new GDesktop object. */ @@ -338,6 +339,15 @@ public class GDesktop extends JFrame showNews_actionPerformed(e); } }); + snapShotWindow.setText(MessageManager.getString("label.take_snapshot")); + snapShotWindow.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + snapShotWindow_actionPerformed(e); + } + }); + desktopMenubar.add(FileMenu); desktopMenubar.add(toolsMenu); VamsasMenu.setVisible(false); @@ -364,6 +374,7 @@ public class GDesktop extends JFrame toolsMenu.add(showConsole); toolsMenu.add(showNews); toolsMenu.add(garbageCollect); + toolsMenu.add(snapShotWindow); inputMenu.add(inputLocalFileMenuItem); inputMenu.add(inputURLMenuItem); inputMenu.add(inputTextboxMenuItem); @@ -374,6 +385,12 @@ public class GDesktop extends JFrame // inputMenu.add(vamsasLoad); } + protected void snapShotWindow_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + protected void showConsole_actionPerformed(ActionEvent e) { // TODO Auto-generated method stub