public class ROI2DArea extends ROI2D
Modifier and Type | Class and Description |
---|---|
class |
ROI2DArea.ROI2DAreaPainter |
ROI2D.ROI2DPainter
ROI.ROIGroupId, ROI.ROIIdComparator, ROI.ROINameComparator, ROI.ROIPainter
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ID_BOOLMASK_DATA |
static java.lang.String |
ID_BOUNDS_H |
static java.lang.String |
ID_BOUNDS_W |
static java.lang.String |
ID_BOUNDS_X |
static java.lang.String |
ID_BOUNDS_Y |
DEFAULT_COLOR, DEFAULT_NORMAL_COLOR, DEFAULT_OPACITY, DEFAULT_STROKE, defaultColor, defaultOpacity, defaultShowName, defaultStroke, ID_CLASSNAME, ID_COLOR, ID_GROUPID, ID_ID, ID_NAME, ID_OPACITY, ID_PROPERTIES, ID_READONLY, ID_ROI, ID_SELECTED, ID_SHOWNAME, ID_STROKE, idComparator, nameComparator, PROPERTY_COLOR, PROPERTY_CREATING, PROPERTY_GROUPID, PROPERTY_ICON, PROPERTY_NAME, PROPERTY_OPACITY, PROPERTY_READONLY, PROPERTY_SHOWNAME, PROPERTY_STROKE, ROI_CHANGED_ALL, ROI_CHANGED_POSITION
Constructor and Description |
---|
ROI2DArea()
Create a ROI2D Area type from the specified
BooleanMask2D . |
ROI2DArea(BooleanMask2D mask)
Create a ROI2D Area type from the specified
BooleanMask2D . |
ROI2DArea(java.awt.geom.Point2D position)
Create a ROI2D Area type with a single point.
|
ROI2DArea(java.awt.geom.Point2D position,
boolean cm)
Deprecated.
Use
ROI2DArea(Point5D) instead |
ROI2DArea(Point5D position)
Generic constructor for interactive mode.
|
ROI2DArea(ROI2DArea area)
Create a copy of the specified 2D Area ROI
|
Modifier and Type | Method and Description |
---|---|
void |
add(BooleanMask2D mask)
Add the specified
BooleanMask2D content to this ROI2DArea |
void |
add(ROI2DArea roi)
Add the specified
ROI2DArea content to this ROI2DArea |
ROI |
add(ROI roi,
boolean allowCreate)
Adds content of specified
ROI into this ROI . |
void |
addBrush(java.awt.geom.Point2D pos)
Add brush point at specified position.
|
void |
addPoint(int x,
int y)
Add a point to the mask
|
void |
addPoint(java.awt.Point pos)
Add a point to the mask
|
boolean |
addPointAt(java.awt.geom.Point2D pos,
boolean ctrl)
Deprecated.
Use
addBrush(Point2D) instead. |
void |
addRect(int x,
int y,
int w,
int h)
Add a rectangle to the mask
|
void |
addRect(java.awt.Rectangle r)
Add a rectangle to the mask
|
void |
addShape(java.awt.Shape s)
Add a shape to the mask
|
boolean |
canAddPoint()
Deprecated.
useless method.
|
boolean |
canRemovePoint()
Deprecated.
useless method.
|
boolean |
canSetPosition()
Returns
true if this ROI accepts position change through the ROI.setPosition5D(Point5D) method. |
boolean |
canTranslate()
Returns
true if the ROI support translate operation. |
void |
clear()
Clear the mask
|
java.awt.geom.Rectangle2D |
computeBounds2D()
Calculate and returns the 2D bounding box of the
ROI . |
double |
computeNumberOfPoints()
Generic implementation for ROI2D using the BooleanMask object so the result is just an
approximation.
|
boolean |
contains(double x,
double y)
Tests if the specified coordinates are inside the
ROI . |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if the
ROI entirely contains the specified rectangular area. |
void |
downscale()
Fast 2x down scaling (each 2x2 block points become 1 point).
|
void |
downscale(int nbPointForTrue)
Fast 2x down scaling (each 2x2 block points become 1 point).
|
void |
exclusiveAdd(BooleanMask2D mask)
Exclusively add the specified
BooleanMask2D content to this ROI2DArea:
mask1 xor mask2 = result
################ ################
############## ############## ## ##
############ ############ #### ####
########## ########## ###### ######
######## ######## ################
###### ###### ###### ######
#### #### #### ####
## ## ## ##
|
void |
exclusiveAdd(ROI2DArea roi)
Exclusively add the specified
ROI2DArea content to this ROI2DArea:
mask1 xor mask2 = result
################ ################
############## ############## ## ##
############ ############ #### ####
########## ########## ###### ######
######## ######## ################
###### ###### ###### ######
#### #### #### ####
## ## ## ##
|
ROI |
exclusiveAdd(ROI roi,
boolean allowCreate)
Sets the content of this
ROI to be the union of its current content and the
content of the specified ROI , minus their intersection. |
boolean[] |
getBooleanMask(int x,
int y,
int w,
int h,
boolean inclusive)
Get the boolean bitmap mask for the specified rectangular area of the roi.
|
java.awt.geom.Rectangle2D |
getBounds2D()
Returns a high precision and more accurate bounding box of the
ROI than the getBounds
method. |
boolean |
getBoundsNeedUpdate()
Return true if bounds need to be updated by calling optimizeBounds() method.
|
java.lang.String |
getDefaultName() |
java.awt.image.BufferedImage |
getImageMask()
Returns the internal image mask.
|
java.awt.Color |
getMaskColor()
Deprecated.
Use
ROI.getDisplayColor() instead. |
ROI2DArea.ROI2DAreaPainter |
getOverlay()
|
ROI2DArea.ROI2DAreaPainter |
getPainter()
Deprecated.
|
boolean |
hasSelectedPoint()
Returns true if the ROI has a (control) point which is currently focused/selected
|
ROI |
intersect(ROI roi,
boolean allowCreate)
Sets the content of this
ROI to the intersection of
its current content and the content of the specified ROI . |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the interior of the
ROI intersects the interior of a specified
rectangular area. |
boolean |
isEmpty()
Returns true if the ROI is empty (the mask does not contains any point).
|
boolean |
isOverEdge(IcyCanvas canvas,
double x,
double y)
Returns true if specified point coordinates overlap the ROI edge.
|
boolean |
loadFromXML(org.w3c.dom.Node node)
LOAD
|
void |
onChanged(CollapsibleEvent object)
fire changed event
|
boolean |
optimizeBounds()
Optimize the bounds size to the minimum surface which still include all mask
You should call it after consecutive remove operations. |
void |
optimizeBounds(boolean removeIfEmpty)
Deprecated.
Use
optimizeBounds() instead. |
void |
remove(BooleanMask2D mask)
Deprecated.
Use
subtract(BooleanMask2D) instead |
void |
remove(ROI2DArea roi)
Deprecated.
Use
subtract(ROI2DArea) instead |
void |
removeBrush(java.awt.geom.Point2D pos)
Remove brush point from the mask at specified position.
|
void |
removePoint(int x,
int y)
Remove a point to the mask.
|
void |
removePoint(java.awt.Point pos)
Remove a point from the mask.
|
boolean |
removePointAt(IcyCanvas canvas,
java.awt.geom.Point2D pos)
Deprecated.
Use
removeBrush(Point2D) instead. |
void |
removeRect(int x,
int y,
int w,
int h)
Remove a rectangle from the mask.
|
void |
removeRect(java.awt.Rectangle r)
Remove a rectangle from the mask.
|
void |
removeShape(java.awt.Shape s)
Remove a shape to the mask.
|
boolean |
saveToXML(org.w3c.dom.Node node)
SAVE
|
void |
setAsBooleanMask(BooleanMask2D mask)
Set the mask from a BooleanMask2D object.
|
void |
setAsBooleanMask(int x,
int y,
int w,
int h,
boolean[] booleanMask) |
void |
setAsBooleanMask(java.awt.Rectangle r,
boolean[] booleanMask)
Set the mask from a boolean array.
|
void |
setPoint(int x,
int y,
boolean value)
Set the value of the specified point.
|
void |
setPosition2D(java.awt.geom.Point2D newPosition)
Set the
ROI 2D position. |
void |
subtract(BooleanMask2D mask)
Subtract the specified
BooleanMask2D from this ROI2DArea |
void |
subtract(ROI2DArea roi)
Subtract the specified
ROI2DArea from this ROI2DArea |
ROI |
subtract(ROI roi,
boolean allowCreate)
Subtract the specified
ROI content from current ROI . |
void |
translate(double dx,
double dy)
Translate the ROI position by the specified delta X/Y.
|
void |
updateMask(int x,
int y,
boolean remove)
Deprecated.
Use
setPoint(int, int, boolean) instead. |
void |
updateMask(java.awt.Shape shape,
boolean remove)
Update mask from specified shape
|
void |
updateMask(java.awt.Shape shape,
boolean remove,
boolean inclusive,
boolean accurate,
boolean immediateUpdate)
Update mask by adding/removing the specified shape to/from it.
|
void |
upscale()
Fast up scaling by a factor of 2 (each point become a 2x2 block points)
|
canSetBounds, computeBounds5D, computeNumberOfContourPoints, computePerimeter, contains, contains, contains, contains, contains, getArea, getAsBooleanMask, getAsBooleanMask, getAsBooleanMask, getAsBooleanMask, getAsBooleanMask, getAsBooleanMask, getBooleanMask, getBooleanMask, getBooleanMask, getBooleanMask, getBooleanMask, getBooleanMask2D, getBooleanMask2D, getBounds, getC, getDimension, getPerimeter, getPerimeter, getPosition, getPosition2D, getROI2DList, getROI2DList, getROI2DList, getSubROI, getT, getZ, intersects, intersects, intersects, isActiveFor, isActiveFor, isOver, isOver, isOverEdge, isOverEdge, isOverEdge, merge, setBounds2D, setBounds5D, setC, setPosition, setPosition5D, setT, setZ, substract, subtract
addListener, attachTo, beginUpdate, canvasToImageDeltaX, canvasToImageDeltaY, canvasToImageLogDeltaX, canvasToImageLogDeltaX, canvasToImageLogDeltaX, canvasToImageLogDeltaX, canvasToImageLogDeltaY, canvasToImageLogDeltaY, canvasToImageLogDeltaY, canvasToImageLogDeltaY, contains, contains, copyFrom, create, create, create, create, createFromXML, delete, delete, detachFrom, detachFromAll, detachFromAll, endUpdate, focusChanged, getAdjustedStroke, getAdjustedStroke, getBooleanMask2D, getBounds5D, getClassName, getColor, getCopy, getDefaultColor, getDefaultOpacity, getDefaultShowName, getDefaultStroke, getDisplayColor, getExclusiveUnion, getFirstSequence, getFocusedColor, getGroupId, getIcon, getId, getIntersection, getLength, getName, getNameSuffix, getNumberOfContourPoints, getNumberOfPoints, getOpacity, getPosition5D, getProperties, getProperty, getPropertyValue, getROICount, getROIList, getROIList, getROIList, getROIsFromXML, getSelectedColor, getSequences, getShowName, getSimpleClassName, getStroke, getSubtraction, getUnion, getVolume, internalFocus, internalSelect, internalUnfocus, internalUnselect, intersects, isAttached, isCreating, isDefaultName, isEditable, isFocused, isReadOnly, isSelected, isUpdating, loadFromXML, loadROIsFromXML, merge, mergeWith, nameChanged, painterChanged, propertyChanged, remove, remove, removeListener, roiChanged, roiChanged, roiChanged, saveROIsToXML, selectionChanged, setColor, setCreating, setDefaultColor, setDefaultOpacity, setDefaultShowName, setDefaultStroke, setEditable, setFocused, setGroupId, setIcon, setMousePos, setName, setOpacity, setProperty, setPropertyValue, setReadOnly, setROIsFromXML, setSelected, setSelected, setSelectedColor, setShowName, setStroke, unselectAllPoints
public static final java.lang.String ID_BOUNDS_X
public static final java.lang.String ID_BOUNDS_Y
public static final java.lang.String ID_BOUNDS_W
public static final java.lang.String ID_BOUNDS_H
public static final java.lang.String ID_BOOLMASK_DATA
public ROI2DArea()
BooleanMask2D
.@Deprecated public ROI2DArea(java.awt.geom.Point2D position, boolean cm)
ROI2DArea(Point5D)
insteadpublic ROI2DArea(java.awt.geom.Point2D position)
public ROI2DArea(BooleanMask2D mask)
BooleanMask2D
.public java.lang.String getDefaultName()
getDefaultName
in class ROI2D
@Deprecated public void optimizeBounds(boolean removeIfEmpty)
optimizeBounds()
instead.public boolean isEmpty()
public boolean optimizeBounds()
@Deprecated public java.awt.Color getMaskColor()
ROI.getDisplayColor()
instead.public java.awt.image.BufferedImage getImageMask()
public void setPoint(int x, int y, boolean value)
@Deprecated public void updateMask(int x, int y, boolean remove)
setPoint(int, int, boolean)
instead.public void add(BooleanMask2D mask)
BooleanMask2D
content to this ROI2DAreapublic void exclusiveAdd(ROI2DArea roi)
ROI2DArea
content to this ROI2DArea:
mask1 xor mask2 = result ################ ################ ############## ############## ## ## ############ ############ #### #### ########## ########## ###### ###### ######## ######## ################ ###### ###### ###### ###### #### #### #### #### ## ## ## ##
public void exclusiveAdd(BooleanMask2D mask)
BooleanMask2D
content to this ROI2DArea:
mask1 xor mask2 = result ################ ################ ############## ############## ## ## ############ ############ #### #### ########## ########## ###### ###### ######## ######## ################ ###### ###### ###### ###### #### #### #### #### ## ## ## ##
public void subtract(BooleanMask2D mask)
BooleanMask2D
from this ROI2DArea@Deprecated public void remove(ROI2DArea roi)
subtract(ROI2DArea)
instead@Deprecated public void remove(BooleanMask2D mask)
subtract(BooleanMask2D)
insteadpublic void updateMask(java.awt.Shape shape, boolean remove, boolean inclusive, boolean accurate, boolean immediateUpdate)
shape
- the shape to add in or remove from the maskremove
- if set to true
the shape will be removed from the maskinclusive
- if we should also consider the edge of the shape to update the maskaccurate
- if set to true
the operation will be done to be as pixel accurate as
possibleimmediateUpdate
- if set to true
the bounds of the mask will be immediately recomputed
(only meaningful for a
remove operation)public void updateMask(java.awt.Shape shape, boolean remove)
@Deprecated public ROI2DArea.ROI2DAreaPainter getPainter()
getPainter
in class ROI
public ROI2DArea.ROI2DAreaPainter getOverlay()
ROI
getOverlay
in class ROI
public boolean hasSelectedPoint()
ROI
hasSelectedPoint
in class ROI
@Deprecated public boolean canAddPoint()
@Deprecated public boolean canRemovePoint()
@Deprecated public boolean addPointAt(java.awt.geom.Point2D pos, boolean ctrl)
addBrush(Point2D)
instead.@Deprecated public boolean removePointAt(IcyCanvas canvas, java.awt.geom.Point2D pos)
removeBrush(Point2D)
instead.public void addBrush(java.awt.geom.Point2D pos)
public void removeBrush(java.awt.geom.Point2D pos)
public void addPoint(java.awt.Point pos)
public void addPoint(int x, int y)
public void removePoint(java.awt.Point pos)
public void removePoint(int x, int y)
public void addRect(java.awt.Rectangle r)
public void addRect(int x, int y, int w, int h)
public void removeRect(java.awt.Rectangle r)
public void removeRect(int x, int y, int w, int h)
public void addShape(java.awt.Shape s)
public void removeShape(java.awt.Shape s)
public ROI add(ROI roi, boolean allowCreate) throws java.lang.UnsupportedOperationException
ROI
ROI
into this ROI
.
The resulting content of this ROI
will include
the union of both ROI's contents.UnsupportedOperationException
is thrown if allowCreate
parameter
is set to false
, if the parameter is set to true
the result may be returned in a new
created ROI.
// Example: roi1 (before) + roi2 = roi1 (after) ################ ################ ################ ############## ############## ################ ############ ############ ################ ########## ########## ################ ######## ######## ################ ###### ###### ###### ###### #### #### #### #### ## ## ## ##
add
in class ROI
roi
- the ROI
to be added to the current ROI
allowCreate
- if set to true
the method will create a new ROI to return the result of
the operation if it
cannot be directly processed on the current ROI
allowCreate
parameter was set to true
java.lang.UnsupportedOperationException
- if the two ROI cannot be added together.ROI.getUnion(ROI)
public ROI intersect(ROI roi, boolean allowCreate) throws java.lang.UnsupportedOperationException
ROI
ROI
to the intersection of
its current content and the content of the specified ROI
.
The resulting ROI will include only contents that were contained in both ROI.UnsupportedOperationException
is thrown if allowCreate
parameter
is set to false
, if the parameter is set to true
the result may be returned in a new
created ROI.
// Example: roi1 (before) intersect roi2 = roi1 (after) ################ ################ ################ ############## ############## ############ ############ ############ ######## ########## ########## #### ######## ######## ###### ###### #### #### ## ##
intersect
in class ROI
roi
- the ROI
to be intersected to the current ROI
allowCreate
- if set to true
the method will create a new ROI to return the result of
the operation if it
cannot be directly processed on the current ROI
allowCreate
parameter was set to true
java.lang.UnsupportedOperationException
- if the two ROI cannot be intersected together.ROI.getIntersection(ROI)
public ROI exclusiveAdd(ROI roi, boolean allowCreate) throws java.lang.UnsupportedOperationException
ROI
ROI
to be the union of its current content and the
content of the specified ROI
, minus their intersection.
The resulting ROI
will include only content that were contained in either this ROI
or
in the specified ROI
, but not in both.UnsupportedOperationException
is thrown if allowCreate
parameter is set to
false
, if the parameter is set to true
the result may be returned
in a new created ROI.
// Example: roi1 (before) xor roi2 = roi1 (after) ################ ################ ############## ############## ## ## ############ ############ #### #### ########## ########## ###### ###### ######## ######## ################ ###### ###### ###### ###### #### #### #### #### ## ## ## ##
exclusiveAdd
in class ROI
roi
- the ROI
to be exclusively added to the current ROI
allowCreate
- if set to true
the method will create a new ROI to return the result of
the operation if it
cannot be directly processed on the current ROI
allowCreate
parameter was set to true
java.lang.UnsupportedOperationException
- if the two ROI cannot be exclusively added together.ROI.getExclusiveUnion(ROI)
public ROI subtract(ROI roi, boolean allowCreate) throws java.lang.UnsupportedOperationException
ROI
ROI
content from current ROI
.UnsupportedOperationException
is thrown if allowCreate
parameter
is set to false
, if the parameter is set to true
the result may be returned in a new
created ROI.subtract
in class ROI
roi
- the ROI
to subtract from the current ROI
allowCreate
- if set to true
the method will create a new ROI to return the result of
the operation if it
cannot be directly processed on the current ROI
allowCreate
parameter was set to true
java.lang.UnsupportedOperationException
- if we can't subtract the specified ROI
from this ROI
ROI.getSubtraction(ROI)
public boolean getBoundsNeedUpdate()
public void clear()
public boolean isOverEdge(IcyCanvas canvas, double x, double y)
ROI2D
ROI2D.contains(double, double)
to test for content overlap instead.isOverEdge
in class ROI2D
public boolean contains(double x, double y)
ROI2D
ROI
.public boolean contains(double x, double y, double w, double h)
ROI2D
ROI
entirely contains the specified rectangular area. All
coordinates that lie inside the rectangular area must lie within the ROI
for the
entire rectangular area to be considered contained within the ROI
.
The ROI.contains()
method allows a ROI
implementation to conservatively return false
when:
intersect
method returns true
and
ROI
entirely contains the rectangular area are
prohibitively expensive.
ROIs
this method might return false
even though the ROI
contains
the rectangular area.contains
in class ROI2D
x
- the X coordinate of the upper-left corner of the specified rectangular areay
- the Y coordinate of the upper-left corner of the specified rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areatrue
if the interior of the ROI
entirely contains the
specified rectangular area; false
otherwise or, if the ROI
contains the
rectangular area and the intersects
method returns true
and the containment
calculations would be too expensive to perform.public java.awt.geom.Rectangle2D computeBounds2D()
ROI2D
ROI
.ROI2D.getBounds2D()
which should try to cache the result as the
bounding box calculation can take some computation time for complex ROI.computeBounds2D
in class ROI2D
public java.awt.geom.Rectangle2D getBounds2D()
ROI2D
ROI
than the getBounds
method. Note that there is no guarantee that the returned Rectangle2D
is the smallest bounding box that
encloses the ROI
, only
that the ROI
lies entirely within the indicated Rectangle2D
. The
bounding box returned by this method is usually tighter than that returned by the getBounds
method
and never fails due to overflow problems since the return value
can be an instance of the Rectangle2D
that uses double precision values to store
the dimensions.getBounds2D
in class ROI2D
Rectangle2D
that is a high-precision bounding box of the ROI
.public boolean intersects(double x, double y, double w, double h)
ROI2D
ROI
intersects the interior of a specified
rectangular area. The rectangular area is considered to intersect the ROI
if any
point is contained in both the interior of the ROI
and the specified rectangular
area.
The ROI.intersects()
method allows a ROI
implementation to conservatively return true
when:
ROI
intersect, but
ROIs
this method might return true
even though the rectangular area does
not intersect the ROI
.intersects
in class ROI2D
x
- the X coordinate of the upper-left corner of the specified rectangular areay
- the Y coordinate of the upper-left corner of the specified rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areatrue
if the interior of the ROI
and the interior of the
rectangular area intersect, or are both highly likely to intersect and intersection
calculations would be too expensive to perform; false
otherwise.public boolean[] getBooleanMask(int x, int y, int w, int h, boolean inclusive)
ROI2D
getBooleanMask
in class ROI2D
x
- the X coordinate of the upper-left corner of the specified rectangular areay
- the Y coordinate of the upper-left corner of the specified rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areainclusive
- If true then all partially contained (intersected) pixels are included in the mask.public double computeNumberOfPoints()
ROI2D
computeNumberOfPoints
in class ROI2D
public boolean canTranslate()
ROI2D
true
if the ROI support translate operation.canTranslate
in class ROI2D
ROI2D.translate(double, double)
public void translate(double dx, double dy)
ROI2D
ROI2D.canTranslate()
first.translate
in class ROI2D
dx
- translation value to apply on X dimensiondy
- translation value to apply on Y dimensionROI2D.canTranslate()
,
ROI2D.setPosition2D(Point2D)
public boolean canSetPosition()
ROI
true
if this ROI accepts position change through the ROI.setPosition5D(Point5D)
method.canSetPosition
in class ROI2D
public void setPosition2D(java.awt.geom.Point2D newPosition)
ROI2D
ROI
2D position.ROI2D.canSetPosition()
first to test
if the operation is supported.setPosition2D
in class ROI2D
newPosition
- new ROI 2D positionpublic void setAsBooleanMask(BooleanMask2D mask)
public void setAsBooleanMask(java.awt.Rectangle r, boolean[] booleanMask)
r
- booleanMask
- public void setAsBooleanMask(int x, int y, int w, int h, boolean[] booleanMask)
public void upscale()
public void downscale(int nbPointForTrue)
nbPointForTrue
- the minimum number of true
points from a 2x2 block to give a true
resulting
point.public void downscale()
public void onChanged(CollapsibleEvent object)
ChangeListener
onChanged
in interface ChangeListener
onChanged
in class ROI
public boolean loadFromXML(org.w3c.dom.Node node)
XMLPersistent
loadFromXML
in interface XMLPersistent
loadFromXML
in class ROI2D
public boolean saveToXML(org.w3c.dom.Node node)
XMLPersistent
saveToXML
in interface XMLPersistent
saveToXML
in class ROI2D