Class CompoundBehavior
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
BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT, geomManager, LOG, LOGGER -
Constructor Summary
ConstructorsConstructorDescriptionCompoundBehavior(Behavior[] behaviors) Creates a new behavior as a composition of others. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMapBehavior(Behavior mt, boolean draw) Adds a new behavior, setting if will be real-time (when user is working with it) drawn or not.booleanSearches formt, returningtrueif is contained.static BehaviorGets theBehaviorthat will be used for anyMapControl.getBehavior(int index) Returns the first-levelBehaviorat the specified position.Gets the mouse cursor of the tool listener associated to this behavior.Gets theToolListenerused by this behavior to perform actions on the associatedMapControlobject.booleanisDrawnBehavior(int index) Returns if it's invoked the methodpublic void paintComponent(Graphics g)of the first-levelBehaviorat the specified position, each time is painted this component.iterator()voidvoidvoidvoidvoidvoidvoidvoidvoidpaintComponent(MapControlDrawer renderer) Method executed in real-time, when user is working with a tool on the associatedMapControlobject, repainting theMapControl's image.voidpaintComponent(MapControlDrawer renderer, boolean clean) voidRemoves aBehaviorthat composes this one.static voidsetAllControlsBehavior(Behavior behavior) Sets theBehaviorthat will be used for anyMapControl.voidsetDrawnBehavior(int index, boolean draw) Sets if will be invoked the methodpublic void paintComponent(Graphics g)of the first-levelBehaviorat the specified position, each time is painted this component.voidsetListener(ToolListener listener) Sets a tool listener to work with aMapControlinstance using these behaviors.voidAssociates this behavior to aMapControlobject.intsize()Returns the number of first-levelBehaviors in thisCompoundBehavior.Methods inherited from class org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior
clean, createArc, createArc, createArc, createCircle, createEllipse, createPoint, createPoint, getMapControl, getUseSnapping, isMyButton, isMyButton, resetMyButton, setUseSnappingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CompoundBehavior
Creates a new behavior as a composition of others.
- Parameters:
tools- atomic behaviors that will compound this one
-
-
Method Details
-
addMapBehavior
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 totrue.- Parameters:
mt- the new behaviordraw- flag determining if will be real-time drawn or no
-
removeMapBehavior
Removes a
Behaviorthat composes this one.- Parameters:
mt- theBehaviorto be removed
-
containsBehavior
Searches for
mt, returningtrueif is contained.- Parameters:
mt- the behavior to search- Returns:
trueif is contained; otherwisefalse
-
getBehavior
Returns the first-level
Behaviorat 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-levelBehaviorat the specified position, each time is painted this component.- Parameters:
index- index of element- Returns:
trueif it's invoked the methodpublic void paintComponent(Graphics g)of the first-levelBehaviorat the specified position, each time is painted this component, otherwisefalse.
-
setDrawnBehavior
public void setDrawnBehavior(int index, boolean draw) Sets if will be invoked the method
public void paintComponent(Graphics g)of the first-levelBehaviorat the specified position, each time is painted this component.- Type Parameters:
code- true if will be invoked the methodpublic void paintComponent(Graphics g)of the first-levelBehaviorat the specified position, each time is painted this component, otherwisefalse.- Parameters:
index- index of element
-
size
public int size()Returns the number of first-level
Behaviors in thisCompoundBehavior.- Returns:
- the number of first-level
Behaviors in thisCompoundBehavior
-
getImageCursor
Description copied from interface:IBehaviorGets the mouse cursor of the tool listener associated to this behavior.
- Specified by:
getImageCursorin interfaceIBehavior- Overrides:
getImageCursorin classBehavior- Returns:
- the mouse cursor of the tool listener associated
-
mouseClicked
- Specified by:
mouseClickedin interfaceIBehavior- Overrides:
mouseClickedin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse clicked event, by theIBehaviorobject- See Also:
-
mouseDragged
- Specified by:
mouseDraggedin interfaceIBehavior- Overrides:
mouseDraggedin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse dragged event, by theIBehaviorobject- See Also:
-
mouseEntered
- Specified by:
mouseEnteredin interfaceIBehavior- Overrides:
mouseEnteredin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse entered event, by theIBehaviorobject- See Also:
-
mouseExited
- Specified by:
mouseExitedin interfaceIBehavior- Overrides:
mouseExitedin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse exited event, by theIBehaviorobject- See Also:
-
mouseMoved
- Specified by:
mouseMovedin interfaceIBehavior- Overrides:
mouseMovedin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse moved event, by theIBehaviorobject- See Also:
-
mousePressed
- Specified by:
mousePressedin interfaceIBehavior- Overrides:
mousePressedin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse pressed event, by theIBehaviorobject- See Also:
-
mouseReleased
- Specified by:
mouseReleasedin interfaceIBehavior- Overrides:
mouseReleasedin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse released event, by theIBehaviorobject- See Also:
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceIBehavior- Overrides:
mouseWheelMovedin classBehavior- Throws:
BehaviorException- any exception processing the action associated to a mouse wheel event, by theIBehaviorobject- See Also:
-
paintComponent
Description copied from interface:IBehaviorMethod executed in real-time, when user is working with a tool on the associated
MapControlobject, repainting theMapControl'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:
paintComponentin interfaceIBehavior- Overrides:
paintComponentin classBehavior- See Also:
-
paintComponent
- Overrides:
paintComponentin classBehavior
-
setListener
Sets a tool listener to work with aMapControlinstance using these behaviors.- Parameters:
listener- aRectangleListenerobject for this behavior
-
getListener
Description copied from interface:IBehaviorGets the
ToolListenerused by this behavior to perform actions on the associatedMapControlobject.- Specified by:
getListenerin interfaceIBehavior- Specified by:
getListenerin classBehavior- Returns:
- the
ToolListenerused by this behavior
-
setMapControl
Description copied from interface:IBehaviorAssociates this behavior to a
MapControlobject.- Specified by:
setMapControlin interfaceIBehavior- Overrides:
setMapControlin classBehavior- Parameters:
mc- theMapControlobject to associate- See Also:
-
setAllControlsBehavior
Sets the
Behaviorthat will be used for anyMapControl.- Parameters:
behavior- the multi-viewBehavior
-
getAllControlsBehavior
Gets the
Behaviorthat will be used for anyMapControl.- Returns:
- the multi-view
Behavior
-
iterator
-