MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / actionPerformed

Method actionPerformed

ij/src/main/java/ij/gui/PlotWindow.java:501–586  ·  view source on GitHub ↗

Called if user has activated a button or popup menu item

(ActionEvent e)

Source from the content-addressed store, hash-verified

499
500 /** Called if user has activated a button or popup menu item */
501 @AstroImageJ(reason = "Handle saving of various AIJ data", modified = true)
502 public void actionPerformed(ActionEvent e) {
503 try {
504 Object b = e.getSource();
505 if (b==live)
506 toggleLivePlot();
507 else if (b==pdfButton) {
508 String fileName = getTitle().replace("Plot of ", "").replace("Measurements in ", "");
509 SaveDialog sf = new SaveDialog("Save plot as vector PDF", fileName, ".pdf");
510 if (sf.getDirectory() == null || sf.getFileName() == null) return;
511 PdfPlotOutput.savePlot(imp.getPlot(), sf.getDirectory() + sf.getFileName());
512 } else if (b==pngButton) {
513 String fileName = getTitle().replace("Plot of ","").replace("Measurements in ", "");
514 SaveDialog sf = new SaveDialog("Save plot as PNG",fileName, ".png");
515 if (sf.getDirectory() == null || sf.getFileName() == null) return;
516 // Save unscaled plot
517 var image = imp;
518 if (plot.isAijPlot()) {
519 image = ScopedValue.where(VectorPlotDrawing.SCALED_PLOT, false).call(() -> {
520 var scaledPlot = plot.duplicate();
521 scaledPlot.draw();
522 return scaledPlot.getImagePlus();
523 });
524 }
525 IJ.runPlugIn(image, "ij.plugin.PNG_Writer", sf.getDirectory()+sf.getFileName());
526 } else if (b==aps) {
527 Prefs.set("aperture.radius",Prefs.get("seeingprofile.radius", 20));
528 Prefs.set("aperture.rback1",Prefs.get("seeingprofile.rback1", 30));
529 Prefs.set("aperture.rback2",Prefs.get("seeingprofile.rback2", 40));
530 Prefs.set("setaperture.aperturechanged",true);
531 }
532 else if (b==list)
533 showList(/*useLabels=*/true);
534 else if (b==data) {
535 enableDisableMenuItems();
536 dataPopupMenu.show((Component)b, 1, 1);
537 } else if (b==more) {
538 enableDisableMenuItems();
539 morePopupMenu.show((Component)b, 1, 1);
540 } else if (b==menuItems[SAVE]) {
541 saveAsText();
542 }
543 else if (b==menuItems[COPY])
544 copyToClipboard(false);
545 else if (b==menuItems[COPY_ALL] || b==copy)
546 copyToClipboard(true);
547 else if (b==menuItems[LIST_SIMPLE])
548 showList(/*useLabels=*/false);
549 else if (b==menuItems[ADD_FROM_TABLE])
550 new PlotContentsDialog(plot, PlotContentsDialog.ADD_FROM_TABLE).showDialog(this);
551 else if (b==menuItems[ADD_FROM_PLOT])
552 new PlotContentsDialog(plot, PlotContentsDialog.ADD_FROM_PLOT).showDialog(this);
553 else if (b==menuItems[ADD_FIT])
554 new PlotContentsDialog(plot, PlotContentsDialog.ADD_FIT).showDialog(this);
555 else if (b==menuItems[ZOOM_SELECTION]) {
556 if (imp!=null && imp.getRoi()!=null && imp.getRoi().isArea())
557 plot.zoomToRect(imp.getRoi().getBounds());
558 } else if (b==menuItems[SET_RANGE])

Callers

nothing calls this directly

Calls 15

toggleLivePlotMethod · 0.95
getDirectoryMethod · 0.95
getFileNameMethod · 0.95
savePlotMethod · 0.95
runPlugInMethod · 0.95
setMethod · 0.95
getMethod · 0.95
showListMethod · 0.95
saveAsTextMethod · 0.95
copyToClipboardMethod · 0.95
getDefaultFlagsMethod · 0.95

Tested by

no test coverage detected