package ij.plugin;
import ij.*;
import ij.gui.*;
import ij.process.*;
import ij.plugin.filter.Analyzer;
import ij.measure.Measurements;
import java.awt.*;
import java.awt.event.*;
import java.util.*;


/** This plugin implements the Edit/Options/Point Tool command. */
public class PointToolOptions implements PlugIn, DialogListener {
	private static GenericDialog gd = null;
	private boolean multipointTool;
	private boolean isMacro;
	
	private static final String help = ""
	+"

Point Tool

" +"" +"
    " +"
  • Alt-click, or control-click, on a point to delete it.
    " +"
  • Press 'alt+y' (Edit>Selection>Properties plus
    alt key) to display the counts in a results table.
    " +"
  • Press 'm' (Analyze>Measure) to list the counter
    and stack position associated with each point.
    " +"
  • Use File>Save As>Tiff or File>Save As>Selection
    to save the points and counts.
    " +"
  • Hold the shift key down and points will be
    constrained to a horizontal or vertical line.
    " +"
" +"
" +"
"; public void run(String arg) { if (gd!=null && gd.isShowing() && !IJ.isMacro()) { gd.toFront(); update(); } else showDialog(); } void showDialog() { String options = IJ.isMacro()?Macro.getOptions():null; isMacro = options!=null; boolean legacyMacro = false; if (isMacro) { options = options.replace("selection=", "color="); options = options.replace("marker=", "size="); Macro.setOptions(options); legacyMacro = options.contains("auto-") || options.contains("add"); } multipointTool = Toolbar.getMultiPointMode() && !legacyMacro; if (isMacro && !legacyMacro) multipointTool = true; Color sc =Roi.getColor(); String sname = Colors.getColorName(sc, "Yellow"); Color cc =PointRoi.getDefaultCrossColor(); String cname = Colors.getColorName(cc, "None"); String type = PointRoi.types[PointRoi.getDefaultType()]; String size = PointRoi.sizes[PointRoi.getDefaultSize()]; if (multipointTool) gd = new NonBlockingGenericDialog("Point Tool"); else gd = new GenericDialog("Point Tool"); gd.setInsets(5,0,2); gd.addChoice("Type:", PointRoi.types, type); gd.addChoice("Color:", Colors.getColors(), sname); gd.addChoice("Size:", PointRoi.sizes, size); if (!multipointTool) { gd.addCheckbox("Auto-measure", Prefs.pointAutoMeasure); gd.addCheckbox("Auto-next slice", Prefs.pointAutoNextSlice); gd.addCheckbox("Add_to overlay", Prefs.pointAddToOverlay); gd.addCheckbox("Add to ROI Manager", Prefs.pointAddToManager); } gd.setInsets(5, 20, 0); gd.addCheckbox("Label points", !Prefs.noPointLabels); if (multipointTool) { gd.addCheckbox("Show all", Prefs.showAllPoints); gd.setInsets(15,0,5); String[] choices = PointRoi.getCounterChoices(); gd.addChoice("Counter:", choices, choices[getCounter()]); gd.setInsets(2, 75, 0); gd.addMessage(getCount(getCounter())+" "); } gd.addHelp(help); gd.addDialogListener(this); gd.showDialog(); if (gd.wasCanceled()) { } } public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) { boolean redraw = false; // type int typeIndex = gd.getNextChoiceIndex(); if (typeIndex!=PointRoi.getDefaultType()) { PointRoi.setDefaultType(typeIndex); redraw = true; } // color String selectionColor = gd.getNextChoice(); Color sc = Colors.getColor(selectionColor, Color.yellow); if (sc!=Roi.getColor()) { Roi.setColor(sc); redraw = true; Toolbar.getInstance().repaint(); } // size int sizeIndex = gd.getNextChoiceIndex(); if (sizeIndex!=PointRoi.getDefaultSize()) { PointRoi.setDefaultSize(sizeIndex); redraw = true; } if (!multipointTool) { Prefs.pointAutoMeasure = gd.getNextBoolean(); Prefs.pointAutoNextSlice = gd.getNextBoolean(); Prefs.pointAddToOverlay = gd.getNextBoolean(); Prefs.pointAddToManager = gd.getNextBoolean(); if (Prefs.pointAddToOverlay) Prefs.pointAddToManager = false; if (Prefs.pointAutoNextSlice&&!Prefs.pointAddToManager) Prefs.pointAutoMeasure = true; } boolean updateLabels = false; boolean noPointLabels = !gd.getNextBoolean(); if (noPointLabels!=Prefs.noPointLabels) { redraw = true; updateLabels = true; } Prefs.noPointLabels = noPointLabels; if (multipointTool) { boolean showAllPoints = gd.getNextBoolean(); if (showAllPoints!=Prefs.showAllPoints) redraw = true; Prefs.showAllPoints = showAllPoints; int counter = gd.getNextChoiceIndex(); if (counter!=getCounter()) { setCounter(counter); redraw = true; } } if (isMacro) { PointRoi roi = getPointRoi(); if (roi!=null) { roi.setPointType(typeIndex); roi.setStrokeColor(sc); roi.setSize(sizeIndex); } } if (redraw) { ImagePlus imp = null; PointRoi roi = getPointRoi(); if (roi!=null) { roi.setShowLabels(!Prefs.noPointLabels); imp = roi.getImage(); } if (updateLabels) { imp = WindowManager.getCurrentImage(); Overlay overlay = imp!=null?imp.getOverlay():null; int pointRoiCount = 0; if (overlay!=null) { for (int i=0; i

Ads help maintain this website.