Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.awt.RegionOfInterest

java.lang.Object
  |
  +--ncsa.horizon.awt.RegionOfInterest

public class RegionOfInterest
extends java.lang.Object
implements SelectionGraphics
A user-selected region of interest for a Component.

The RegionOfInterest 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 RegionOfInterest on mouse button down, extend the size on mouse drag, and return a completed RegionOfInterest on mouse up.

The RegionOfInterest 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.


Field Summary
static int CENTER
          The inside area of the bounding rectangle.
static int EAST
          The right edge of the bounding rectangle.
int height
           
static int NORTHEAST
          The top right vertex of the bounding rectangle.
static int NORTH
          The top edge of the bounding rectangle.
static int NORTHWEST
          The top left vertex of the bounding rectangle.
static int SOUTHEAST
          The bottom right vertex of the bounding rectangle.
static int SOUTH
          The bottom edge of the bounding rectangle.
static int SOUTHWEST
          The bottom left vertex of the bounding rectangle.
static int WEST
          The left edge of the bounding rectangle.
int width
           
int x
           
int y
           
 
Constructor Summary
RegionOfInterest()
          Create a RegionOfInterest in the default style and size.
RegionOfInterest(java.awt.Point p, java.awt.Component _component)
          Create a RegionOfInterest beginning at the specified point.
RegionOfInterest(int _x, int _y, java.awt.Component _component)
          Create a RegionOfInterest beginning at the specified point.
RegionOfInterest(int _x, int _y, int _width, int _height, java.awt.Component _component)
          Create a RegionOfInterest beginning with the specified vertex and dimensions.
RegionOfInterest(java.awt.Component _component)
          Create a RegionOfInterest for a given component.
 
Method Summary
java.lang.String directionString(int _direction)
          Translate a direction integer to a String representation.
void drag(int _x, int _y)
          Drag this RegionOfInterest to a given location.
void draw(java.awt.Graphics g)
          Draw the RegionOfInterest at its current location.
void drop(int _x, int _y)
          Drop this Region Of Interest.
java.awt.Color getColor()
          Get the color of this RegionOfInterest.
java.awt.Point getOrigin()
          get the location of the Marker.
java.awt.Rectangle getRect()
          return the Rectangle described by this region.
java.awt.Dimension getSize()
          get the size of the Marker
int getStyle()
          Get the style of this RegionOfInterest.
int getThickness()
          Get the current RegionOfInterest line thickness.
java.awt.Rectangle getTrueRectangle()
          return the current region as a rectable with positive length sides
static java.awt.Rectangle getTrueRectangle(java.awt.Rectangle rec)
           
void grab(int _x, int _y)
          Grab this RegionOfInterest in preparation for dragging or resizing.
void grow(int _x, int _y)
          Adjust the width and height in the current direction.
void hide()
          Deprecated. Hide the RegionOfInterest from view.
boolean isActive()
          Indicate whether the RegionOfInterest has been completed.
boolean isGrabbed()
          Indicate whether the RegionOfInterest has been grabbed.
boolean isInitialized()
          Indicate whether the RegionOfInterest has been initialized but not completed.
boolean isResizable()
          Indicates whether this RegionOfInterest is resizable.
boolean isVisible()
          Indicate whether the RegionOfInterest is visible.
void move(int _x, int _y)
          Move this RegionOfInterest to the coordinate (x,y) in the parent's coordinate space.
int on(int _x, int _y, int _pad)
          Determines if the specified (x,y) location is on or inside this component.
void resize(java.awt.Dimension _dim)
          Deprecated. Resize the RegionOfInterest to the width and height specified by the dimension argument.
void resize(int _width, int _height)
          Deprecated. Resize the RegionOfInterest to the width and height specified.
void setColor(java.awt.Color _color)
          Set the color for this RegionOfInterest.
void setComponent(java.awt.Component _component)
          Set the component to attach this RegionOfInterest to.
void setOrigin(java.awt.Point p)
          set the location of the Marker.
void setResizable(boolean resizable)
          Determines whether this RegionOfInterest should be resizable.
void setSize(java.awt.Dimension d)
          set the size of the Marker
void setSize(int width, int height)
          set the size of the Marker
void setStyle(int _style)
          Set the style for this RegionOfInterest.
void setThickness(int _thickness)
          Set the line thickness to use.
void setVisible(boolean b)
          set whether the region is visible
void show()
          Deprecated. Show the RegionOfInterest.
void show(boolean cond)
          Deprecated. If the boolean argument is true, makes the RegionOfInterest visible.
java.awt.Dimension size()
          Deprecated. Resize the RegionOfInterest to the width and height specified by the dimension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

x

protected int x

y

protected int y

width

protected int width

height

protected int height

CENTER

public static final int CENTER
The inside area of the bounding rectangle.

NORTH

public static final int NORTH
The top edge of the bounding rectangle.

NORTHEAST

public static final int NORTHEAST
The top right vertex of the bounding rectangle.

EAST

public static final int EAST
The right edge of the bounding rectangle.

SOUTHEAST

public static final int SOUTHEAST
The bottom right vertex of the bounding rectangle.

SOUTH

public static final int SOUTH
The bottom edge of the bounding rectangle.

SOUTHWEST

public static final int SOUTHWEST
The bottom left vertex of the bounding rectangle.

WEST

public static final int WEST
The left edge of the bounding rectangle.

NORTHWEST

public static final int NORTHWEST
The top left vertex of the bounding rectangle.
Constructor Detail

RegionOfInterest

public RegionOfInterest()
Create a RegionOfInterest in the default style and size.

RegionOfInterest

public RegionOfInterest(java.awt.Point p,
                        java.awt.Component _component)
Create a RegionOfInterest beginning at the specified point.
Parameters:
p - The point defining a vertex of the region.
_component - The component to attach the RegionOfInterest to.

RegionOfInterest

public RegionOfInterest(int _x,
                        int _y,
                        java.awt.Component _component)
Create a RegionOfInterest 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 RegionOfInterest to.

RegionOfInterest

public RegionOfInterest(int _x,
                        int _y,
                        int _width,
                        int _height,
                        java.awt.Component _component)
Create a RegionOfInterest 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 RegionOfInterest to.

RegionOfInterest

public RegionOfInterest(java.awt.Component _component)
Create a RegionOfInterest for a given component.
Parameters:
_component - The component to attach the RegionOfInterest to.
Method Detail

draw

public void draw(java.awt.Graphics g)
Draw the RegionOfInterest at its current location. It is the responsibility of the applet/application to draw the RegionOfInterest 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 RegionOfInterest in preparation for dragging or resizing.

drag

public void drag(int _x,
                 int _y)
Drag this RegionOfInterest 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 RegionOfInterest to the coordinate (x,y) in the parent's coordinate space. This calls the repaint() method of the RegionOfInterest's component, which is ultimately responsible for calling the RegionOfInterest's draw() method.
Parameters:
_x - the x coordinate
_y - the y coordinate

setVisible

public void setVisible(boolean b)
set whether the region is visible
Specified by:
setVisible in interface SelectionGraphics

hide

public void hide()
Deprecated. use setVisible()
Hide the RegionOfInterest from view.

show

public void show()
Deprecated. use setVisible()
Show the RegionOfInterest.

show

public void show(boolean cond)
Deprecated. use setVisible()
If the boolean argument is true, makes the RegionOfInterest visible. If false, makes the RegionOfInterest invisible.
Parameters:
cond - if true, show the RegionOfInterest; if false, hide the RegionOfInterest.

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.

getSize

public java.awt.Dimension getSize()
get the size of the Marker
Specified by:
getSize in interface SelectionGraphics

setSize

public void setSize(java.awt.Dimension d)
set the size of the Marker
Specified by:
setSize in interface SelectionGraphics

setSize

public void setSize(int width,
                    int height)
set the size of the Marker

size

public java.awt.Dimension size()
Deprecated. use getSize() instead
Resize the RegionOfInterest to the width and height specified by the dimension
Returns:
The current size of this RegionOfInterest.

resize

public void resize(java.awt.Dimension _dim)
Deprecated. use setSize() instead
Resize the RegionOfInterest to the width and height specified by the dimension argument.
Parameters:
_dim - The new dimension of this RegionOfInterest.

resize

public void resize(int _width,
                   int _height)
Deprecated. use setSize() instead
Resize the RegionOfInterest to the width and height specified.
Parameters:
_width - The new width of this RegionOfInterest.
_height - The new height of this RegionOfInterest.

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 RegionOfInterest for determining on-ness insideness.
Returns:
int A direction constant indicating the postion of the (x,y) location of the region box; otherwise 0.

getOrigin

public java.awt.Point getOrigin()
get the location of the Marker.
Specified by:
getOrigin in interface SelectionGraphics

setOrigin

public void setOrigin(java.awt.Point p)
set the location of the Marker. This is equivalent to move().
Specified by:
setOrigin in interface SelectionGraphics

getRect

public java.awt.Rectangle getRect()
return the Rectangle described by this region.
Returns:
The Rectangle described by this region.

isInitialized

public boolean isInitialized()
Indicate whether the RegionOfInterest has been initialized but not completed.
Returns:
boolean true if this RegionOfInterest has been initialized but not completed.

isActive

public boolean isActive()
Indicate whether the RegionOfInterest has been completed.
Returns:
boolean true if this RegionOfInterest has been completed.

isVisible

public boolean isVisible()
Indicate whether the RegionOfInterest is visible.
Specified by:
isVisible in interface SelectionGraphics
Returns:
boolean true if this RegionOfInterest is showing; false if it is hidden.
See Also:
show

isGrabbed

public boolean isGrabbed()
Indicate whether the RegionOfInterest has been grabbed.
Returns:
boolean true if this RegionOfInterest has been grabbed; otherwise false
See Also:
grab, drop

setComponent

public void setComponent(java.awt.Component _component)
Set the component to attach this RegionOfInterest to.
Parameters:
_component - The component to attach the RegionOfInterest to.

setStyle

public void setStyle(int _style)
Set the style for this RegionOfInterest.
Parameters:
_style - The style to use for the RegionOfInterest.

getStyle

public int getStyle()
Get the style of this RegionOfInterest.
Returns:
The style of the RegionOfInterest.

setColor

public void setColor(java.awt.Color _color)
Set the color for this RegionOfInterest.
Specified by:
setColor in interface SelectionGraphics
Parameters:
_color - The Color to use to draw the RegionOfInterest.

getColor

public java.awt.Color getColor()
Get the color of this RegionOfInterest.
Specified by:
getColor in interface SelectionGraphics
Returns:
The Color used to draw the RegionOfInterest.

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 RegionOfInterests, and the size of the center portion of open- and bullseye-style RegionOfInterests.
Specified by:
setThickness in interface SelectionGraphics
Parameters:
_thickness - The thickness of the RegionOfInterest elements.

getThickness

public int getThickness()
Get the current RegionOfInterest line thickness.
Specified by:
getThickness in interface SelectionGraphics
Returns:
The thicknes of the RegionOfInterest elements.

isResizable

public boolean isResizable()
Indicates whether this RegionOfInterest is resizable. By default, an RegionOfInterest is resizable.
Returns:
true if this RegionOfInterest can be resized; false otherwise

setResizable

public void setResizable(boolean resizable)
Determines whether this RegionOfInterest should be resizable. By default, an RegionOfInterest is resizable.
Parameters:
resizable - true if this RegionOfInterest should be resizable; false otherwise

directionString

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

getTrueRectangle

public java.awt.Rectangle getTrueRectangle()
return the current region as a rectable with positive length sides

getTrueRectangle

public static java.awt.Rectangle getTrueRectangle(java.awt.Rectangle rec)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD