@Override public Dataset getValue() { if (imageDisplayService == null) return null; return imageDisplayService.getActiveDataset(); }
private Dataset dataset() { return imageDisplayService.getActiveDataset(display); }
private Dataset dataset() { return imageDisplayService.getActiveDataset(display); }
private boolean isMyDataset(final Dataset ds) { if (ds == null) return false; final ImageDisplay disp = getDisplay(); return imageDisplayService.getActiveDataset(disp) == ds; }
@Override public Dataset getActiveDataset(final ImageDisplay display) { return imageDisplayService().getActiveDataset(display); }
public ImagePlus createLegacyImage(final ImageDisplay display) { final Dataset dataset = imageDisplayService.getActiveDataset(display); return createLegacyImage(dataset, display); }
private void updateDataset(final ModuleItem<Dataset> item) { update(item, imageDisplayService.getActiveDataset()); }
/** * Ensures that the active {@link Dataset} of the given {@link ImageDisplay} * has equivalent ROIs/tables attached as those associated with the given * {@link ImagePlus}. * <p> * All ROIs/tables associated with the given {@link ImagePlus} are converted * and attached to the active {@link Dataset}. Such that both the given * {@link ImagePlus} and the active {@link Dataset} have equivalent ROIs and * tables attached. * </p> * * @param display The {@link ImageDisplay} whose active {@link Dataset} will * have equivalent ROIs/tables attached * @param imagePlus The {@link ImagePlus} whose ROIs/tables will be converted * and referenced by the active Dataset */ private void synchronizeAttachmentsToDataset(final ImageDisplay display, final ImagePlus imagePlus) { synchronizeAttachmentsToDataset(imageDisplayService.getActiveDataset( display), imagePlus); }
/** * Ensures that the given {@link ImagePlus} has the same ROIs/tables attached * as those attached to the active {@link Dataset} in the given * {@link ImageDisplay}. * <p> * All ROIs/tables associated with the active {@link Dataset}, are converted * and attached to the given {@link ImagePlus}. Such that both the active * {@link Dataset} and {@link ImagePlus} have equivalent ROIs and tables. * </p> * * @param imagePlus The {@link ImagePlus} to attach ROIs/tables to * @param display The {@link ImageDisplay} whose active {@link Dataset}'s * ROIs/tables will be converted and referenced by the ImagePlus */ private void synchronizeAttachmentsToImagePlus(final ImagePlus imagePlus, final ImageDisplay display) { synchronizeAttachmentsToImagePlus(imagePlus, imageDisplayService .getActiveDataset(display)); }
@SuppressWarnings("unchecked") @Override public <T> T convert(final Object src, final Class<T> dest) { if (!legacyEnabled() || imageDisplayService == null) { throw new UnsupportedOperationException(); } // Convert using the LegacyImageMap final ImageDisplay display = legacyService.getImageMap().registerLegacyImage((ImagePlus) src); final Dataset dataset = imageDisplayService.getActiveDataset(display); return (T) dataset; }
@Override public void fillOverlay(final Overlay o, final ImageDisplay display, final ChannelCollection channels) { draw(o, imageDisplayService.getActiveDataset(display), imageDisplayService .getActivePosition(display), channels, new OverlayFiller()); }
@Override public void drawOverlay(final Overlay o, final ImageDisplay display, final ChannelCollection channels) { draw(o, imageDisplayService.getActiveDataset(display), imageDisplayService .getActivePosition(display), channels, new OverlayOutliner()); }
@Override public Figure createDefaultFigure() { ImageDisplay display = imageDisplayService.getActiveImageDisplay(); if (display == null) return null; Dataset dataset = imageDisplayService.getActiveDataset(); if (dataset == null) return null; ThresholdOverlay overlay = thresholdService.getThreshold(display); return new ThresholdFigure(display, dataset, overlay); }
@Override public void preview() { if (imp == null) { cancelAndFreezeUI(NO_IMAGE); } else if (dataset != imageDisplayService.getActiveDataset()) { // uiService.getDisplayViewer(impDisplay).getWindow().requestFocus(); imp.getWindow().requestFocus(); // Only works on legacy mode } }
@Override protected void updateTitle() { String trailer = ""; final Dataset ds = imageDisplayService.getActiveDataset(display); if (ds != null) { final Img<?> img = ds.getImgPlus().getImg(); if (AbstractCellImg.class.isAssignableFrom(img.getClass())) { trailer = " (V)"; } } String name = getDisplay().getName(); if (name == null) name = ""; getWindow().setTitle(name + trailer); }
@Override public ThresholdOverlay getThreshold(final ImageDisplay display) { ThresholdOverlay overlay = thresholdMap().get(display); if (overlay == null) { final Dataset dataset = displayService.getActiveDataset(display); if (dataset == null) { throw new IllegalArgumentException( "expected ImageDisplay to have active dataset"); } overlay = new ThresholdOverlay(getContext(), dataset); thresholdMap().put(display, overlay); display.display(overlay); // NOTE - the call on prev line did a rebuild() but not necessarily an // update(). So graphics might not be up to date! This may be a bug in // display code. Anyhow this next line makes sure that the display is // updated. This fixes the problem where you adjust threshold and in // dialog you delete the thresh and then go into min or max field and make // a change. Correct behavior is for new thresh to immediately appear. // Without this update() call the thresh overlay exists but doesn't get // displayed. display.update(); // TEMP HACK } return overlay; }
/** * Changes the data within an {@link ImagePlus} to match data in a * {@link ImageDisplay}. Assumes Dataset has planar primitive access in a * legacy ImageJ compatible format. */ public void updateLegacyImage(final ImageDisplay display, final ImagePlus imp) { final Dataset ds = imageDisplayService.getActiveDataset(display); rebuildImagePlusData(display, imp); metadataHarmonizer.updateLegacyImage(ds, imp); colorTableHarmonizer.updateLegacyImage(display, imp); // NB - correct thresholding behavior requires overlay harmonization after // color table harmonization overlayHarmonizer.updateLegacyImage(display, imp); positionHarmonizer.updateLegacyImage(display, imp); nameHarmonizer.updateLegacyImage(display, imp); }
/** * Modifies a given {@link Dataset} to incorporate all new data from a legacy * {@link ImagePlus}. Internally the Dataset refers to an all new {@link * ImgPlus}. */ private void rebuildDatasetData(final Dataset ds, final ImagePlus imp) { // NB - create display from copy of original ImagePlus? Not right now. But // will need to in future if createDisplay() registers "imp" with legacy // image map. If that were the case we'd have two displays referring to a // single ImagePlus which could be problematic. But since we're not // registering right now avoid the runtime penalty and memory overhead. //final ImagePlus impCopy = imp.duplicate(); //final ImageDisplay tmpDisplay = // imageTranslator.createDisplay(impCopy, ds.getAxes()); final ImageDisplay tmpDisplay = imageTranslator.createDisplay(imp); final Dataset tmpDs = imageDisplayService.getActiveDataset(tmpDisplay); ds.setImgPlus(tmpDs.getImgPlus()); ds.setRGBMerged(tmpDs.isRGBMerged()); tmpDisplay.close(); }
ImagePlus imp = lookupImagePlus(display); if (imp == null) { final Dataset ds = imageDisplayService.getActiveDataset(display); if ( LegacyUtils.dimensionsIJ1Compatible(ds)) {
final Dataset ds = imgDispSrv.getActiveDataset(disp); setImagePlusLUTToFirstInDataset(ds, imp);