Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.astro.louisville.edu/software/astroimagej/imagej/api/ij/gui/Roi.html
Дата изменения: Thu Dec 2 23:03:11 2010
Дата индексирования: Mon Oct 1 21:32:57 2012
Кодировка:
Roi (ImageJ API)

ij.gui
Class Roi

java.lang.Object
  extended by ij.gui.Roi
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ImageRoi, Line, OvalRoi, PolygonRoi, ShapeRoi, TextRoi

public class Roi
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

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

See Also:
Serialized Form

Field Summary
static int ANGLE
           
protected  double asp_bk
           
protected  boolean aspect
           
protected  ImageProcessor cachedMask
           
protected  boolean center
           
protected  ImagePlus clipboard
           
protected  int clipHeight
           
protected  int clipWidth
           
protected  int clipX
           
protected  int clipY
           
static int COMPOSITE
           
protected  boolean constrain
           
static int CONSTRUCTING
           
protected static java.awt.Color defaultFillColor
           
protected  java.awt.Color fillColor
           
static int FREELINE
           
static int FREEROI
           
static int HANDLE_SIZE
           
protected  java.awt.Color handleColor
           
protected  ImageCanvas ic
           
protected  ImagePlus imp
           
protected  java.awt.Color instanceColor
           
static int LINE
           
protected static int lineWidth
           
protected  double mag
           
static int MOVING
           
static int MOVING_HANDLE
           
protected  java.lang.String name
           
protected  boolean nonScalable
           
static int NORMAL
           
static int NOT_PASTING
           
protected  int oldHeight
           
protected  int oldWidth
           
protected  int oldX
           
protected  int oldY
           
static java.awt.BasicStroke onePixelWide
           
static int OVAL
           
protected  boolean overlay
           
protected static int pasteMode
           
static int POINT
           
static int POLYGON
           
static int POLYLINE
           
static Roi previousRoi
           
static int RECTANGLE
           
static int RESIZING
           
protected static java.awt.Color ROIColor
           
protected  java.awt.BasicStroke stroke
           
protected  java.awt.Color strokeColor
           
static int TRACED_ROI
           
protected  int type
           
protected  boolean updateFullWindow
           
protected  boolean wideLine
           
protected  int xMax
           
protected  int yMax
           
 
Constructor Summary
Roi(int sx, int sy, ImagePlus imp)
          Starts the process of creating a user-defined rectangular Roi, where sx and sy are the starting screen coordinates.
Roi(int sx, int sy, ImagePlus imp, int arcSize)
          Starts the process of creating a user-defined rectangular Roi, where sx and sy are the starting screen coordinates.
Roi(int x, int y, int width, int height)
          Creates a new rectangular Roi.
Roi(int x, int y, int width, int height, ImagePlus imp)
          Deprecated.  
Roi(int x, int y, int width, int height, int arcSize)
          Creates a new rounded rectangular Roi.
Roi(java.awt.Rectangle r)
          Creates a new rectangular Roi.
 
Method Summary
 void abortPaste()
           
protected  int clipRectMargin()
           
 java.lang.Object clone()
          Returns a copy of this roi.
 boolean contains(int x, int y)
           
 void copyAttributes(Roi roi2)
          Copy the attributes (outline color, fill color, outline width) of 'roi2' to the this selection.
 void draw(java.awt.Graphics g)
           
 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 endPaste()
           
 boolean equals(java.lang.Object obj)
          Checks whether two rectangles are equal.
 double getAngle(int x1, int y1, int x2, int y2)
          Returns the angle in degrees between the specified line and a horizontal line.
 java.awt.Rectangle getBoundingRect()
          Deprecated. replaced by getBounds()
 java.awt.Rectangle getBounds()
          Return this selection's bounding rectangle.
static java.awt.Color getColor()
          Returns the default (global) color used for drawing ROI outlines.
 java.awt.Polygon getConvexHull()
           
static int getCurrentPasteMode()
          Returns the current paste transfer mode.
static java.awt.Color getDefaultFillColor()
           
 double getFeretsDiameter()
          Returns Feret's diameter, the greatest distance between any two points along the ROI boundary.
 double[] getFeretValues()
          Caculates "Feret" (maximum caliper width), "FeretAngle" and "MinFeret" (minimum caliper width), "FeretX" and "FeretY".
 java.awt.Color getFillColor()
          Returns the the color used to fill this ROI when it is in a display, or null.
 FloatPolygon getFloatPolygon()
           
 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
 java.lang.String getName()
          Returns the name of this ROI, or null.
 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.
 int getRoundRectArcSize()
           
protected  java.awt.BasicStroke getScaledStroke()
           
 int getState()
           
 java.awt.BasicStroke getStroke()
          Returns the Stroke used to draw this ROI, or null if no Stroke is used.
 java.awt.Color getStrokeColor()
          Returns the the color used to draw the ROI outline or null if the default color is being used.
 float getStrokeWidth()
          Returns the lineWidth.
 int getType()
           
 java.lang.String getTypeAsString()
          Convenience method that converts Roi type to a human-readable form.
protected  void grow(int sx, int sy)
           
protected  void handleMouseDown(int sx, int sy)
           
protected  void handleMouseDrag(int sx, int sy, int flags)
           
protected  void handleMouseUp(int screenX, int screenY)
           
 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., Rounded Rectangle, 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.
protected  void mouseDownInHandle(int handle, int sx, int sy)
           
protected  void moveHandle(int sx, int sy)
           
 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.
static void setColor(java.awt.Color c)
          Sets the default (global) color used for ROI outlines.
static void setDefaultFillColor(java.awt.Color color)
           
 void setFillColor(java.awt.Color color)
          Sets the color used to fill ROIs when they are in an overlay.
 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 setName(java.lang.String name)
          Sets the name of this ROI.
 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 setRoundRectArcSize(int size)
          Sets the rounded rectangle arc size (pixels).
 void setStroke(java.awt.BasicStroke stroke)
          Sets the Stroke used to draw this ROI.
 void setStrokeColor(java.awt.Color c)
          Sets the color used by this ROI to draw its outline.
 void setStrokeWidth(float width)
          Sets the width of the lines used to draw this ROI when it is part of an Overlay list or ROI Manager "Show All" list.
protected  void showStatus()
           
 void startPaste(ImagePlus clipboard)
           
 java.lang.String toString()
           
 void update(boolean add, boolean subtract)
          If 'add' is true, adds this selection to the previous one.
protected  void updateClipRect()
           
 void updateWideLine(float width)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONSTRUCTING

public static final int CONSTRUCTING
See Also:
Constant Field Values

MOVING

public static final int MOVING
See Also:
Constant Field Values

RESIZING

public static final int RESIZING
See Also:
Constant Field Values

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

MOVING_HANDLE

public static final int MOVING_HANDLE
See Also:
Constant Field Values

RECTANGLE

public static final int RECTANGLE
See Also:
Constant Field Values

OVAL

public static final int OVAL
See Also:
Constant Field Values

POLYGON

public static final int POLYGON
See Also:
Constant Field Values

FREEROI

public static final int FREEROI
See Also:
Constant Field Values

TRACED_ROI

public static final int TRACED_ROI
See Also:
Constant Field Values

LINE

public static final int LINE
See Also:
Constant Field Values

POLYLINE

public static final int POLYLINE
See Also:
Constant Field Values

FREELINE

public static final int FREELINE
See Also:
Constant Field Values

ANGLE

public static final int ANGLE
See Also:
Constant Field Values

COMPOSITE

public static final int COMPOSITE
See Also:
Constant Field Values

POINT

public static final int POINT
See Also:
Constant Field Values

HANDLE_SIZE

public static final int HANDLE_SIZE
See Also:
Constant Field Values

NOT_PASTING

public static final int NOT_PASTING
See Also:
Constant Field Values

previousRoi

public static Roi previousRoi

onePixelWide

public static final java.awt.BasicStroke onePixelWide

ROIColor

protected static java.awt.Color ROIColor

pasteMode

protected static int pasteMode

lineWidth

protected static int lineWidth

defaultFillColor

protected static java.awt.Color defaultFillColor

type

protected int type

xMax

protected int xMax

yMax

protected int yMax

imp

protected ImagePlus imp

ic

protected ImageCanvas ic

oldX

protected int oldX

oldY

protected int oldY

oldWidth

protected int oldWidth

oldHeight

protected int oldHeight

clipX

protected int clipX

clipY

protected int clipY

clipWidth

protected int clipWidth

clipHeight

protected int clipHeight

clipboard

protected ImagePlus clipboard

constrain

protected boolean constrain

center

protected boolean center

aspect

protected boolean aspect

updateFullWindow

protected boolean updateFullWindow

mag

protected double mag

asp_bk

protected double asp_bk

name

protected java.lang.String name

cachedMask

protected ImageProcessor cachedMask

handleColor

protected java.awt.Color handleColor

strokeColor

protected java.awt.Color strokeColor

instanceColor

protected java.awt.Color instanceColor

fillColor

protected java.awt.Color fillColor

stroke

protected java.awt.BasicStroke stroke

nonScalable

protected boolean nonScalable

overlay

protected boolean overlay

wideLine

protected boolean wideLine
Constructor Detail

Roi

public Roi(int x,
           int y,
           int width,
           int height)
Creates a new rectangular Roi.


Roi

public Roi(int x,
           int y,
           int width,
           int height,
           int arcSize)
Creates a new rounded rectangular Roi.


Roi

public Roi(java.awt.Rectangle r)
Creates a new rectangular Roi.


Roi

public Roi(int sx,
           int sy,
           ImagePlus imp)
Starts the process of creating a user-defined rectangular Roi, where sx and sy are the starting screen coordinates.


Roi

public Roi(int sx,
           int sy,
           ImagePlus imp,
           int arcSize)
Starts the process of creating a user-defined rectangular Roi, where sx and sy are the starting screen coordinates.


Roi

public Roi(int x,
           int y,
           int width,
           int height,
           ImagePlus imp)
Deprecated. 

Method Detail

setLocation

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


setImage

public void setImage(ImagePlus imp)

getImageID

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


getType

public int getType()

getState

public int getState()

getLength

public double getLength()
Returns the perimeter length.


getFeretsDiameter

public double getFeretsDiameter()
Returns Feret's diameter, the greatest distance between any two points along the ROI boundary.


getFeretValues

public double[] getFeretValues()
Caculates "Feret" (maximum caliper width), "FeretAngle" and "MinFeret" (minimum caliper width), "FeretX" and "FeretY".


getConvexHull

public java.awt.Polygon getConvexHull()

getBounds

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


getBoundingRect

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


getPolygon

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

See Also:
ImageProcessor.setRoi(java.awt.Rectangle), ImageProcessor.drawPolygon(java.awt.Polygon), ImageProcessor.fillPolygon(java.awt.Polygon)

getFloatPolygon

public FloatPolygon getFloatPolygon()

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 java.lang.Object

grow

protected void grow(int sx,
                    int sy)

moveHandle

protected void moveHandle(int sx,
                          int sy)

nudge

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


nudgeCorner

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


updateClipRect

protected void updateClipRect()

clipRectMargin

protected int clipRectMargin()

handleMouseDrag

protected void handleMouseDrag(int sx,
                               int sy,
                               int flags)

draw

public void draw(java.awt.Graphics g)

drawOverlay

public void drawOverlay(java.awt.Graphics g)

drawPixels

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


drawPixels

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

See Also:
ImageProcessor.setColor(java.awt.Color), ImageProcessor.setLineWidth(int)

contains

public boolean contains(int x,
                        int y)

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.


mouseDownInHandle

protected void mouseDownInHandle(int handle,
                                 int sx,
                                 int sy)

handleMouseDown

protected void handleMouseDown(int sx,
                               int sy)

handleMouseUp

protected void handleMouseUp(int screenX,
                             int screenY)

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.


showStatus

protected void showStatus()

getMask

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


startPaste

public void startPaste(ImagePlus clipboard)

endPaste

public void endPaste()

abortPaste

public void abortPaste()

getAngle

public double getAngle(int x1,
                       int y1,
                       int x2,
                       int y2)
Returns the angle in degrees between the specified line and a horizontal line.


setColor

public static void setColor(java.awt.Color c)
Sets the default (global) color used for ROI outlines.

See Also:
getColor(), setStrokeColor(Color)

getColor

public static java.awt.Color getColor()
Returns the default (global) color used for drawing ROI outlines.

See Also:
setColor(Color), getStrokeColor()

setStrokeColor

public void setStrokeColor(java.awt.Color c)
Sets the color used by this ROI to draw its outline. This color, if not null, overrides the global color set by the static setColor() method.

See Also:
getStrokeColor(), #setStrokeWidth(int), ImagePlus.setOverlay(ij.gui.Overlay)

getStrokeColor

public java.awt.Color getStrokeColor()
Returns the the color used to draw the ROI outline or null if the default color is being used.

See Also:
setStrokeColor(Color)

setFillColor

public void setFillColor(java.awt.Color color)
Sets the color used to fill ROIs when they are in an overlay.

See Also:
ImagePlus.setOverlay(ij.gui.Overlay)

getFillColor

public java.awt.Color getFillColor()
Returns the the color used to fill this ROI when it is in a display, or null.

See Also:
getStrokeColor()

setDefaultFillColor

public static void setDefaultFillColor(java.awt.Color color)

getDefaultFillColor

public static java.awt.Color getDefaultFillColor()

copyAttributes

public void copyAttributes(Roi roi2)
Copy the attributes (outline color, fill color, outline width) of 'roi2' to the this selection.


setInstanceColor

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


setLineWidth

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


updateWideLine

public void updateWideLine(float width)

setNonScalable

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


setStrokeWidth

public void setStrokeWidth(float width)
Sets the width of the lines used to draw this ROI when it is part of an Overlay list or ROI Manager "Show All" list.

See Also:
setStrokeColor(Color), ImagePlus.setOverlay(ij.gui.Overlay)

getStrokeWidth

public float getStrokeWidth()
Returns the lineWidth.


setStroke

public void setStroke(java.awt.BasicStroke stroke)
Sets the Stroke used to draw this ROI.


getStroke

public java.awt.BasicStroke getStroke()
Returns the Stroke used to draw this ROI, or null if no Stroke is used.


getScaledStroke

protected java.awt.BasicStroke getScaledStroke()

getName

public java.lang.String getName()
Returns the name of this ROI, or null.


setName

public void setName(java.lang.String name)
Sets the name of this ROI.


setPasteMode

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

See Also:
Blitter

setRoundRectArcSize

public void setRoundRectArcSize(int size)
Sets the rounded rectangle arc size (pixels).


getRoundRectArcSize

public int getRoundRectArcSize()

getPasteMode

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

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.


isLine

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


isDrawingTool

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


getTypeAsString

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


isVisible

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


equals

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

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object