org.gvsig.fmap.mapcontrol.tools.Behavior
Class PolylineBehavior

java.lang.Object
  extended by org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior
      extended by org.gvsig.fmap.mapcontrol.tools.Behavior.PolylineBehavior
All Implemented Interfaces:
IBehavior
Direct Known Subclasses:
PolygonBehavior

public class PolylineBehavior
extends Behavior

Behavior that allows user to draw a polyline by its vertexes on the image of the associated MapControl using a PolylineListener.

Author:
Vicente Caballero Navarro, Pablo Piqueras Bartolomé

Field Summary
protected  ArrayList arrayX
          The abscissa coordinate of all vertexes of the polyline.
protected  ArrayList arrayY
          The ordinate coordinate of all vertexes of the polyline.
protected  boolean isClicked
          Determines if user is setting the vertexes (with one click of the button 1 of the mouse), or not.
protected  PolylineListener listener
          Tool listener used to work with the MapControl object.
 
Fields inherited from class org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior
geomManager
 
Constructor Summary
PolylineBehavior(PolylineListener mli)
          Creates a new behavior for drawing a polyline by its vertexes.
 
Method Summary
protected  void addPoint(Point2D p)
          Adds a new point to the polyline.
protected  void changeLastPoint(Point2D p)
          Changes the last point added of the polyline.
protected  void drawPolyLine(MapControlDrawer mapControlDrawer)
          Draws the polyline in the Graphics2D of the associated MapControl.
 ToolListener getListener()
          Gets the ToolListener used by this behavior to perform actions on the associated MapControl object.
 void mouseDragged(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void paintComponent(MapControlDrawer mapControlDrawer)
          Method executed in real-time, when user is working with a tool on the associated MapControl object, repainting the MapControl's image.
 void setListener(ToolListener listener)
          Sets a tool listener to work with the MapControl using this behavior.
 
Methods inherited from class org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior
createArc, createArc, createArc, createCircle, createLineString, createPoint, createPoint, getImageCursor, getMapControl, mouseClicked, mouseEntered, mouseExited, mouseReleased, mouseWheelMoved, setMapControl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arrayX

protected ArrayList arrayX
The abscissa coordinate of all vertexes of the polyline.


arrayY

protected ArrayList arrayY
The ordinate coordinate of all vertexes of the polyline.


isClicked

protected boolean isClicked
Determines if user is setting the vertexes (with one click of the button 1 of the mouse), or not.


listener

protected PolylineListener listener
Tool listener used to work with the MapControl object.

See Also:
getListener(), setListener(ToolListener)
Constructor Detail

PolylineBehavior

public PolylineBehavior(PolylineListener mli)

Creates a new behavior for drawing a polyline by its vertexes.

Parameters:
mli - listener used to permit this object to work with the associated MapControl
Method Detail

paintComponent

public void paintComponent(MapControlDrawer mapControlDrawer)
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)

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)

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)

changeLastPoint

protected void changeLastPoint(Point2D p)

Changes the last point added of the polyline.

Parameters:
p - a point which will replace the last added to the polyline

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)

drawPolyLine

protected void drawPolyLine(MapControlDrawer mapControlDrawer)

Draws the polyline in the Graphics2D of the associated MapControl.

Parameters:
g2 - the 2D context that allows draw the polyline

addPoint

protected void addPoint(Point2D p)

Adds a new point to the polyline.

Parameters:
p - a new point to the polyline

setListener

public void setListener(ToolListener listener)

Sets a tool listener to work with the MapControl using this behavior.

Parameters:
listener - a PolylineListener 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


Copyright © 2004-2013 gvSIG. All Rights Reserved.