public class CompoundBehavior extends Behavior
Allows having multiple behaviors when user works with the associated
MapControl. Each one with its associated tool listener.
BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT, geomManager| Constructor and Description |
|---|
CompoundBehavior(Behavior[] behaviors)
Creates a new behavior as a composition of others.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
paintComponent(MapControlDrawer renderer,
boolean clean) |
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. |
clean, createArc, createArc, createArc, createCircle, createLineString, createPoint, createPoint, getMapControl, isMyButton, isMyButton, resetMyButtonpublic CompoundBehavior(Behavior[] behaviors)
Creates a new behavior as a composition of others.
tools - atomic behaviors that will compound this onepublic 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.
mt - the new behaviordraw - flag determining if will be real-time drawn or nopublic void removeMapBehavior(Behavior mt)
Removes a Behavior that composes this one.
mt - the Behavior to be removedpublic boolean containsBehavior(Behavior mt)
Searches for mt, returning true if is contained.
mt - the behavior to searchtrue if is contained; otherwise falsepublic Behavior getBehavior(int index)
Returns the first-level Behavior at the specified position.
index - index of element to returnpublic 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.
index - index of elementtrue 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.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.
index - index of elementtrue - 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.public int size()
Returns the number of first-level Behaviors in this CompoundBehavior.
Behaviors in this CompoundBehaviorpublic Image getImageCursor()
IBehaviorGets the mouse cursor of the tool listener associated to this behavior.
getImageCursor in interface IBehaviorgetImageCursor in class Behaviorpublic void mouseClicked(MouseEvent e) throws BehaviorException
mouseClicked in interface IBehaviormouseClicked in class BehaviorBehaviorException - any exception processing the action associated to a mouse clicked event, by the IBehavior objectMouseListener.mouseClicked(java.awt.event.MouseEvent)public void mouseDragged(MouseEvent e) throws BehaviorException
mouseDragged in interface IBehaviormouseDragged in class BehaviorBehaviorException - any exception processing the action associated to a mouse dragged event, by the IBehavior objectMouseMotionListener.mouseDragged(java.awt.event.MouseEvent)public void mouseEntered(MouseEvent e) throws BehaviorException
mouseEntered in interface IBehaviormouseEntered in class BehaviorBehaviorException - any exception processing the action associated to a mouse entered event, by the IBehavior objectMouseListener.mouseEntered(java.awt.event.MouseEvent)public void mouseExited(MouseEvent e) throws BehaviorException
mouseExited in interface IBehaviormouseExited in class BehaviorBehaviorException - any exception processing the action associated to a mouse exited event, by the IBehavior objectMouseListener.mouseExited(java.awt.event.MouseEvent)public void mouseMoved(MouseEvent e) throws BehaviorException
mouseMoved in interface IBehaviormouseMoved in class BehaviorBehaviorException - any exception processing the action associated to a mouse moved event, by the IBehavior objectMouseMotionListener.mouseMoved(java.awt.event.MouseEvent)public void mousePressed(MouseEvent e) throws BehaviorException
mousePressed in interface IBehaviormousePressed in class BehaviorBehaviorException - any exception processing the action associated to a mouse pressed event, by the IBehavior objectMouseListener.mousePressed(java.awt.event.MouseEvent)public void mouseReleased(MouseEvent e) throws BehaviorException
mouseReleased in interface IBehaviormouseReleased in class BehaviorBehaviorException - any exception processing the action associated to a mouse released event, by the IBehavior objectMouseListener.mouseReleased(java.awt.event.MouseEvent)public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException
mouseWheelMoved in interface IBehaviormouseWheelMoved in class BehaviorBehaviorException - any exception processing the action associated to a mouse wheel event, by the IBehavior objectMouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)public void paintComponent(MapControlDrawer renderer)
IBehaviorMethod 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 IBehaviorpaintComponent in class BehaviorGraphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)public void paintComponent(MapControlDrawer renderer, boolean clean)
paintComponent in class Behaviorpublic void setListener(ToolListener listener)
MapControl instance using these behaviors.listener - a RectangleListener object for this behaviorpublic ToolListener getListener()
IBehaviorGets the ToolListener used by this behavior to perform actions on the
associated MapControl object.
getListener in interface IBehaviorgetListener in class BehaviorToolListener used by this behaviorpublic void setMapControl(MapControl mc)
IBehaviorAssociates this behavior to a MapControl object.
setMapControl in interface IBehaviorsetMapControl in class Behaviormc - the MapControl object to associateIBehavior.getMapControl()public static void setAllControlsBehavior(Behavior behavior)
Sets the Behavior that will be used for any MapControl.
behavior - the multi-view Behaviorpublic static Behavior getAllControlsBehavior()
Gets the Behavior that will be used for any MapControl.
Behavior