org.gvsig.fmap.mapcontrol.tools
Class BaseMapTool

java.lang.Object
  extended by org.gvsig.fmap.mapcontrol.tools.BaseMapTool
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, IBehavior, CircleListener, PanListener, PointListener, PolylineListener, RectangleListener, ToolListener, MapTool

public class BaseMapTool
extends java.lang.Object
implements MapTool, java.awt.event.ActionListener, IBehavior, ToolListener, CircleListener, PanListener, PointListener, PolylineListener, RectangleListener


Field Summary
protected  IBehavior behavior
           
protected  boolean isCancelDrawing
           
protected  ToolListener listener
           
protected  int type
           
 
Fields inherited from interface org.gvsig.fmap.mapcontrol.tools.MapTool
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 Summary
BaseMapTool(int type)
           
BaseMapTool(ToolListener listener)
           
 
Method Summary
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

behavior

protected IBehavior behavior

isCancelDrawing

protected boolean isCancelDrawing

listener

protected ToolListener listener

type

protected int type
Constructor Detail

BaseMapTool

public BaseMapTool(int type)

BaseMapTool

public BaseMapTool(ToolListener listener)
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent arg0)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

callActionPerformed

protected void callActionPerformed(java.lang.Object event,
                                   int type,
                                   java.lang.String actionCommand)

cancelDrawing

public boolean cancelDrawing()
Description copied from interface: ToolListener

Determines if the drawing process that this tool executes on the MapControl instance could be canceled or not.

Specified by:
cancelDrawing in interface ToolListener
Returns:
true if is cancellable; otherwise returns false

circle

public void circle(MeasureEvent event)
            throws BehaviorException
Description copied from interface: CircleListener

Called when user defines a circular area.

Specified by:
circle in interface CircleListener
Parameters:
event - information about the mouse event, and geometry data related with the operation done
Throws:
BehaviorException - will be thrown when fails the process of this tool

getImageCursor

public java.awt.Image getImageCursor()
Description copied from interface: IBehavior

Gets the mouse cursor of the tool listener associated to this behavior.

Specified by:
getImageCursor in interface IBehavior
Specified by:
getImageCursor in interface ToolListener
Specified by:
getImageCursor in interface MapTool
Returns:
the mouse cursor of the tool listener associated

getListener

public ToolListener getListener()
Description copied from interface: IBehavior

Gets the ToolListener used by this behavior to perform actions on the associated MapControl object.

Specified by:
getListener in interface IBehavior
Returns:
the ToolListener used by this behavior

getMapControl

public MapControl getMapControl()
Description copied from interface: IBehavior

Returns the reference to the MapControl object that this behavior uses.

Specified by:
getMapControl in interface IBehavior
Specified by:
getMapControl in interface MapTool
Returns:
the MapControl object used this behavior
See Also:
IBehavior.setMapControl(MapControl)

getName

public java.lang.String getName()
Specified by:
getName in interface MapTool

getType

public int getType()
Specified by:
getType in interface MapTool

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
                  throws BehaviorException
Specified by:
mouseClicked in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse clicked event, by the IBehavior object
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
                  throws BehaviorException
Specified by:
mouseDragged in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse dragged event, by the IBehavior object
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
                  throws BehaviorException
Specified by:
mouseEntered in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse entered event, by the IBehavior object
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
                 throws BehaviorException
Specified by:
mouseExited in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse exited event, by the IBehavior object
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
                throws BehaviorException
Specified by:
mouseMoved in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse moved event, by the IBehavior object
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
                  throws BehaviorException
Specified by:
mousePressed in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse pressed event, by the IBehavior object
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
                   throws BehaviorException
Specified by:
mouseReleased in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse released event, by the IBehavior object
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
                     throws BehaviorException
Specified by:
mouseWheelMoved in interface IBehavior
Throws:
BehaviorException - any exception processing the action associated to a mouse wheel event, by the IBehavior object
See Also:
MouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)

move

public void move(MoveEvent event)
          throws BehaviorException
Description copied from interface: 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.

Specified by:
move in interface PanListener
Parameters:
event - mouse event information about the initial and final positions of the movement
Throws:
BehaviorException - will be thrown when fails the process of this tool

paintComponent

public void paintComponent(MapControlDrawer renderer)
Description copied from interface: 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.

Specified by:
paintComponent in interface IBehavior
See Also:
Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)

point

public void point(PointEvent event)
           throws BehaviorException
Description copied from interface: PointListener

Called when one click is pressed on the associated MapControl, or the location of the cursor of the mouse has changed on it.

Specified by:
point in interface PointListener
Parameters:
event - mouse event with the coordinates of the point selected on the associated MapControl
Throws:
BehaviorException - will be thrown when fails the process of this tool

pointDoubleClick

public void pointDoubleClick(PointEvent event)
                      throws BehaviorException
Description copied from interface: PointListener

Called when a double click is pressed on the associated MapControl.

Specified by:
pointDoubleClick in interface PointListener
Parameters:
event - mouse event and the coordinates of the point selected on the associated MapControl
Throws:
BehaviorException - will be thrown when fails the process of this tool

pointFixed

public void pointFixed(MeasureEvent event)
                throws BehaviorException
Description copied from interface: PolylineListener

Called when user executes a mouse click and selects a vertex of the polyline.

Specified by:
pointFixed in interface PolylineListener
Parameters:
event - information about the mouse event, and geometry data of the polyline
Throws:
BehaviorException - will be thrown when fails the process of this tool

points

public void points(MeasureEvent event)
            throws BehaviorException
Description copied from interface: 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.

Specified by:
points in interface PolylineListener
Parameters:
event - information about the mouse event, and geometry data of the polyline
Throws:
BehaviorException - will be thrown when fails the process of this tool

polylineFinished

public void polylineFinished(MeasureEvent event)
                      throws BehaviorException
Description copied from interface: 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.

Specified by:
polylineFinished in interface PolylineListener
Parameters:
event - information about the mouse event, and geometry data of the polyline
Throws:
BehaviorException - will be thrown when fails the process of this tool

rectangle

public void rectangle(EnvelopeEvent event)
               throws BehaviorException
Description copied from interface: 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.

Specified by:
rectangle in interface RectangleListener
Parameters:
event - mouse event and information about the rectangle defined
Throws:
BehaviorException - will be thrown when fails the process of this tool

setMapControl

public void setMapControl(MapControl mc)
Description copied from interface: IBehavior

Associates this behavior to a MapControl object.

Specified by:
setMapControl in interface IBehavior
Parameters:
mc - the MapControl object to associate
See Also:
IBehavior.getMapControl()

setName

protected void setName(java.lang.String name)

setType

public void setType(int type)


Copyright © 2014 gvSIG Association. All Rights Reserved.