/** Stops animation of displays whose {@link Data} have been restructured. */ @EventHandler protected void onEvent(final DataRestructuredEvent event) { final Data data = event.getObject(); for (final Animation animation : animations.values()) { final ImageDisplay display = animation.getDisplay(); if (display.isDisplaying(data)) stop(display); } }
@Override public void run() { final ArrayList<DataView> views = new ArrayList<DataView>(display); for (final DataView view : views) { if (view.isSelected()) { display.remove(view); view.dispose(); display.update(); } } }
public synchronized void toggleLegacyMode(boolean toggle) { final Harmonizer harmonizer = new Harmonizer(legacyService, imageTranslator); if (toggle) { // make sure that all ImageDisplays have a corresponding ImagePlus final List<ImageDisplay> imageDisplays = imageDisplayService.getImageDisplays(); // TODO: this is almost exactly what LegacyCommand does, so it is // pretty obvious that it is misplaced in there. for (final ImageDisplay display : imageDisplays) { ImagePlus imp = lookupImagePlus(display); if (imp == null) { final Dataset ds = imageDisplayService.getActiveDataset(display); if (LegacyUtils.dimensionsIJ1Compatible(ds)) { imp = registerDisplay(display); final ImageDisplayViewer viewer = (ImageDisplayViewer) uiService.getDisplayViewer(display); if (viewer != null) { final DisplayWindow window = viewer.getWindow(); if (window != null) window.showDisplay(!toggle); } } } else { imp.unlock(); } harmonizer.updateLegacyImage(display, imp); harmonizer.registerType(imp); } } else { for (ImagePlus imp : displayTable.keySet()) { final ImageWindow window = imp.getWindow(); final ImageDisplay display = displayTable.get(imp); if (window == null || window.isClosed()) { unregisterLegacyImage(imp); display.close(); } else { harmonizer.updateDisplay(display, imp); } } for (final WeakReference<ImagePlus> ref : legacyModeImages) { final ImagePlus imp = ref.get(); if (imp == null) continue; final ImageWindow window = imp.getWindow(); if (window != null && !window.isClosed()) { registerLegacyImage(imp); } } } legacyModeImages.clear(); }
/** * Create an AxisSubrange from a String definition. The definition is a textual language that * allows one or more positions to be defined by one or more comma separated values. Some * examples: * * <p> * * <ul> * <li>"1" : plane 1 * <li>"3,5" : planes 3 and 5 * <li>"1-10" : planes 1 through 10 * <li>"1-10,20-30" : planes 1 through 10 and 20 through 30 * <li>"1-10-2,20-30-3" : planes 1 through 10 by 2 and planes 20 through 30 by 3 * <li>"1,3-5,12-60-6" : an example combining all three formats * </ul> * * @param display The ImageDisplay used to set legal bounds on dimension sizes * @param axis The AxisType within the ImageDisplay that defines bounds * @param definition The textual description of the subrange (detailed elsewhere) * @param originOne A boolean specifying whether the origin within the String language should be * treated as 0 based or 1 based. */ public AxisSubrange( final ImageDisplay display, final AxisType axis, final String definition, final boolean originOne) { this(); final int axisIndex = display.getAxisIndex(axis); long min, max; if (originOne) { min = 1; max = display.dimension(axisIndex); } else { // origin zero min = 0; max = display.dimension(axisIndex) - 1; } parseAxisDefinition(min, max, definition); }
@Override public void applyLUT(final ColorTable colorTable, final ImageDisplay display) { final DatasetView view = imageDisplayService.getActiveDatasetView(display); if (view == null) return; final int channel = view.getIntPosition(Axes.CHANNEL); view.setColorTable(colorTable, channel); display.update(); }
// drag - publish rectangle dimensions in status bar @Override public void onMouseDrag(final MsDraggedEvent evt) { if (evt.getButton() != MsButtonEvent.LEFT_BUTTON) return; final StatusService statusService = evt.getContext().getService(StatusService.class); final ImageDisplayService imgService = evt.getContext().getService(ImageDisplayService.class); final ImageDisplay imgDisp = imgService.getActiveImageDisplay(); final IntCoords startPt = new IntCoords(anchor.x, anchor.y); final IntCoords endPt = new IntCoords(evt.getX() - anchor.x, evt.getY() - anchor.y); final RealCoords startPtModelSpace = imgDisp.getCanvas().panelToImageCoords(startPt); final RealCoords endPtModelSpace = imgDisp.getCanvas().panelToImageCoords(endPt); final int x = (int) startPtModelSpace.x; final int y = (int) startPtModelSpace.y; final int w = (int) endPtModelSpace.x; final int h = (int) endPtModelSpace.y; final String message = String.format("x=%d, y=%d, w=%d, h=%d", x, y, w, h); statusService.showStatus(message); // NB: Prevent PixelProbe from overwriting the status bar. evt.consume(); }
/** Gets the coordinates in <em>data</em> space for the given (x, y) pixel coordinates. */ private RealCoords getDataCoords(final Display<?> d, final int x, final int y) { if (!(d instanceof ImageDisplay)) return null; final ImageDisplay imageDisplay = (ImageDisplay) d; final ImageCanvas canvas = imageDisplay.getCanvas(); return canvas.panelToDataCoords(new IntCoords(x, y)); }