org.gvsig.fmap.mapcontrol.tools
Class CompoundBehavior

java.lang.Object
  extended by org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior
      extended by org.gvsig.fmap.mapcontrol.tools.CompoundBehavior
All Implemented Interfaces:
IBehavior

public class CompoundBehavior
extends Behavior

Allows having multiple behaviors when user works with the associated MapControl. Each one with its associated tool listener.

Author:
Fernando González Cortés, Pablo Piqueras Bartolomé

Field Summary
 
Fields inherited from class org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior
geomManager
 
Constructor Summary
CompoundBehavior(Behavior[] behaviors)
          Creates a new behavior as a composition of others.
 
Method Summary
 void addMapBehavior(Behavior mt, boolean draw)
          Adds a new behavior, setting if will be real-time (when user is working with it) drawn or not.
 boolean containsBehavior(Behavior mt)
          Searches for mt, returning true if is contained.
static Behavior getAllControlsBehavior()
          Gets the Behavior that will be used for any MapControl.
 Behavior getBehavior(int index)
          Returns the first-level Behavior at the specified position.
 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.
 boolean isDrawnBehavior(int index)
          Returns if it's invoked the method public void paintComponent(Graphics g) of the first-level Behavior at the specified position, each time is painted this component.
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void mouseWheelMoved(MouseWheelEvent e)
           
 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 removeMapBehavior(Behavior mt)
          Removes a Behavior that composes this one.
static void setAllControlsBehavior(Behavior behavior)
          Sets the Behavior that will be used for any MapControl.
 void setDrawnBehavior(int index, boolean draw)
          Sets if will be invoked the method public void paintComponent(Graphics g) of the first-level Behavior at the specified position, each time is painted this component.
 void setListener(ToolListener listener)
          Sets a tool listener to work with a MapControl instance using these behaviors.
 void setMapControl(MapControl mc)
          Associates this behavior to a MapControl object.
 int size()
          Returns the number of first-level Behaviors in this CompoundBehavior.
 
Methods inherited from class org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior
createArc, createArc, createArc, createCircle, createLineString, createPoint, createPoint, getMapControl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompoundBehavior

public CompoundBehavior(Behavior[] behaviors)

Creates a new behavior as a composition of others.

Parameters:
tools - atomic behaviors that will compound this one
Method Detail

addMapBehavior

public void addMapBehavior(Behavior mt,
                           boolean draw)

Adds a new behavior, setting if will be real-time (when user is working with it) drawn or not.

When user works with a compound behavior, he/she will see on real-time the graphical changes produced at the associated MapControl, only by those which have their associated draw flag to true.

Parameters:
mt - the new behavior
draw - flag determining if will be real-time drawn or no

removeMapBehavior

public void removeMapBehavior(Behavior mt)

Removes a Behavior that composes this one.

Parameters:
mt - the Behavior to be removed

containsBehavior

public boolean containsBehavior(Behavior mt)

Searches for mt, returning true if is contained.

Parameters:
mt - the behavior to search
Returns:
true if is contained; otherwise false

getBehavior

public Behavior getBehavior(int index)

Returns the first-level Behavior at the specified position.

Parameters:
index - index of element to return
Returns:
the element at the specified position.

isDrawnBehavior

public boolean isDrawnBehavior(int index)

Returns if it's invoked the method public void paintComponent(Graphics g) of the first-level Behavior at the specified position, each time is painted this component.

Parameters:
index - index of element
Returns:
true if it's invoked the method public void paintComponent(Graphics g) of the first-level Behavior at the specified position, each time is painted this component, otherwise false.

setDrawnBehavior

public void setDrawnBehavior(int index,
                             boolean draw)

Sets if will be invoked the method public void paintComponent(Graphics g) of the first-level Behavior at the specified position, each time is painted this component.

Parameters:
index - index of element
true - if will be invoked the method public void paintComponent(Graphics g) of the first-level Behavior at the specified position, each time is painted this component, otherwise false.

size

public int size()

Returns the number of first-level Behaviors in this CompoundBehavior.

Returns:
the number of first-level Behaviors in this CompoundBehavior

getImageCursor

public 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
Overrides:
getImageCursor in class Behavior
Returns:
the mouse cursor of the tool listener associated

mouseClicked

public void mouseClicked(MouseEvent e)
                  throws BehaviorException
Specified by:
mouseClicked in interface IBehavior
Overrides:
mouseClicked in class Behavior
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(MouseEvent e)
                  throws BehaviorException
Specified by:
mouseDragged in interface IBehavior
Overrides:
mouseDragged in class Behavior
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(MouseEvent e)
                  throws BehaviorException
Specified by:
mouseEntered in interface IBehavior
Overrides:
mouseEntered in class Behavior
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(MouseEvent e)
                 throws BehaviorException
Specified by:
mouseExited in interface IBehavior
Overrides:
mouseExited in class Behavior
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(MouseEvent e)
                throws BehaviorException
Specified by:
mouseMoved in interface IBehavior
Overrides:
mouseMoved in class Behavior
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(MouseEvent e)
                  throws BehaviorException
Specified by:
mousePressed in interface IBehavior
Overrides:
mousePressed in class Behavior
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(MouseEvent e)
                   throws BehaviorException
Specified by:
mouseReleased in interface IBehavior
Overrides:
mouseReleased in class Behavior
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(MouseWheelEvent e)
                     throws BehaviorException
Specified by:
mouseWheelMoved in interface IBehavior
Overrides:
mouseWheelMoved in class Behavior
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)

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
Overrides:
paintComponent in class Behavior
See Also:
Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)

setListener

public void setListener(ToolListener listener)
Sets a tool listener to work with a MapControl instance using these behaviors.

Parameters:
listener - a RectangleListener object for this behavior

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
Specified by:
getListener in class Behavior
Returns:
the ToolListener used by this behavior

setMapControl

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

Associates this behavior to a MapControl object.

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

setAllControlsBehavior

public static void setAllControlsBehavior(Behavior behavior)

Sets the Behavior that will be used for any MapControl.

Parameters:
behavior - the multi-view Behavior

getAllControlsBehavior

public static Behavior getAllControlsBehavior()

Gets the Behavior that will be used for any MapControl.

Returns:
the multi-view Behavior


Copyright © 2004-2013 gvSIG. All Rights Reserved.