    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class ncsa.horizon.awt.ROI

    java.lang.Object
       |
       +----java.awt.Rectangle
               |
               +----ncsa.horizon.awt.ROI

public class ROI
extends Rectangle

A user-selected Region of Interest for a Component. The ROI can be created, moved, resized, etc. by calling the appropriate methods. It is up to the calling application to implement the user action interface to the routines. E.g., create the ROI on mouse button down, extend the size on mouse drag, and return a completed ROI on mouse up.

The ROI neither generates nor receives events. It can be thought of as a simple decorational widget than knows its location and state, can draw itself given a graphics context, and can be manipulated and queried through method calls.

##

CENTER
  The inside area of the bounding rectangle.
EAST
  The right edge of the bounding rectangle.
NORTH
  The top edge of the bounding rectangle.
NORTHEAST
  The top right vertex of the bounding rectangle.
NORTHWEST
  The top left vertex of the bounding rectangle.
SOUTH
  The bottom edge of the bounding rectangle.
SOUTHEAST
  The bottom right vertex of the bounding rectangle.
SOUTHWEST
  The bottom left vertex of the bounding rectangle.
WEST
  The left edge of the bounding rectangle.

##

ROI()
  Create a ROI in the default style and size.
ROI(Component)
  Create a ROI for a given component.
ROI(int, int, Component)
  Create a ROI beginning at the specified point.
ROI(int, int, int, int, Component)
  Create a ROI beginning with the specified vertex and dimensions.
ROI(Point, Component)
  Create a ROI beginning at the specified point.

##

directionString(int)
  Translate a direction integer to a String representation.
drag(int, int)
  Drag this ROI to a given location.
draw(Graphics)
  Draw the ROI at its current location.
drop(int, int)
  Drop this Region Of Interest.
getColor()
  Get the color of this ROI.
getRect()
  return the Rectangle described by this region.
getStyle()
  Get the style of this ROI.
getThickness()
  Get the current ROI line thickness.
grab(int, int)
  Grab this ROI in preparation for dragging or resizing.
grow(int, int)
  Adjust the width and height in the current direction.
hide()
  Hide the ROI from view.
isActive()
  Indicate whether the ROI has been completed.
isGrabbed()
  Indicate whether the ROI has been grabbed.
isInitialized()
  Indicate whether the ROI has been initialized but not completed.
isResizable()
  Indicates whether this ROI is resizable.
isVisible()
  Indicate whether the ROI is visible.
move(int, int)
  Move this ROI to the coordinate (x,y) in the parent's coordinate space.
on(int, int, int)
  Determines if the specified (x,y) location is on or inside this component.
resize(Dimension)
  Resize the ROI to the width and height specified by the dimension argument.
resize(int, int)
  Resize the ROI to the width and height specified.
setColor(Color)
  Set the color for this ROI.
setComponent(Component)
  Set the component to attach this ROI to.
setResizable(boolean)
  Determines whether this ROI should be resizable.
setStyle(int)
  Set the style for this ROI.
setThickness(int)
  Set the line thickness to use.
show()
  Show the ROI.
show(boolean)
  If the boolean argument is true, makes the ROI visible.
size()
  Resize the ROI to the width and height specified by the dimension

##

CENTER

      public final static int CENTER

  The inside area of the bounding rectangle.

NORTH

      public final static int NORTH

  The top edge of the bounding rectangle.

NORTHEAST

      public final static int NORTHEAST

  The top right vertex of the bounding rectangle.

EAST

      public final static int EAST

  The right edge of the bounding rectangle.

SOUTHEAST

      public final static int SOUTHEAST

  The bottom right vertex of the bounding rectangle.

SOUTH

      public final static int SOUTH

  The bottom edge of the bounding rectangle.

SOUTHWEST

      public final static int SOUTHWEST

  The bottom left vertex of the bounding rectangle.

WEST

      public final static int WEST

  The left edge of the bounding rectangle.

NORTHWEST

      public final static int NORTHWEST

  The top left vertex of the bounding rectangle.

##

ROI

      public ROI()

  Create a ROI in the default style and size.

ROI

      public ROI(Point p,
                 Component _component)

  Create a ROI beginning at the specified point.
  Parameters:
    p - The point defining a vertex of the region.
    _component - The component to attach the ROI to.

ROI

      public ROI(int _x,
                 int _y,
                 Component _component)

  Create a ROI beginning at the specified point.
  Parameters:
    x - The x value of the location of one vertex of the region.
    y - The y value of the location of one vertex of the region.
    _component - The component to attach the ROI to.

ROI

      public ROI(int _x,
                 int _y,
                 int _width,
                 int _height,
                 Component _component)

  Create a ROI beginning with the specified vertex and dimensions.
  Parameters:
    x - The x value of the location of one vertex of the region.
    y - The y value of the location of one vertex of the region.
    width - The width of the region.
    height - The height of the region.
    _component - The component to attach the ROI to.

ROI

      public ROI(Component _component)

  Create a ROI for a given component.
  Parameters:
    _component - The component to attach the ROI to.

##

draw

      public void draw(Graphics g)

  Draw the ROI at its current location. It is the responsibility of the applet/application to draw the ROI at the appropriate times, e.g., inside the component's update() and/or paint() method. This gives maximum flexibility for double buffering, etc.
  Parameters:
    g - The Graphics context to use for drawing.

grab

      public void grab(int _x,
                       int _y)

  Grab this ROI in preparation for dragging or resizing.

drag

      public void drag(int _x,
                       int _y)

  Drag this ROI to a given location.
  Parameters:
    _x - the x coordinate.
    _y - the y coordinate.

drop

      public void drop(int _x,
                       int _y)

  Drop this Region Of Interest. Depending on region state, this can mean either finish creating a new region, ending a region move, or ending a resize operation.
  Parameters:
    _x - The x coordinate.
    _y - The y coordinate.

move

      public void move(int _x,
                       int _y)

  Move this ROI to the coordinate (x,y) in the parent's coordinate space. This calls the repaint() method of the ROI's component, which is ultimately responsible for calling the ROI's draw() method.
  Parameters:
    _x - the x coordinate
    _y - the y coordinate
  Overrides:
    move in class Rectangle

hide

      public void hide()

  Hide the ROI from view.

show

      public void show()

  Show the ROI.

show

      public void show(boolean cond)

  If the boolean argument is true, makes the ROI visible. If false, makes the ROI invisible.
  Parameters:
    cond - if true, show the ROI; if false, hide the ROI.

grow

      public void grow(int _x,
                       int _y)

  Adjust the width and height in the current direction. Overrides the superclass method to handle single-direction growth and negative width/height.
  Parameters:
    x - The x value of the new location.
    y - The y value of the new location.
  Overrides:
    grow in class Rectangle

size

      public Dimension size()

  Resize the ROI to the width and height specified by the dimension
  Returns:
    The current size of this ROI.

resize

      public void resize(Dimension _dim)

  Resize the ROI to the width and height specified by the dimension argument.
  Parameters:
    _dim - The new dimension of this ROI.

resize

      public void resize(int _width,
                         int _height)

  Resize the ROI to the width and height specified.
  Parameters:
    _width - The new width of this ROI.
    _height - The new height of this ROI.
  Overrides:
    resize in class Rectangle

on

      public int on(int _x,
                    int _y,
                    int _pad)

  Determines if the specified (x,y) location is on or inside this component. This method is used for resize or move operations on the region.
  Parameters:
    _x - The x coordinate
    _y - The y coordinate
    _pad - The pad value. This amount is added to each side of the bounding box of the ROI for determining on-ness insideness.
  Returns:
    A direction constant indicating the postion of the (x,y) location of the region box; otherwise 0.

getRect

      public Rectangle getRect()

  return the Rectangle described by this region.
  Returns:
    The Rectangle described by this region.

isInitialized

      public boolean isInitialized()

  Indicate whether the ROI has been initialized but not completed.
  Returns:
    boolean true if this ROI has been initialized but not completed.

isActive

      public boolean isActive()

  Indicate whether the ROI has been completed.
  Returns:
    boolean true if this ROI has been completed.

isVisible

      public boolean isVisible()

  Indicate whether the ROI is visible.
  Returns:
    boolean true if this ROI is showing; false if it is hidden.
  See Also:
    show

isGrabbed

      public boolean isGrabbed()

  Indicate whether the ROI has been grabbed.
  Returns:
    boolean true if this ROI has been grabbed; otherwise false
  See Also:
    grab, drop

setComponent

      public void setComponent(Component _component)

  Set the component to attach this ROI to.
  Parameters:
    _component - The component to attach the ROI to.

setStyle

      public void setStyle(int _style)

  Set the style for this ROI.
  Parameters:
    _style - The style to use for the ROI.

getStyle

      public int getStyle()

  Get the style of this ROI.
  Returns:
    The style of the ROI.

setColor

      public void setColor(Color _color)

  Set the color for this ROI.
  Parameters:
    _color - The Color to use to draw the ROI.

getColor

      public Color getColor()

  Get the color of this ROI.
  Returns:
    The Color used to draw the ROI.

setThickness

      public void setThickness(int _thickness)

  Set the line thickness to use. This controls the width of the lines that make up box- and cross-style ROIs, and the size of the center portion of open- and bullseye-style ROIs.
  Parameters:
    _thickness - The thickness of the ROI elements.

getThickness

      public int getThickness()

  Get the current ROI line thickness.
  Returns:
    The thicknes of the ROI elements.

isResizable

      public boolean isResizable()

  Indicates whether this ROI is resizable. By default, an ROI is resizable.
  Returns:
    true if this ROI can be resized; false otherwise

setResizable

      public void setResizable(boolean resizable)

  Determines whether this ROI should be resizable. By default, an ROI is resizable.
  Parameters:
    resizable - true if this ROI should be resizable; false otherwise

directionString

      public String directionString(int _direction)

  Translate a direction integer to a String representation.
  Parameters:
    _direction - An integer representation of a direction.
  Returns:
    A String describing the direction; "NONE" if out of bounds.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index