@Override public void removeOverlay(final ImageDisplay display, final Overlay overlay) { final ArrayList<DataView> overlayViews = new ArrayList<>(); final List<DataView> views = display; for (final DataView view : views) { final Data data = view.getData(); if (data == overlay) overlayViews.add(view); } for (final DataView view : overlayViews) { display.remove(view); view.dispose(); } display.update(); }
private void updateAxis(final AxisType axis) { final int value = (int) display.getLongPosition(axis); if (axis == Axes.CHANNEL) updateColorBar(value); final JScrollBar scrollBar = axisSliders.get(axis); if (scrollBar != null) scrollBar.setValue(value); getDisplay().update(); }
@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(); }
private void makeCompositeOverlay(CompositeOverlay.Operation op) { ImageDisplay imageDisplay = imageDisplayService.getActiveImageDisplay(); if (imageDisplay == null) return; List<Overlay> overlays = overlayService.getOverlayInfo().selectedOverlays(); if (overlays.size() == 0) overlays = overlayService.getOverlays(imageDisplay); if (overlays.size() < 2) { JOptionPane.showMessageDialog(this, "This command only works with 2 or more overlays"); return; } // else overlays.size() >= 2 CompositeOverlay newOverlay = new CompositeOverlay(context); for (Overlay o : overlays) newOverlay.doOperation(op, o); imageDisplay.display(newOverlay); imageDisplay.update(); }
@Override public void divideCompositeOverlay(final CompositeOverlay overlay) { final List<Overlay> subcomponents = overlay.getSubcomponents(); // to each display that owns the composite // reference the original overlays (if not already) final List<ImageDisplay> owners = getDisplays(overlay); for (final ImageDisplay owner : owners) { boolean changes = false; final List<Overlay> displayOverlays = getOverlays(owner); for (final Overlay subcomponent : subcomponents) { if (!displayOverlays.contains(subcomponent)) { owner.display(subcomponent); changes = true; } } if (changes) owner.update(); } // delete the composite overlay removeOverlay(overlay); }
@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; }
@Override public void figureRemoved(final FigureEvent e) { final ImageDisplay d = getDisplay(); if (d.isVisible(overlayView)) { DataView view = getDataView(); // TODO : replace next two lines with call to OverlayService to // removeOverlay(d, getDataView().getData()); d.remove(view); view.dispose(); // end TODO replace dispose(); d.update(); } } });
/** * When a tool creates an overlay, add the overlay/figure combo to an * {@link OverlayFigureView}. */ @EventHandler protected void onEvent(final FigureCreatedEvent event) { final ImageDisplay display = event.getDisplay(); if (display != getDisplay()) return; // not this canvas's display final OverlayView overlay = event.getView(); for (int i = 0; i < display.numDimensions(); i++) { final AxisType axisType = display.axis(i).type(); if (axisType.isXY()) continue; if (overlay.getData().dimensionIndex(axisType) < 0) { overlay.setPosition(display.getLongPosition(axisType), axisType); } } if (drawingView.getSelectedFigures().contains(event.getFigure())) { overlay.setSelected(true); } final OverlayFigureView figureView = new OverlayFigureView(displayViewer, overlay, event.getFigure()); figureViews.add(figureView); display.add(overlay); display.update(); }