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

How to use
getOverlayInfo
method
in
net.imagej.display.OverlayService

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

origin: net.imagej/imagej-ui-swing

private void runPropertiesPlugin() {
  final Map<String, Object> inputMap = new HashMap<>();
  inputMap.put("overlays", overlayService.getOverlayInfo().selectedOverlays());
  // FIXME: Migrate OverlayProperties functionality into OverlayService API.
  commandService.run(
    "net.imagej.plugins.commands.overlay.SelectedManagerOverlayProperties",
    true, inputMap);
}
origin: net.imagej/imagej-ui-swing

private void properties() {
  int[] selected = overlayService.getOverlayInfo().selectedIndices();
  if (selected.length == 0) {
    JOptionPane.showMessageDialog(this, "This command requires one or more selections");
    return;
  }
  // else one or more selections exist
  runPropertiesPlugin();
}

origin: net.imagej/imagej-ui-swing

private void sort() {
  overlayService.getOverlayInfo().sort();
  int[] newSelections = overlayService.getOverlayInfo().selectedIndices();
  jlist.setSelectedIndices(newSelections);
  jlist.updateUI();
}

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 deselect() {
  overlayService.getOverlayInfo().deselectAll();
  jlist.clearSelection();
}

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 rename() {
  final int[] selectedIndices = overlayService.getOverlayInfo().selectedIndices();
  if (selectedIndices.length < 1) {
    JOptionPane.showMessageDialog(this, "Must select an overlay to rename");
    return;
  }
  if (selectedIndices.length > 1) {
    JOptionPane.showMessageDialog(this, "Cannot rename multiple overlays simultaneously");
    return;
  }
  final OverlayInfo info = overlayService.getOverlayInfo().getOverlayInfo(selectedIndices[0]);
  if (info == null) return;
  // TODO - UI agnostic way here
  final String name = JOptionPane.showInputDialog(this, "Enter new name for overlay");
  if ((name == null) || (name.length() == 0))
    info.getOverlay().setName(null);
  else
    info.getOverlay().setName(name);
  jlist.updateUI();
}

origin: net.imagej/imagej-ui-swing

@EventHandler
protected void onEvent(final OverlayDeletedEvent event) {
  //System.out.println("\tDELETED: " + event.toString());
  Overlay overlay = event.getObject();
  overlayService.getOverlayInfo().deleteOverlay(overlay);
  int[] newSelectedIndices = overlayService.getOverlayInfo().selectedIndices();
  jlist.setSelectedIndices(newSelectedIndices);
  jlist.updateUI();
}

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-ui-swing

context.inject(this);
jlist = new JList<>(new OverlayListModel(overlayService.getOverlayInfo()));
origin: net.imagej/imagej-ui-swing

@EventHandler
protected void onEvent(final OverlayCreatedEvent event) {
  //System.out.println("\tCREATED: " + event.toString());
  overlayService.getOverlayInfo().addOverlay(event.getObject());
  jlist.updateUI();
}
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 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 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-ui-swing

final int overlayIndex = overlayService.getOverlayInfo().findIndex(overlay);
final OverlayInfo overlayInfo = overlayService.getOverlayInfo().getOverlayInfo(overlayIndex);
overlayInfo.setSelected(event.isSelected());
int[] selections = overlayService.getOverlayInfo().selectedIndices();
jlist.setSelectedIndices(selections);
selecting = false;
origin: net.imagej/imagej-ui-swing

  @Override
  public void valueChanged(final ListSelectionEvent listSelectionEvent) {
    if (selecting) return;
    selecting = true;
    final ImageDisplay display =
      imageDisplayService.getActiveImageDisplay();
    if (display == null) return;
    final JList<?> list = (JList<?>) listSelectionEvent.getSource();
    final List<?> selectionValues = list.getSelectedValuesList();
    overlayService.getOverlayInfo().deselectAll();
    for (final Object overlayInfoObj : selectionValues) {
      final OverlayInfo overlayInfo = (OverlayInfo) overlayInfoObj;
      overlayInfo.setSelected(true);
    }
    for (final DataView overlayView : display) {
      overlayView.setSelected(false);
      for (final Object overlayInfoObj : selectionValues) {
        final OverlayInfo overlayInfo = (OverlayInfo) overlayInfoObj;
        if (overlayInfo.getOverlay() == overlayView.getData()) {
          overlayInfo.setSelected(true);
          overlayView.setSelected(true);
          break;
        }
      }
    }
    selecting = false;
  }
};
net.imagej.displayOverlayServicegetOverlayInfo

Javadoc

Returns the overlay info list associated with this service. There is one list per ImageJ context. It tracks overlay selection info and is used by any defined overlay managers.

Popular methods of OverlayService

  • 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
  • getSelectionBounds
    Gets the bounding box for the selected overlays in the given ImageDisplay.

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • onRequestPermissionsResult (Fragment)
  • setContentView (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Best plugins for Eclipse
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