Tabnine Logo
OverlayService
Code IndexAdd Tabnine to your IDE (free)

How to use
OverlayService
in
net.imagej.display

Best Java code snippets using net.imagej.display.OverlayService (Showing top 14 results out of 315)

origin: net.imagej/imagej-legacy

/**
 * Updates the given {@link ImageDisplay} to contain {@link Overlay}s
 * corresponding to all the given {@link ImagePlus}'s Rois (both the active
 * Roi and the Rois stored in ImageJ 1.x's current Overlay).
 */
@Override
public void updateDisplay(final ImageDisplay display, final ImagePlus imp) {
  final List<Overlay> overlaysToRemove = overlayService.getOverlays(display);
  for (final Overlay overlay : overlaysToRemove) {
    overlayService.removeOverlay(display, overlay);
  }
  /*
  if (fullySelected(display, imp)) {
    for (DataView view : display)
      view.setSelected(true);
  }
  else {
  */
  final List<Overlay> overlays = getOverlays(imp);
  overlayService.addOverlays(display, overlays);
  // }
  setModernThreshold(display, imp);
}
origin: net.imagej/imagej-legacy

/**
 * Updates the given {@link ImagePlus}'s Roi and Overlay to match the modern
 * ImageJ {@link Overlay}s being visualized in the given {@link ImageDisplay}.
 */
@Override
public void
  updateLegacyImage(final ImageDisplay display, final ImagePlus imp)
{
  final List<Overlay> overlays = overlayService.getOverlays(display);
  setOverlays(overlays, overlayService.getActiveOverlay(display), imp);
  setLegacyThreshold(display, imp);
}
origin: net.imagej/imagej-ui-swing

/**
 * Takes the currently selected CompositeOverlay and turns it into its
 * constituent overlays. The CompositeOverlay is deleted. It does one layer
 * of division (it is not a deep division).
 */
private void divide() {
  List<Overlay> overlays = overlayService.getOverlayInfo().selectedOverlays();
  int i = 0;
  while (i < overlays.size()) {
    Overlay o = overlays.get(i);
    if (! (o instanceof CompositeOverlay))
      overlays.remove(i);
    else
      i++;
  }
  if (overlays.size() == 0) {
    JOptionPane.showMessageDialog(
      this, "One or more composite overlays must be selected");
    return;
  }
  for (Overlay o : overlays) {
    overlayService.divideCompositeOverlay((CompositeOverlay) o);
  }
}

origin: net.imagej/imagej-ui-swing

private void draw() {
  ChannelCollection channels = getChannels();
  List<Overlay> selected = overlayService.getOverlayInfo().selectedOverlays();
  for (Overlay o : selected) {
    ImageDisplay disp = overlayService.getFirstDisplay(o);
    overlayService.drawOverlay(o, disp, channels);
  }
}
origin: net.imagej/imagej-ui-swing

private void fill() {
  ChannelCollection channels = getChannels();
  List<Overlay> selected = overlayService.getOverlayInfo().selectedOverlays();
  for (Overlay o : selected) {
    ImageDisplay disp = overlayService.getFirstDisplay(o);
    overlayService.fillOverlay(o, disp, channels);
  }
}

origin: net.imagej/imagej-ui-swing

private void delete() {
  if (overlayService.getOverlayInfo().getOverlayInfoCount() == 0) return;
  List<Overlay> overlaysToDelete = new LinkedList<>();
  final int[] selectedIndices = overlayService.getOverlayInfo().selectedIndices();
  if (selectedIndices.length == 0) {
    final int result =
      JOptionPane.showConfirmDialog(
        this, "Delete all overlays?", "Delete All", JOptionPane.YES_NO_OPTION);
    if (result != JOptionPane.YES_OPTION) return;
    for (int i = 0; i < overlayService.getOverlayInfo().getOverlayInfoCount(); i++) {
      overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(i).getOverlay());
    }
  }
  else {
    for (int i = 0; i < selectedIndices.length; i++) {
      int index = selectedIndices[i];
      overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(index).getOverlay());
    }
  }
  for (Overlay overlay : overlaysToDelete) {
    // NB - removeOverlay() can indirectly change our infoList contents.
    // Thus we first collect overlays from the infoList and then delete
    // them all afterwards to avoid interactions.
    overlayService.removeOverlay(overlay);
  }
}

origin: net.imagej/imagej-ui-swing

private void populateOverlayList() {
  // Populate the list with all overlays
  for (final Overlay overlay : overlayService.getOverlays()) {
    boolean found = false;
    int totOverlays = overlayService.getOverlayInfo().getOverlayInfoCount();
    for (int i = 0; i < totOverlays; i++) {
      OverlayInfo info = overlayService.getOverlayInfo().getOverlayInfo(i);
      if (overlay == info.getOverlay()) {
        found = true;
        break;
      }
    }
    if (!found) {
      OverlayInfo info = new OverlayInfo(overlay);
      overlayService.getOverlayInfo().addOverlayInfo(info);
    }
  }
  jlist.updateUI();
}

origin: net.imagej/imagej-deprecated

@Override
public void removeThreshold(final ImageDisplay display) {
  final ThresholdOverlay overlay = thresholdMap().get(display);
  if (overlay != null) {
    overlayService.removeOverlay(display, overlay);
    thresholdMap().remove(display);
  }
}
origin: net.imagej/imagej-common

private void attachOverlays(final ImageDisplay inputDisp,
  final ImageDisplay outputDisp, final List<Overlay> overlays)
{
  final RealRect bounds = overlayService.getSelectionBounds(inputDisp);
  final double[] toOrigin = new double[2];
  toOrigin[0] = -bounds.x;
  toOrigin[1] = -bounds.y;
  final List<Overlay> newOverlays = new ArrayList<>();
  for (final Overlay overlay : overlays) {
    if (overlayWithinBounds(overlay, bounds)) {
      // add a reference to existing overlay?
      if (toOrigin[0] == 0 && toOrigin[1] == 0) {
        newOverlays.add(overlay);
      }
      else { // different origins means must create new overlays
        final Overlay newOverlay = overlay.duplicate();
        newOverlay.move(toOrigin);
        newOverlays.add(newOverlay);
      }
    }
  }
  overlayService.addOverlays(outputDisp, newOverlays);
}
origin: net.imagej/imagej-common

@Override
public void run() {
  if (overlayService != null) {
    updateSettings(overlayService.getDefaultSettings());
  }
  super.run();
}
origin: net.imagej/imagej-common

@Override
public Overlay getValue() {
  if (imageDisplayService == null) return null;
  final ImageDisplay display = imageDisplayService.getActiveImageDisplay();
  return display == null ? null : overlayService.getActiveOverlay(display);
}
origin: net.imagej/imagej-ui-swing

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

origin: net.imagej/imagej-common

public AbstractOverlay(final Context context, RealInterval interval) {
  super(context, interval);
  if (overlayService == null) applySettings(new OverlaySettings());
  else applySettings(overlayService.getDefaultSettings());
  setAxis(new DefaultLinearAxis(Axes.X, null, 1), 0);
  setAxis(new DefaultLinearAxis(Axes.Y, null, 1), 1);
}
origin: net.imagej/imagej-ui-swing

protected void initDefaultSettings(final F figure) {
  final OverlaySettings settings = overlayService.getDefaultSettings();
  set(figure, AttributeKeys.STROKE_WIDTH, getDefaultLineWidth(settings));
  set(figure, AttributeKeys.FILL_COLOR, getDefaultFillColor(settings));
  set(figure, AttributeKeys.STROKE_COLOR, getDefaultStrokeColor(settings));
  // Avoid IllegalArgumentException: miter limit < 1 on the EDT
  set(figure, AttributeKeys.IS_STROKE_MITER_LIMIT_FACTOR, false);
}
net.imagej.displayOverlayService

Javadoc

Interface for service that works with Overlays.

Most used methods

  • removeOverlay
    Removes an Overlay from all ImageDisplays.
  • addOverlays
    Adds the list of Overlays to the given ImageDisplay.
  • getActiveOverlay
    Returns the active overlay associated with a display
  • getDefaultSettings
  • getOverlays
    Gets a list of Overlays linked to the given ImageDisplay. If selectedOnly is true then it will gathe
  • divideCompositeOverlay
    Divides a CompositeOverlay into its constituent parts and registers each part with the appropriate d
  • drawOverlay
    Draws the outline of a given overlay in a display using the set of channel information provided.
  • fillOverlay
    Draws and fills the outline of a given overlay in a display using the set of channel information pro
  • getFirstDisplay
    Returns the first display associated with an overlay
  • getOverlayInfo
    Returns the overlay info list associated with this service. There is one list per ImageJ context. It
  • getSelectionBounds
    Gets the bounding box for the selected overlays in the given ImageDisplay.
  • getSelectionBounds

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSupportFragmentManager (FragmentActivity)
  • onRequestPermissionsResult (Fragment)
  • getExternalFilesDir (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • ImageIO (javax.imageio)
  • JTable (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now