|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.Rectangle
dods.clients.importwizard.TMAP.map.MapTool
public abstract class MapTool
A rectangular map tool defined by x, y, width and height.
This abstract superclass defines a rectangular tool with
nine ToolHandles (small rectangles) which allow
reshaping and repositioning of the tool on a MapCanvas.
The abstract
method which makes this class
abstract is the draw(Graphics g)
method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D |
---|
Rectangle2D.Double, Rectangle2D.Float |
Field Summary | |
---|---|
protected boolean |
active
Returns true if the tool is "active". |
protected boolean |
bottom_edge_scroll
|
protected Rectangle |
boundingRect
The bounding rectangle in which this tool moves freely. |
protected Rectangle |
canvas_clipRect
The area of the map canvas occupied by the map. |
protected Color |
color
The color of the tool. |
double |
delta_X
Delta for this tool in "user" values. |
double |
delta_Y
Delta for this tool in "user" values. |
protected boolean |
drawHandles
Whether the tool handles should be drawn or not. |
MapGrid |
grid
The grid on which this tool acts. |
protected ToolHandle[] |
handle
The array of handles for this tool. |
protected boolean |
left_edge_scroll
|
protected int |
mouseDownHandle
The handle type to return when mouseDown doesn't activate one of the handles. |
boolean |
needsRange_X
Whether or not the tool should always have a range of values along the X axis. |
boolean |
needsRange_Y
Whether or not the tool should always have a range of values along the Y axis. |
protected int |
numHandles
The number of handles in this tool. |
double[] |
range_X
Range for this tool in "user" values. |
double[] |
range_Y
Range for this tool in "user" values. |
protected boolean |
right_edge_scroll
|
protected boolean |
snap_X
Whether the tool snaps to the underlying grid or not. |
protected boolean |
snap_Y
Whether the tool snaps to the underlying grid or not. |
protected boolean |
top_edge_scroll
|
double[] |
user_X
Current "user" values for the left, middle and right edges of this tool. |
double[] |
user_Y
Current "user" values for the bottom, middle and top edges of this tool. |
Fields inherited from class java.awt.Rectangle |
---|
height, width, x, y |
Fields inherited from class java.awt.geom.Rectangle2D |
---|
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP |
Fields inherited from interface dods.clients.importwizard.TMAP.map.MapConstants |
---|
DEPTH_AXIS, HEIGHT_AXIS, HI, LATITUDE_AXIS, LO, LONGITUDE_AXIS, MID, PT, SNAP_MID, SNAP_ON, TIME_AXIS |
Constructor Summary | |
---|---|
MapTool()
Constructs a new MapTool. |
|
MapTool(Dimension d,
Color color)
Constructs a MapTool and initializes it with the specified parameters. |
|
MapTool(int width,
int height,
Color color)
Constructs a MapTool and initializes it with the specified parameters. |
|
MapTool(int x,
int y,
int width,
int height,
Color color)
Constructs and initializes a MapTool with the specified parameters. |
|
MapTool(Point p,
Color color)
Constructs a MapTool and initializes it with the specified parameters. |
|
MapTool(Point p,
Dimension d,
Color color)
Constructs a MapTool and initializes it with a specified parameters. |
|
MapTool(Rectangle rect,
Color color)
Constructs a MapTool and initializes it with the specified parameters. |
Method Summary | |
---|---|
void |
adjustWidthHeight()
Adjust the width or height for those tools which don't specify an extent of width or height. |
void |
applyClipRect(int c_r_x,
int c_r_y,
int c_r_width,
int c_r_height)
Sets the bounding rectangle for this tool. |
void |
applyClipRect(Rectangle rect)
Applies the canvas_clipRect after potential scrolling so that a new boundingRect can be calculated for this tool. |
void |
bump_against_sides(int mouse_x,
int mouse_y)
Allows movement of the tool within the bounding rectangle specified in applyClipRect(). |
protected int |
check_for_zero_range()
Checks to make sure that tools which require ranges along X or Y do indeed describe. |
abstract void |
draw(Graphics g)
Draws a MapTool. |
Color |
getColor()
Gets the color for this tool. |
double |
getDelta_X()
Gets delta_X for this tool. |
double |
getDelta_Y()
Gets delta_Y for this tool. |
MapGrid |
getGrid()
Returns the grid on which this tool acts. |
Rectangle |
getRectangle()
Gets the rectangle for this tool. |
boolean |
getSnap_X()
Gets snap_X for this tool. |
boolean |
getSnap_Y()
Gets snap_Y for this tool. |
void |
handle_reshape(int mouse_x,
int mouse_y)
Reshapes the tool. |
void |
intersect(int x,
int y,
int width,
int height)
Resizes the tool to the intersection of the current tool rectangle and the specified rectangle. |
boolean |
is_active()
Returns the state of the tool. |
void |
mouseDown(int mouse_x,
int mouse_y)
Notifies tool of a mouseDown event. |
void |
mouseDrag(int mouse_x,
int mouse_y)
Notifies tool of a mouseDrag event. |
int |
mouseMove(int mouse_x,
int mouse_y)
Notifies tool of a mouseMove event. |
void |
mouseUp(int mouse_x,
int mouse_y)
Notifies tool of a mouseUp event. |
protected void |
saveHandles()
Saves the current positions of all the handles. |
void |
setBounds(int x,
int y,
int width,
int height)
Reshapes the tool using pixel values |
void |
setBounds(Rectangle rect)
Reshapes the tool using a rectangle specified in pixel values |
void |
setColor(Color color)
Sets the color for this tool. |
void |
setDelta_X(double delta)
Sets delta_X for this tool in "user" coordinates. |
void |
setDelta_Y(double delta)
Sets delta_Y for this tool in "user" coordinates. |
void |
setGrid(MapGrid grid)
Sets the grid on which this tool acts. |
void |
setLocation(int x,
int y)
Moves the tool to a new x, y location interpreting x and y as pixels. |
void |
setRange_X(double lo,
double hi)
Sets the X range of this tool in "user" coordinates. |
void |
setRange_Y(double lo,
double hi)
Sets the Y range of this tool in "user" coordinates. |
void |
setSnapping(boolean snap_X,
boolean snap_Y)
Sets the "snap to grid" state. |
void |
setUser_X()
Sets the user_X values for this tool. |
void |
setUser_X(double lo,
double hi)
Sets the user_X values for this tool. |
void |
setUser_XY()
Sets the user_X/Y values for this tool. |
void |
setUser_XY(double Xlo,
double Xhi,
double Ylo,
double Yhi)
Sets the user_X/Y values for this tool. |
void |
setUser_Y()
Sets the user_Y values for this tool. |
void |
setUser_Y(double lo,
double hi)
Sets the user_Y values for this tool. |
void |
setUserBounds(double left,
double right,
double bottom,
double top)
Reshapes the tool using user values |
void |
setUserLocation(double x,
double y)
Moves the tool to a new x, y location interpreting x and y as user values on this tools grid. |
String |
toString()
Returns the String representation of the tool's values. |
Methods inherited from class java.awt.Rectangle |
---|
add, add, add, contains, contains, contains, contains, createIntersection, createUnion, equals, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setLocation, setRect, setSize, setSize, translate, union |
Methods inherited from class java.awt.geom.Rectangle2D |
---|
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union |
Methods inherited from class java.awt.geom.RectangularShape |
---|
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.Shape |
---|
contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects |
Field Detail |
---|
protected boolean left_edge_scroll
protected boolean right_edge_scroll
protected boolean top_edge_scroll
protected boolean bottom_edge_scroll
public double[] user_X
Access these values with LO
, MID
or HI
as in: user_X[LO]
.
DO NOT SET THESE VALUES. They should only be read.
public double[] user_Y
Access these values with LO
, MID
or HI
as in: user_Y[LO]
.
DO NOT SET THESE VALUES. They should only be read.
public double[] range_X
Access these values with LO
or HI
as in: range_X[LO]
.
public double[] range_Y
Access these values with LO
or HI
as in: range_Y[LO]
.
public double delta_X
public double delta_Y
protected boolean drawHandles
protected boolean snap_X
protected boolean snap_Y
public boolean needsRange_X
public boolean needsRange_Y
public MapGrid grid
protected Rectangle boundingRect
protected Rectangle canvas_clipRect
protected Color color
protected boolean active
true
if the tool is "active".
An "active" tool is one that is currently being dragged
or resized by the mouse.
protected ToolHandle[] handle
protected int numHandles
protected int mouseDownHandle
NW
).
Constructor Detail |
---|
public MapTool()
public MapTool(int x, int y, int width, int height, Color color)
x
- the x coordinatey
- the y coordinatewidth
- the width of the MapToolheight
- the height of the MapToolcolor
- the color of the MapToolpublic MapTool(Rectangle rect, Color color)
rect
- the rectangle of the MapToolcolor
- the color of the MapToolpublic MapTool(int width, int height, Color color)
width
- the width of the MapToolheight
- the height of the MapToolcolor
- the color of the MapToolpublic MapTool(Point p, Dimension d, Color color)
p
- the pointd
- dimensioncolor
- the color of the MapToolpublic MapTool(Point p, Color color)
p
- the value of the x and y coordinatecolor
- the color of the MapToolpublic MapTool(Dimension d, Color color)
d
- the value of the width and heightcolor
- the color of the MapToolMethod Detail |
---|
public String toString()
toString
in class Rectangle
public boolean is_active()
public void setSnapping(boolean snap_X, boolean snap_Y)
true
, MapTools will snap to gridpoints along these axes where gridpoints are defined by the MapGrid associated with the MapCanvas.
snap_X
- whether snapping is in effect for the X axis.snap_Y
- whether snapping is in effect for the Y axis.public boolean getSnap_X()
public boolean getSnap_Y()
public MapGrid getGrid()
public void setGrid(MapGrid grid)
new_grid
- the new gridpublic void setRange_X(double lo, double hi)
Note: If you wish to use setRange_X() to restrict the movement of the tool
then you must set modulo_X = false
in the associated
MapGrid. Otherwise the mapGrid boundingRect
restricting the tool's movement will default to the entire globe.
lo
- the "user" value of the low end of the data range along X.hi
- the "user" value of the high end of the data range along X.public void setRange_Y(double lo, double hi)
lo
- the "user" value of the low end of the data range along Y.hi
- the "user" value of the highe end of the data range along Y.public void setDelta_X(double delta)
delta
- the "user" value of of the grid spacing along X.public double getDelta_X()
public void setDelta_Y(double delta)
delta
- the "user" value of of the grid spacing along Y.public double getDelta_Y()
public void intersect(int x, int y, int width, int height)
x
- the x location in pixelsy
- the y location in pixelswidth
- the width in pixelsheight
- the height in pixelsRectangle
public void setLocation(int x, int y)
setLocation
in class Rectangle
x
- the x location in pixelsy
- the y location in pixelsRectangle
public void setUserLocation(double x, double y)
x
- the x location in user valuesy
- the y location in user values// JC_TODO: This method should do the same checks found in
// JC_TODO: setUserBounds().
public void setBounds(Rectangle rect)
setBounds
in class Rectangle
rect
- a rectangle specified in pixelsRectangle
public void setBounds(int x, int y, int width, int height)
setBounds
in class Rectangle
x
- the x location in pixelsy
- the y location in pixelswidth
- the width in pixelsheight
- the height in pixelsRectangle
public void setUserBounds(double left, double right, double bottom, double top)
left
- the left in user valuesright
- the right in user valuesbottom
- the bottom location in user valuestop
- the top location in user valuesThis method of reshaping the tool does checks against the
tool's associated grid to make sure the tool stays within
the range and domain.
public Color getColor()
public void setColor(Color color)
color
- the Color of this tool.public Rectangle getRectangle()
protected void saveHandles()
protected int check_for_zero_range()
public void applyClipRect(Rectangle rect)
rect
- the MapCanvas clipRect rectangle.public void applyClipRect(int c_r_x, int c_r_y, int c_r_width, int c_r_height)
c_r_x
- the x coordinate of the boundingRectc_r_y
- the y coordinate of the boundingRectc_r_width
- the width of the boundingRect.c_r_height
- the height of the boundingRect.public void handle_reshape(int mouse_x, int mouse_y)
mouse_x
- new mouse X position for one of the handlesmouse_y
- new mouse Y position for one of the handlespublic void setUser_XY()
public void setUser_XY(double Xlo, double Xhi, double Ylo, double Yhi)
public void setUser_X()
public void setUser_Y()
public void setUser_X(double lo, double hi)
lo
- the lower value in "user" units.hi
- the higher value in "user" units.
This method sets the user values directly rather than going through
the interpolation in the tool. Whenever map.reshape_tool() or
map.center_tool() is called, this method should be used because
we don't want to allow the possibility of the grid altering
the user values simply because the image has fewer pixels
than grid points.public void setUser_Y(double lo, double hi)
lo
- the lower value in "user" units.hi
- the higher value in "user" units.
This method sets the user values directly rather than going through
the interpolation in the tool. Whenever map.reshape_tool() or
map.center_tool() is called, this method should be used because
we don't want to allow the possibility of the grid altering
the user values simply because the image has fewer pixels
than grid points.public void adjustWidthHeight()
public abstract void draw(Graphics g)
abstract
method which makes this class abstract.
g
- the graphics context for the drawing operation.public int mouseMove(int mouse_x, int mouse_y)
Frame.MOVE_CURSOR
if the
mouse moves of the center tool handle.
mouse_x
- current mouse Xmouse_y
- current mouse Y
public void mouseDown(int mouse_x, int mouse_y)
mouse_x
- current mouse Xmouse_y
- current mouse Ypublic void mouseDrag(int mouse_x, int mouse_y)
mouse_x
- current mouse Xmouse_y
- current mouse Ypublic void mouseUp(int mouse_x, int mouse_y)
x
- current mouseXy
- current mouseYpublic void bump_against_sides(int mouse_x, int mouse_y)
x
- current mouseXy
- current mouseY
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |