View Javadoc
1   package com.github.celldynamics.quimp.plugin.protanalysis;
2   
3   import java.awt.event.ActionEvent;
4   
5   import org.scijava.vecmath.Point2d;
6   
7   import com.github.celldynamics.quimp.QuimpException;
8   
9   import ij.gui.Roi;
10  
11  /**
12   * Get reference point from current roi.
13   * 
14   * @author p.baniukiewicz
15   *
16   */
17  @SuppressWarnings("serial")
18  public class ActionRoiPredefinedPoint extends ProtAnalysisAbstractAction {
19  
20    /**
21     * Action creator.
22     * 
23     * @param name name
24     * @param desc description
25     * @param ui reference to outer class.
26     */
27    public ActionRoiPredefinedPoint(String name, String desc, ProtAnalysisUi ui) {
28      super(name, desc, ui);
29    }
30  
31    /*
32     * (non-Javadoc)
33     * 
34     * @see
35     * com.github.celldynamics.quimp.plugin.protanalysis.ProtAnalysisAbstractAction#actionPerformed(
36     * java.awt.event.ActionEvent)
37     */
38    @Override
39    public void actionPerformed(ActionEvent e) {
40      try {
41        Roi roi = model.getImage().getRoi();
42        if (roi == null) {
43          throw new QuimpException("No selection in the image", model.getSink());
44        }
45        options.gradientPoint = new Point2d(roi.getXBase(), roi.getYBase());
46        model.getGui().updateStaticFields();
47        model.getImage().deleteRoi();
48      } catch (QuimpException e1) {
49        e1.handleException(null, "Cannot access ROI.");
50      }
51    }
52  
53  }