Search in sources :

Example 31 with Display

use of ini.trakem2.display.Display in project TrakEM2 by trakem2.

the class ControlClickBehavior method doProcess.

@Override
public void doProcess(final MouseEvent e) {
    if (!e.isControlDown() || e.getID() != MouseEvent.MOUSE_PRESSED) {
        super.doProcess(e);
        return;
    }
    final Picker picker = universe.getPicker();
    final Content content = picker.getPickedContent(e.getX(), e.getY());
    if (content == null)
        return;
    final Point3d p = picker.getPickPointGeometry(content, e);
    if (p == null) {
        Utils.log("No point was found on content " + content);
        return;
    }
    final Display display = Display.getFront(ls.getProject());
    if (display == null) {
        // If there's no Display, just return...
        return;
    }
    if (display.getLayerSet() != ls) {
        Utils.log("The LayerSet instances do not match");
        return;
    }
    if (ls == null) {
        Utils.log("No LayerSet was found for the Display");
        return;
    }
    final Calibration cal = ls.getCalibration();
    if (cal == null) {
        Utils.log("No calibration information was found for the LayerSet");
        return;
    }
    final double scaledZ = p.z / cal.pixelWidth;
    final Layer l = ls.getNearestLayer(scaledZ);
    if (l == null) {
        Utils.log("No layer was found nearest to " + scaledZ);
        return;
    }
    final Coordinate<?> coordinate = new Coordinate<Object>(p.x / cal.pixelWidth, p.y / cal.pixelHeight, l, null);
    display.center(coordinate);
}
Also used : Coordinate(ini.trakem2.display.Coordinate) Content(ij3d.Content) Point3d(org.scijava.vecmath.Point3d) Picker(ij3d.behaviors.Picker) Calibration(ij.measure.Calibration) Layer(ini.trakem2.display.Layer) Display(ini.trakem2.display.Display)

Aggregations

ArrayList (java.util.ArrayList)11 Layer (ini.trakem2.display.Layer)10 Worker (ini.trakem2.utils.Worker)10 LayerSet (ini.trakem2.display.LayerSet)9 ZDisplayable (ini.trakem2.display.ZDisplayable)9 DBObject (ini.trakem2.persistence.DBObject)9 ImagePlus (ij.ImagePlus)8 Display (ini.trakem2.display.Display)8 Displayable (ini.trakem2.display.Displayable)8 HashSet (java.util.HashSet)8 Project (ini.trakem2.Project)7 GenericDialog (ij.gui.GenericDialog)6 Roi (ij.gui.Roi)6 ProjectThing (ini.trakem2.tree.ProjectThing)6 Rectangle (java.awt.Rectangle)6 File (java.io.File)6 DirectoryChooser (ij.io.DirectoryChooser)5 Calibration (ij.measure.Calibration)5 Future (java.util.concurrent.Future)5 JPopupMenu (javax.swing.JPopupMenu)5