ij.gui
Class RectangleRoi

java.lang.Object
  extended by ij.gui.AbstractRoi
      extended by ij.gui.AttributeRoi
          extended by ij.gui.Roi
              extended by ij.gui.RectangleRoi
All Implemented Interfaces:
RoiBeans, RoiConstance, java.io.Serializable, java.lang.Cloneable

public class RectangleRoi
extends Roi

A rectangular region of interest and superclass for the other ROI classes.

See Also:
Serialized Form

Field Summary
static java.awt.BasicStroke onePixelWide
           
static Roi previousRoi
           
 
Fields inherited from class ij.gui.Roi
roundRect
 
Fields inherited from interface ij.gui.RoiConstance
ADD_TO_ROI, ANGLE, COMPOSITE, CONSTRUCTING, DRAW_HANDLE, EVT_HANDLE_SIZE, FILL_HANDLE, FREELINE, FREEROI, HANDLE_SIZE, LINE, MOVING, MOVING_HANDLE, MOVING_ROUNDRECT_HANDLE, NO_MODS, NORMAL, NOT_PASTING, OVAL, POINT, POLYGON, POLYLINE, RECTANGLE, RESIZING, SUBTRACT_FROM_ROI, TRACED_ROI
 
Constructor Summary
RectangleRoi(double x, double y, double width, double height)
          Creates a rectangular ROI using double arguments.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this roi.
 boolean contains(int x, int y)
           
 void draw(java.awt.Graphics g)
           
 void drawHandle(java.awt.Graphics g, int x, int y)
           
 void drawOverlay(java.awt.Graphics g)
           
 void drawPixels()
          Deprecated. replaced by drawPixels(ImageProcessor)
 void drawPixels(ImageProcessor ip)
          Draws the selection outline on the specified ImageProcessor.
 void drawPixels(ImageProcessor ip, java.awt.geom.GeneralPath path)
          Draws the selection outline on the specified ImageProcessor.
 boolean equals(java.lang.Object obj)
          Checks whether two rectangles are equal.
 java.awt.Rectangle getBoundingRect()
          Deprecated. replaced by getBounds()
 java.awt.Rectangle getBounds()
          Return this selection's bounding rectangle.
static int getCurrentPasteMode()
          Returns the current paste transfer mode.
 boolean getDrawOffset()
          Returns true if this is a PolygonRoi that supports sub-pixel resolution and polygons are drawn on zoomed images offset down and to the right by 0.5 pixels..
 java.awt.geom.Rectangle2D.Double getFloatBounds()
          Return this selection's bounding rectangle.
 FloatPolygon getFloatPolygon()
           
 int getHandleSize()
           
 ImagePlus getImage()
          Returns the ImagePlus associated with this ROI, or null.
 int getImageID()
          Returns the ID of the image associated with this ROI.
 double getLength()
          Returns the perimeter length.
 ImageProcessor getMask()
          Always returns null for rectangular Roi's
 int getPasteMode()
          Returns the current paste transfer mode, or NOT_PASTING (-1) if no paste operation is in progress.
 java.awt.Polygon getPolygon()
          Returns the outline of this selection as a Polygon, or null if this is a straight line selection.
 Overlay getPrototypeOverlay()
           
 int getState()
           
 int getType()
           
 java.lang.String getTypeAsString()
          Convenience method that converts Roi type to a human-readable form.
 boolean isArea()
          Returns 'true' if this is an area selection.
 boolean isDrawingTool()
          Returns 'true' if this is an ROI primarily used from drawing (e.g., TextRoi or Arrow).
 int isHandle(int sx, int sy)
          Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.
 boolean isLine()
          Returns 'true' if this is a line selection.
 boolean isVisible()
          Returns true if this ROI is currently displayed on an image.
 void nudge(int key)
          Nudge ROI one pixel on arrow key press.
 void nudgeCorner(int key)
          Nudge lower right corner of rectangular and oval ROIs by one pixel based on arrow key press.
 void setDrawOffset(boolean drawOffset)
           
 void setImage(ImagePlus imp)
           
 void setInstanceColor(java.awt.Color c)
          Deprecated. replaced by setStrokeColor()
 void setLineWidth(int width)
          Deprecated. replaced by setStrokeWidth(int)
 void setLocation(int x, int y)
          Set the location of the ROI in image coordinates.
 void setNonScalable(boolean nonScalable)
          Set 'nonScalable' true to have TextRois in a display list drawn at a fixed location and size.
static void setPasteMode(int transferMode)
          Sets the Paste transfer mode.
 void setPrototypeOverlay(Overlay overlay)
           
 boolean subPixelResolution()
          Returns true if this is a PolygonRoi that supports sub-pixel resolution.
 java.lang.String toString()
           
 void update(boolean add, boolean subtract)
          If 'add' is true, adds this selection to the previous one.
 void updateWideLine(float width)
           
 
Methods inherited from class ij.gui.Roi
abortPaste, drawfillOverlay, drawRoiHandle, drawStroke, endPaste, fillRoiHandle, getCornerDiameter, getRoundRectArcSize, setCornerDiameter, setRoundRectArcSize, startPaste, temporarilyHide, toFloat, toInt, toInt, toIntR
 
Methods inherited from class ij.gui.AttributeRoi
copyAttributes, getAngle, getColor, getConvexHull, getCPosition, getDefaultFillColor, getFeretsDiameter, getFeretValues, getFillColor, getName, getPosition, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getZPosition, setColor, setDefaultFillColor, setFillColor, setName, setPosition, setPosition, setStroke, setStrokeColor, setStrokeWidth, setStrokeWidth
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

previousRoi

public static Roi previousRoi

onePixelWide

public static final java.awt.BasicStroke onePixelWide
Constructor Detail

RectangleRoi

public RectangleRoi(double x,
                    double y,
                    double width,
                    double height)
Creates a rectangular ROI using double arguments.

Method Detail

setLocation

public void setLocation(int x,
                        int y)
Set the location of the ROI in image coordinates.

Specified by:
setLocation in interface RoiBeans
Overrides:
setLocation in class Roi

setImage

public void setImage(ImagePlus imp)
Specified by:
setImage in interface RoiBeans
Overrides:
setImage in class Roi

getImage

public ImagePlus getImage()
Returns the ImagePlus associated with this ROI, or null.

Specified by:
getImage in interface RoiBeans
Overrides:
getImage in class AttributeRoi

getImageID

public int getImageID()
Returns the ID of the image associated with this ROI.

Specified by:
getImageID in interface RoiBeans
Overrides:
getImageID in class AttributeRoi

getType

public int getType()
Specified by:
getType in interface RoiBeans
Overrides:
getType in class AttributeRoi

getState

public int getState()
Specified by:
getState in interface RoiBeans
Overrides:
getState in class Roi

getLength

public double getLength()
Returns the perimeter length.

Specified by:
getLength in interface RoiBeans
Overrides:
getLength in class Roi

getBounds

public java.awt.Rectangle getBounds()
Return this selection's bounding rectangle.

Specified by:
getBounds in interface RoiBeans
Overrides:
getBounds in class Roi

getFloatBounds

public java.awt.geom.Rectangle2D.Double getFloatBounds()
Return this selection's bounding rectangle.

Specified by:
getFloatBounds in interface RoiBeans
Overrides:
getFloatBounds in class Roi

getBoundingRect

public java.awt.Rectangle getBoundingRect()
Deprecated. replaced by getBounds()

Specified by:
getBoundingRect in interface RoiBeans
Overrides:
getBoundingRect in class Roi

getPolygon

public java.awt.Polygon getPolygon()
Returns the outline of this selection as a Polygon, or null if this is a straight line selection.

Specified by:
getPolygon in interface RoiBeans
Overrides:
getPolygon in class Roi
See Also:
ImageProcessor.setRoi(java.awt.Rectangle), ImageProcessor.drawPolygon(java.awt.Polygon), ImageProcessor.fillPolygon(java.awt.Polygon)

getFloatPolygon

public FloatPolygon getFloatPolygon()
Specified by:
getFloatPolygon in interface RoiBeans
Overrides:
getFloatPolygon in class Roi

nudge

public void nudge(int key)
Nudge ROI one pixel on arrow key press.

Specified by:
nudge in interface RoiBeans
Overrides:
nudge in class Roi

nudgeCorner

public void nudgeCorner(int key)
Nudge lower right corner of rectangular and oval ROIs by one pixel based on arrow key press.

Specified by:
nudgeCorner in interface RoiBeans
Overrides:
nudgeCorner in class Roi

getHandleSize

public int getHandleSize()
Specified by:
getHandleSize in interface RoiBeans
Overrides:
getHandleSize in class Roi

draw

public void draw(java.awt.Graphics g)
Specified by:
draw in interface RoiBeans
Overrides:
draw in class Roi

drawOverlay

public void drawOverlay(java.awt.Graphics g)
Specified by:
drawOverlay in interface RoiBeans
Overrides:
drawOverlay in class Roi

drawHandle

public void drawHandle(java.awt.Graphics g,
                       int x,
                       int y)
Specified by:
drawHandle in interface RoiBeans
Overrides:
drawHandle in class Roi

drawPixels

public void drawPixels()
Deprecated. replaced by drawPixels(ImageProcessor)

Specified by:
drawPixels in interface RoiBeans
Overrides:
drawPixels in class Roi

drawPixels

public void drawPixels(ImageProcessor ip)
Draws the selection outline on the specified ImageProcessor.

Specified by:
drawPixels in interface RoiBeans
Overrides:
drawPixels in class Roi
See Also:
ImageProcessor.setColor(java.awt.Color), ImageProcessor.setLineWidth(int)

drawPixels

public void drawPixels(ImageProcessor ip,
                       java.awt.geom.GeneralPath path)
Draws the selection outline on the specified ImageProcessor.

Overrides:
drawPixels in class Roi
See Also:
ImageProcessor.setColor(java.awt.Color), ImageProcessor.setLineWidth(int)

contains

public boolean contains(int x,
                        int y)
Specified by:
contains in interface RoiBeans
Overrides:
contains in class Roi

isHandle

public int isHandle(int sx,
                    int sy)
Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.

Specified by:
isHandle in interface RoiBeans
Overrides:
isHandle in class Roi

update

public void update(boolean add,
                   boolean subtract)
If 'add' is true, adds this selection to the previous one. If 'subtract' is true, subtracts it from the previous selection. Called by the IJ.doWand() method, and the makeRectangle(), makeOval(), makePolygon() and makeSelection() macro functions.

Specified by:
update in interface RoiBeans
Overrides:
update in class Roi

getMask

public ImageProcessor getMask()
Always returns null for rectangular Roi's

Specified by:
getMask in interface RoiBeans
Overrides:
getMask in class Roi

setInstanceColor

public void setInstanceColor(java.awt.Color c)
Deprecated. replaced by setStrokeColor()

Specified by:
setInstanceColor in interface RoiBeans
Overrides:
setInstanceColor in class Roi

setLineWidth

public void setLineWidth(int width)
Deprecated. replaced by setStrokeWidth(int)

Specified by:
setLineWidth in interface RoiBeans
Overrides:
setLineWidth in class Roi

updateWideLine

public void updateWideLine(float width)
Specified by:
updateWideLine in interface RoiBeans
Overrides:
updateWideLine in class Roi

setNonScalable

public void setNonScalable(boolean nonScalable)
Set 'nonScalable' true to have TextRois in a display list drawn at a fixed location and size.

Specified by:
setNonScalable in interface RoiBeans
Overrides:
setNonScalable in class Roi

setPrototypeOverlay

public void setPrototypeOverlay(Overlay overlay)
Specified by:
setPrototypeOverlay in interface RoiBeans
Overrides:
setPrototypeOverlay in class Roi

getPrototypeOverlay

public Overlay getPrototypeOverlay()
Specified by:
getPrototypeOverlay in interface RoiBeans
Overrides:
getPrototypeOverlay in class Roi

setPasteMode

public static void setPasteMode(int transferMode)
Sets the Paste transfer mode.

See Also:
Blitter

getPasteMode

public int getPasteMode()
Returns the current paste transfer mode, or NOT_PASTING (-1) if no paste operation is in progress.

Specified by:
getPasteMode in interface RoiBeans
Overrides:
getPasteMode in class Roi
See Also:
Blitter

getCurrentPasteMode

public static int getCurrentPasteMode()
Returns the current paste transfer mode.


isArea

public boolean isArea()
Returns 'true' if this is an area selection.

Specified by:
isArea in interface RoiBeans
Overrides:
isArea in class Roi

isLine

public boolean isLine()
Returns 'true' if this is a line selection.

Specified by:
isLine in interface RoiBeans
Overrides:
isLine in class Roi

isDrawingTool

public boolean isDrawingTool()
Returns 'true' if this is an ROI primarily used from drawing (e.g., TextRoi or Arrow).

Specified by:
isDrawingTool in interface RoiBeans
Overrides:
isDrawingTool in class Roi

getTypeAsString

public java.lang.String getTypeAsString()
Convenience method that converts Roi type to a human-readable form.

Specified by:
getTypeAsString in interface RoiBeans
Overrides:
getTypeAsString in class Roi

isVisible

public boolean isVisible()
Returns true if this ROI is currently displayed on an image.

Specified by:
isVisible in interface RoiBeans
Overrides:
isVisible in class Roi

subPixelResolution

public boolean subPixelResolution()
Returns true if this is a PolygonRoi that supports sub-pixel resolution.

Specified by:
subPixelResolution in interface RoiBeans
Overrides:
subPixelResolution in class Roi

getDrawOffset

public boolean getDrawOffset()
Returns true if this is a PolygonRoi that supports sub-pixel resolution and polygons are drawn on zoomed images offset down and to the right by 0.5 pixels..

Specified by:
getDrawOffset in interface RoiBeans
Overrides:
getDrawOffset in class Roi

setDrawOffset

public void setDrawOffset(boolean drawOffset)
Specified by:
setDrawOffset in interface RoiBeans
Overrides:
setDrawOffset in class Roi

clone

public java.lang.Object clone()
Returns a copy of this roi. See Thinking is Java by Bruce Eckel (www.eckelobjects.com) for a good description of object cloning.

Overrides:
clone in class Roi

equals

public boolean equals(java.lang.Object obj)
Checks whether two rectangles are equal.

Specified by:
equals in interface RoiBeans
Overrides:
equals in class Roi

toString

public java.lang.String toString()
Specified by:
toString in interface RoiBeans
Overrides:
toString in class Roi