Interface CanAddROIToFrame


public interface CanAddROIToFrame
An interface to indicate that a JFrame can receive ROIs.
  • Method Details

    • getFrame

      JFrame getFrame()
      Returns the JFrame to which the ROI(s) will be added.
      Returns:
      the JFrame to which the ROI(s) will be added.
    • getSelectedSlice

      Integer getSelectedSlice()
      Returns the number of the selected image slice in this CanAddROIToFrame. Image slices are indexed from zero.
      Returns:
      the number of the selected image slice in this CanAddROIToFrame; returns null if the image does not have a selected slice, if the selected slice is outside the slice range of the image, or if there is no image currently loaded.
    • addROIs

      void addROIs(List<ROI> rois) throws ROIException
      Add a List of ROIs to the Frame.
      Parameters:
      rois - the List of ROIs to add.
      Throws:
      ROIException - if one or more of the ROIs couldn't be added.
    • addROI

      boolean addROI(ROI roi)
      Add an ROI to the frame.
      Parameters:
      roi - the ROI to add.
      Returns:
      true if the addition was successful.
    • exchangeROIs

      void exchangeROIs(List<ROI> oldROIs, List<ROI> newROIs, ROIEditAction editAction) throws ROIException
      Exchange one List of ROIs with another List of ROIs in this Frame.
      Parameters:
      oldROIs - the current List of ROIs to change.
      newROIs - the new List of ROIs that will be substituted.
      editAction - the ROIEditAction that records the action that resulted in the exchange.
      Throws:
      ROIException - if the exchange couldn't be made.
    • previewROIs

      void previewROIs(List<ROI> rois)
      Previews a List of ROIs in the frame.
      Parameters:
      rois - the List of ROIs to preview.
    • hasCurrentROIs

      boolean hasCurrentROIs() throws ROIException
      Tests whether a CanAddROIToFrame has current (not deleted) ROIs.
      Returns:
      true if the Frame has current (not deleted) ROIs.
      Throws:
      ROIException - if there is no image displayed.
    • getROIs

      List<ROI> getROIs() throws ROIException
      Returns a List of current (not deleted) ROIs for the image displayed.
      Returns:
      a List of current (not deleted) ROIs for the image displayed in this CanAddROIToFrame. Returns an empty list if the image has no ROIs.
      Throws:
      ROIException - if there is no image displayed.
    • getROIs

      List<ROI> getROIs(int slice) throws ROIException
      Returns a List of current (not deleted) ROIs for one slice of the image displayed.
      Parameters:
      slice - the slice number for the image.
      Returns:
      a List of current (not deleted) ROIs for one slice of the image displayed in this CanAddROIToFrame. Returns an empty list of there is no image displayed or the image has no ROIs in the given slice.
      Throws:
      ROIException - if the slice number is invalid.
    • getSelectedROIs

      List<ROI> getSelectedROIs()
      Returns a List of selected ROIs for the image displayed.
      Returns:
      a List of selected ROIs for the image displayed in this CanAddROIToFrame. Returns an empty list if there is no image displayed or no selected ROIs.
    • getDeletedROIs

      List<ROI> getDeletedROIs() throws ROIException
      Returns a List of deleted (not current) ROIs for the image displayed.
      Returns:
      a List of deleted ROIs for the image displayed in this CanAddROIToFrame. Will return an empty list if the image has no deleted ROIs.
      Throws:
      ROIException - if there is no image displayed.
    • getROIOutput

      byte[] getROIOutput() throws IOException
      Returns the current set of both current and deleted ROIs, outputted as text to a byte[].
      Returns:
      the ROIs, saved into the byte[].
      Throws:
      IOException - if an error occurs while writing the ROIs to the byte[].
    • getDeletedROIs

      List<ROI> getDeletedROIs(int slice) throws ROIException
      Returns a List of deleted (not current) ROIs for one slice of the image displayed.
      Parameters:
      slice - the slice number for the image.
      Returns:
      a List of deleted ROIs for one slice of the image displayed in this CanAddROIToFrame. Returns an empty list of there is no image displayed or the image has no deleted ROIs in the given slice.
      Throws:
      ROIException - if the slice number is invalid.
    • maskImage

      void maskImage(int slice, List<ROI> ROIs, MaskAction maskAction, double maskValue, CombineMode combineMode) throws ROIException
      Use the supplied ROIs in the slice to mask the image. Masking is the process of setting some of the pixel values to the maskValue according to whether they are inside or outside the ROIs. Before the mask action is applied, the ROIs are combined acording to the combineMode.
      Parameters:
      slice - the slice of the image to be masked.
      ROIs - a List of ROIs to be used as a mask.
      maskAction - one of:
      • MaskAction.NONE - no masking is performed;
      • MaskAction.MASK_INSIDE - pixels inside the ROIs are set to the mask value;
      • MaskAction.MASK_OUTSIDE - pixels outside the ROIs are set to the mask value.
      • MaskAction.MASK_INSIDE_SOFT - pixels inside the ROIs are set to somewhere between the mask value and the original pixel value depending how much of each pixel is inside the ROIs;
      • MaskAction.MASK_OUTSIDE_SOFT - pixels outside the ROIs are set to somewhere between the mask value and the original pixel value depending how much of each pixel is inside the ROIs.
      maskValue - the value to which pixel intensities will be changed. If maskValue is non-integer, then its value will be rounded to the nearest integer for Integer pixel value types. If the maskValue is outside the dynamic range of the pixel value type, then it will be truncated.
      combineMode - governs the way in which multiple ROIs are combined before the mask is applied. One of: CombineMode.UNION - a region is formed which is the union of all selected ROIs; CombineMode.INTERSECTION - a region is formed which is the intersection of all selected ROIs; CombineMode.XOR - a region is formed which is the exclsive OR of all selected ROIs.
      Throws:
      ROIException - if there is no current displayed image or if the displayed image doesn't have a slice selected, or if the selected slice has no ROIs.
    • unloadROIs

      boolean unloadROIs()
      Unload all ROIs from the frame.
      Returns:
      true if the ROIs were successfully unloaded.
    • unloadROIs

      boolean unloadROIs(boolean noQuery)
      Unload all ROIs from the frame, optionally unloading without querying the user.
      Parameters:
      noQuery - if true, the ROIs will be unloaded without querying the user.
      Returns:
      true if the ROIs were successfully unloaded.
    • unloadROIs

      boolean unloadROIs(Component c, boolean noQuery)
      Unload all ROIs from the CanAddROIToFrame, optionally unloading without querying the user.
      Parameters:
      c - the component used as the parent of any JOptionPane used to query the user.
      noQuery - if true, the ROIs will be unloaded without querying the user.
      Returns:
      true if the ROIs were successfully unloaded.
    • unloadROIs

      boolean unloadROIs(List<ROI> roisToUnload, Component c, boolean noQuery)
      Unload the supplied ROIs from the CanAddROIToFrame, optionally unloading without querying the user.
      Parameters:
      roisToUnload - a List<ROI> of the ROIs to unload.
      c - the component used as the parent of any JOptionPane used to query the user.
      noQuery - if true, the ROIs will be unloaded without querying the user.
      Returns:
      true if the ROIs were successfully unloaded.
    • showROIToolkit

      void showROIToolkit()
      Show the tool that is used to interactively create, modify and delete ROIs.
    • showError

      void showError(String message)
      Shows an error message in the CanAddROIToFrame.
      Parameters:
      message - the error message to show.
    • showStatus

      void showStatus(String message)
      Shows a status message in the CanAddROIToFrame.
      Parameters:
      message - the status message to show.