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);
}
Aggregations