public class BaseMapTool extends AbstractCircleListener implements MapTool, java.awt.event.ActionListener, IBehavior, ToolListener, PanListener, PointListener, PolylineListener, RectangleListener
Modifier and Type | Field and Description |
---|---|
protected IBehavior |
behavior |
protected boolean |
isCancelDrawing |
protected ToolListener |
listener |
protected int |
type |
ACTION_AREA, ACTION_MEASURE, ACTION_PAN, ACTION_SELECTION, ACTION_ZOOM, EVENT_MEASURE, EVENT_MOVE, EVENT_POINT, EVENT_POINTDOUBLECLICKED, EVENT_POINTFIXED, EVENT_POINTS, EVENT_POLYLINEFINISHED, EVENT_RECTANGLE, TYPE_CIRCLE, TYPE_MOUSEDRAGGED, TYPE_MOUSEMOVENENT, TYPE_MOVE, TYPE_POINT, TYPE_POLYGON, TYPE_POLYLINE, TYPE_RECTANGLE, TYPE_UNKNOW
Constructor and Description |
---|
BaseMapTool(int type) |
BaseMapTool(ToolListener listener) |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent arg0) |
protected void |
callActionPerformed(java.lang.Object event,
int type,
java.lang.String actionCommand) |
boolean |
cancelDrawing()
Determines if the drawing process that this tool executes on the
MapControl
instance could be canceled or not. |
void |
circle(MeasureEvent event)
Called when user defines a circular area.
|
java.awt.Image |
getImageCursor()
Gets the mouse cursor of the tool listener associated to this behavior.
|
ToolListener |
getListener()
Gets the
ToolListener used by this behavior to perform actions on the
associated MapControl object. |
MapControl |
getMapControl()
Returns the reference to the
MapControl object that this behavior uses. |
java.lang.String |
getName() |
int |
getType() |
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e) |
void |
move(MoveEvent event)
Called when user drags the mouse on the view.
|
void |
paintComponent(MapControlDrawer renderer)
Method executed in real-time, when user is working with a tool on the associated
MapControl
object, repainting the MapControl 's image. |
void |
point(PointEvent event)
Called when one click is pressed on the associated
MapControl , or the location of the cursor
of the mouse has changed on it. |
void |
pointDoubleClick(PointEvent event)
Called when a double click is pressed on the associated
MapControl . |
void |
pointFixed(MeasureEvent event)
Called when user executes a mouse click and selects a vertex of the polyline.
|
void |
points(MeasureEvent event)
Called when user moves the mouse after selecting a vertex of the polyline.
|
void |
polylineFinished(MeasureEvent event)
Called when user executes a double click with the mouse, finishing the
drawn of the polyline.
|
void |
rectangle(EnvelopeEvent event)
Called when user executes a double click with the mouse, finishing the
drawn of the rectangle.
|
void |
setMapControl(MapControl mc)
Associates this behavior to a
MapControl object. |
protected void |
setName(java.lang.String name) |
void |
setType(int type) |
circleFinished
protected int type
protected ToolListener listener
protected IBehavior behavior
protected boolean isCancelDrawing
public BaseMapTool(int type)
public BaseMapTool(ToolListener listener)
protected void setName(java.lang.String name)
public void actionPerformed(java.awt.event.ActionEvent arg0)
actionPerformed
in interface java.awt.event.ActionListener
public java.awt.Image getImageCursor()
IBehavior
Gets the mouse cursor of the tool listener associated to this behavior.
getImageCursor
in interface IBehavior
getImageCursor
in interface ToolListener
getImageCursor
in interface MapTool
public boolean cancelDrawing()
ToolListener
Determines if the drawing process that this tool executes on the MapControl
instance could be canceled or not.
cancelDrawing
in interface ToolListener
true
if is cancellable; otherwise returns false
public void setType(int type)
public MapControl getMapControl()
IBehavior
Returns the reference to the MapControl
object that this behavior uses.
getMapControl
in interface IBehavior
getMapControl
in interface MapTool
MapControl
object used this behaviorIBehavior.setMapControl(MapControl)
public void setMapControl(MapControl mc)
IBehavior
Associates this behavior to a MapControl
object.
setMapControl
in interface IBehavior
mc
- the MapControl
object to associateIBehavior.getMapControl()
public ToolListener getListener()
IBehavior
Gets the ToolListener
used by this behavior to perform actions on the
associated MapControl
object.
getListener
in interface IBehavior
ToolListener
used by this behaviorprotected void callActionPerformed(java.lang.Object event, int type, java.lang.String actionCommand)
public void rectangle(EnvelopeEvent event) throws BehaviorException
RectangleListener
Called when user executes a double click with the mouse, finishing the drawn of the rectangle.
All features of the active and vector layers of the associated MapControl
object that
their area intersect with the polygonal area defined in the event, will be selected.
rectangle
in interface RectangleListener
event
- mouse event and information about the rectangle definedBehaviorException
- will be thrown when fails the process of this toolpublic void points(MeasureEvent event) throws BehaviorException
PolylineListener
Called when user moves the mouse after selecting a vertex of the polyline.
Each kind of polyline listener calculates different information with the data of the
MeasureEvent
, according its nature.
points
in interface PolylineListener
event
- information about the mouse event, and geometry data of the polylineBehaviorException
- will be thrown when fails the process of this toolpublic void pointFixed(MeasureEvent event) throws BehaviorException
PolylineListener
Called when user executes a mouse click and selects a vertex of the polyline.
pointFixed
in interface PolylineListener
event
- information about the mouse event, and geometry data of the polylineBehaviorException
- will be thrown when fails the process of this toolpublic void polylineFinished(MeasureEvent event) throws BehaviorException
PolylineListener
Called when user executes a double click with the mouse, finishing the drawn of the polyline.
All features of the active and vector layers of the associated MapControl
object that
their area intersect with the polygonal area defined in the event, will be selected.
polylineFinished
in interface PolylineListener
event
- information about the mouse event, and geometry data of the polylineBehaviorException
- will be thrown when fails the process of this toolpublic void point(PointEvent event) throws BehaviorException
PointListener
Called when one click is pressed on the associated MapControl
, or the location of the cursor
of the mouse has changed on it.
point
in interface PointListener
event
- mouse event with the coordinates of the point selected on the associated MapControl
BehaviorException
- will be thrown when fails the process of this toolpublic void pointDoubleClick(PointEvent event) throws BehaviorException
PointListener
Called when a double click is pressed on the associated MapControl
.
pointDoubleClick
in interface PointListener
event
- mouse event and the coordinates of the point selected on the associated MapControl
BehaviorException
- will be thrown when fails the process of this toolpublic void move(MoveEvent event) throws BehaviorException
PanListener
Called when user drags the mouse on the view.
Updates the extent coordinates according to the direction of the movement between the initial and final points of line determined by the move of the mouse.
move
in interface PanListener
event
- mouse event information about the initial and final positions of the movementBehaviorException
- will be thrown when fails the process of this toolpublic void circle(MeasureEvent event) throws BehaviorException
CircleListener
Called when user defines a circular area.
circle
in interface CircleListener
event
- information about the mouse event, and geometry data related with the operation doneBehaviorException
- will be thrown when fails the process of this toolpublic void paintComponent(MapControlDrawer renderer)
IBehavior
Method executed in real-time, when user is working with a tool on the associated MapControl
object, repainting the MapControl
's image.
Returns immediately in all cases, even if the complete image has not yet been loaded.
This method will be implemented according to the specific nature of each behavior, and its extra and particular features.
paintComponent
in interface IBehavior
Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
public void mouseClicked(java.awt.event.MouseEvent e) throws BehaviorException
mouseClicked
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse clicked event, by the IBehavior
objectMouseListener.mouseClicked(java.awt.event.MouseEvent)
public void mouseEntered(java.awt.event.MouseEvent e) throws BehaviorException
mouseEntered
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse entered event, by the IBehavior
objectMouseListener.mouseEntered(java.awt.event.MouseEvent)
public void mouseExited(java.awt.event.MouseEvent e) throws BehaviorException
mouseExited
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse exited event, by the IBehavior
objectMouseListener.mouseExited(java.awt.event.MouseEvent)
public void mousePressed(java.awt.event.MouseEvent e) throws BehaviorException
mousePressed
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse pressed event, by the IBehavior
objectMouseListener.mousePressed(java.awt.event.MouseEvent)
public void mouseReleased(java.awt.event.MouseEvent e) throws BehaviorException
mouseReleased
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse released event, by the IBehavior
objectMouseListener.mouseReleased(java.awt.event.MouseEvent)
public void mouseDragged(java.awt.event.MouseEvent e) throws BehaviorException
mouseDragged
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse dragged event, by the IBehavior
objectMouseMotionListener.mouseDragged(java.awt.event.MouseEvent)
public void mouseMoved(java.awt.event.MouseEvent e) throws BehaviorException
mouseMoved
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse moved event, by the IBehavior
objectMouseMotionListener.mouseMoved(java.awt.event.MouseEvent)
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) throws BehaviorException
mouseWheelMoved
in interface IBehavior
BehaviorException
- any exception processing the action associated to a mouse wheel event, by the IBehavior
objectMouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)