()
| 75 | } |
| 76 | |
| 77 | @AstroImageJ(reason = "Add various save buttons to SP stack plot") |
| 78 | void draw() { |
| 79 | if (!getTitle().startsWith("Seeing Profile")) { |
| 80 | return; |
| 81 | } |
| 82 | Panel bottomPanel = new Panel(); |
| 83 | int hgap = IJ.isMacOSX()?1:5; |
| 84 | |
| 85 | var pdf = new JButton(" Summary PDF "); |
| 86 | pdf.setToolTipText("Save summary image as PDF"); |
| 87 | bottomPanel.add(pdf); |
| 88 | |
| 89 | var png = new JButton(" Summary PNG "); |
| 90 | png.setToolTipText("Save summary image as PNG"); |
| 91 | bottomPanel.add(png); |
| 92 | |
| 93 | var stackPdf = new JButton(" Stack PDF "); |
| 94 | stackPdf.setToolTipText("Save full stack as PDF"); |
| 95 | bottomPanel.add(stackPdf); |
| 96 | |
| 97 | var gif = new JButton(" Stack GIF "); |
| 98 | gif.setToolTipText("Save full stack as GIF"); |
| 99 | bottomPanel.add(gif); |
| 100 | |
| 101 | var copy = new JButton(" Copy... "); |
| 102 | copy.setToolTipText("Copy plot image or data"); |
| 103 | if (imp.getStack() instanceof PlotVirtualStack) { |
| 104 | bottomPanel.add(copy); |
| 105 | } |
| 106 | |
| 107 | var listener = new ActionListener() { |
| 108 | public void actionPerformed(ActionEvent e) { |
| 109 | Object b = e.getSource(); |
| 110 | Plot summaryPlot = null; |
| 111 | if (imp.getStack() instanceof PlotVirtualStack plotVirtualStack) { |
| 112 | summaryPlot = plotVirtualStack.getPlot(1); |
| 113 | } |
| 114 | if (b == pdf) { |
| 115 | String fileName = getTitle().replace("Plot of ","").replace("Measurements in ", ""); |
| 116 | SaveDialog sf = new SaveDialog("Save summary plot as vector PDF", fileName, ".pdf"); |
| 117 | if (sf.getDirectory() == null || sf.getFileName() == null) return; |
| 118 | PdfPlotOutput.savePlot(summaryPlot, sf.getDirectory()+sf.getFileName()); |
| 119 | } else if (b == png) { |
| 120 | String fileName = getTitle().replace("Plot of ","").replace("Measurements in ", ""); |
| 121 | SaveDialog sf = new SaveDialog("Save summary plot as PNG",fileName, ".png"); |
| 122 | if (sf.getDirectory() == null || sf.getFileName() == null) return; |
| 123 | var imp2 = imp.duplicate(); |
| 124 | imp2.setSlice(1); |
| 125 | IJ.runPlugIn(imp2, "ij.plugin.PNG_Writer", sf.getDirectory()+sf.getFileName()); |
| 126 | } else if (b == gif) { |
| 127 | String fileName = getTitle().replace("Plot of ","").replace("Measurements in ", ""); |
| 128 | SaveDialog sf = new SaveDialog("Save plot stack as GIF", fileName, ".gif"); |
| 129 | if (sf.getDirectory() == null || sf.getFileName() == null) return; |
| 130 | GifWriter.save(imp, sf.getDirectory()+sf.getFileName()); |
| 131 | } else if (b == stackPdf) { |
| 132 | String fileName = getTitle().replace("Plot of ","").replace("Measurements in ", ""); |
| 133 | SaveDialog sf = new SaveDialog("Save plot stack as vector PDF", fileName, ".pdf"); |
| 134 | if (sf.getDirectory() == null || sf.getFileName() == null) return; |
no test coverage detected