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
Behavior s in this CompoundBehavior . |
clean, createArc, createArc, createArc, createCircle, createLineString, createPoint, createPoint, getMapControl, isMyButton, isMyButton, resetMyButton
public 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 false
public 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 Behavior
s in this CompoundBehavior
.
Behavior
s in this CompoundBehavior
public Image getImageCursor()
IBehavior
Gets the mouse cursor of the tool listener associated to this behavior.
getImageCursor
in interface IBehavior
getImageCursor
in class Behavior
public void mouseClicked(MouseEvent e) throws BehaviorException
mouseClicked
in interface IBehavior
mouseClicked
in class Behavior
BehaviorException
- 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 IBehavior
mouseDragged
in class Behavior
BehaviorException
- 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 IBehavior
mouseEntered
in class Behavior
BehaviorException
- 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 IBehavior
mouseExited
in class Behavior
BehaviorException
- 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 IBehavior
mouseMoved
in class Behavior
BehaviorException
- 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 IBehavior
mousePressed
in class Behavior
BehaviorException
- 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 IBehavior
mouseReleased
in class Behavior
BehaviorException
- 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 IBehavior
mouseWheelMoved
in class Behavior
BehaviorException
- 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)
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
paintComponent
in class Behavior
Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
public void paintComponent(MapControlDrawer renderer, boolean clean)
paintComponent
in class Behavior
public void setListener(ToolListener listener)
MapControl
instance using these behaviors.listener
- a RectangleListener
object for this behaviorpublic ToolListener getListener()
IBehavior
Gets the ToolListener
used by this behavior to perform actions on the
associated MapControl
object.
getListener
in interface IBehavior
getListener
in class Behavior
ToolListener
used by this behaviorpublic void setMapControl(MapControl mc)
IBehavior
Associates this behavior to a MapControl
object.
setMapControl
in interface IBehavior
setMapControl
in class Behavior
mc
- 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 Behavior
public static Behavior getAllControlsBehavior()
Gets the Behavior
that will be used for any MapControl
.
Behavior