org.gvsig.fmap.mapcontrol
Class MapControl

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.gvsig.fmap.mapcontrol.MapControl
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, org.gvsig.tools.dispose.Disposable, org.gvsig.tools.observer.Observer

public class MapControl
extends javax.swing.JComponent
implements java.awt.event.ComponentListener, org.gvsig.tools.observer.Observer, org.gvsig.tools.dispose.Disposable

A component that includes a MapContext with support for use it as a particular Behavior.

A developer can register a set of Behavior, but only one (that can be a composition of several) of them can be active. The active one defines the way to work and access with its MapContext's layers. The active behavior, in combination with the appropriate ToolListener will allow user work with a particular tool.

All mouse events produced on this component will be delegated to the current active behavior, the currentMapTool.

Drawing process:

Uses a double buffer for the drawing process of MapContext's information.

If the double buffer wasn't created, creates a new one.

Paints the component according the following algorithm:
  If status is UPDATED:
    If there is a double buffer:
      If there is a behavior for managing the MapControl instance, delegates the drawing process to that behavior, calling: behavior_instance.paintComponent(g).
      Else, repaints the current graphical information quickly calling: g.drawImage(image,0,0,null).
  Else, (status is OUTDATED, or ONLY_GRAPHICS): executes a quickly repaint of the previous information calling g.drawImage(image,0,0,null), and creates a painting request to delegate the heavy drawing process to the Drawer2's worker thread, according the SingleWorketThread pattern, starting a timer to update (invoking repaint()) the view every delay of 1000 / drawFrameRate ms. during that heavy drawing process, and if its enabled drawAnimationEnabled. The painting request once is being attended, invokes MapContext to draw the layers: mapContext.draw(image, g, cancel,mapContext.getScaleView());

Some notes:

Tools:

A developer can:

Exception listener:

Adding an ExceptionListener, can get notification about any exception produced:

Other:

Other useful capabilities of MapControl:

Author:
Fernando Gonz�lez Cort�s, Pablo Piqueras Bartolom� (pablo.piqueras@iver.es)
See Also:
MapControl.CancelDraw, MapControl.Drawer, MapControl.MapContextListener, MapControl.MapToolListener, Serialized Form

Nested Class Summary
 class MapControl.CancelDraw
           An instance of CancelDraw will be shared by all this MapControl's MapContext layers, allowing receive a notification that, when they're been drawn, to be cancelled.
 class MapControl.Drawer
           An instance of Drawer2 could manage all MapControl painting requests.
 class MapControl.MapContextListener
          MapContextListener listens all events produced in a MapControl's MapContext object during an atomic period of time, and sets it to dirty, executing drawMap(false), if any of the following conditions is accomplished: Any of the LayerEvent in the AtomicEvent parameter notifies a visibility change.
 class MapControl.MapToolListener
           Listens all kind of mouse events produced in MapControl, and invokes its current map tool ( MapControl#getCurrentMapTool() to simulate a behavior.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int ACTUALIZADO
           One of the possible status of MapControl.
protected  java.awt.geom.Point2D adjustedPoint
          Represents the cursor's point selected in screen coordinates.
protected  Behavior currentMapTool
           Active Behavior that will generate events according a criterion, and then, with a ToolListener associated, will simulate to user that works with this component as a particular tool.
protected  java.lang.String currentTool
           Name of the tool used currently to interact with this component.
static int DESACTUALIZADO
           One of the possible status of MapControl.
protected static org.gvsig.fmap.geom.GeometryManager geomManager
           
protected  java.awt.geom.Point2D mapAdjustedPoint
          Represents the cursor's point selected in map coordinates.
protected static MapControlManager mapControlManager
           
protected  MapControl.MapToolListener mapToolListener
           Listener of all kind of mouse events produced in this component.
protected  java.util.Map<java.lang.String,Behavior> namesMapTools
           All registered Behavior that can define a way to work with this MapControl.
protected  java.lang.String prevTool
           Name of the previous tool used.
protected  org.gvsig.fmap.mapcontext.ViewPort vp
           Reference to the ViewPort of the MapContext of this component.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MapControl()
           Creates a new MapControl instance with the following characteristics: Name: MapControl .
 
Method Summary
 void addBehavior(java.lang.String name, Behavior tool)
           Registers a new behavior to this component.
 void addBehavior(java.lang.String name, Behavior[] tools)
           Registers a new behavior to this component as a CompoundBehavior made up of tools.
 void addCombinedBehavior(Behavior tool)
           Adds a new tool as combined tool.
 void addExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o)
           
 void applyFrameRate()
           Sets the delay to the timer that refreshes this MapControl instance.
 void calculateSnapPoint(java.awt.Point point)
           Tries to find the nearest geometry or grid control point by the position of the current snap tool.
 void cancelDrawing()
           Determines that current drawing process of MapControl's MapContext's data must be canceled.
 void commandRefresh()
           
 void commandRepaint()
           
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 void dispose()
           
 void drawMap(boolean doClear)
           Forces repaint all visible graphical information in this component.
 java.awt.geom.Point2D getAdjustedPoint()
           
 MapControl.CancelDraw getCanceldraw()
           Gets the shared object that determines if a drawing process must be cancelled or can continue.
 Behavior getCombinedTool()
           Gets the tool used in combination with the current tool of this MapControl.
 Behavior getCurrentMapTool()
           Gets as current active Behavior associated to this component, that one which is registered and identified by toolName.
 java.lang.String getCurrentTool()
           Returns the name of the current selected tool on this MapControl
 Grid getGrid()
           
 java.awt.image.BufferedImage getImage()
           Gets the BufferedImage used to accelerate the draw of new ''frames'' with changes, or new graphical items in this component.
 java.awt.geom.Point2D getMapAdjustedPoint()
           
 org.gvsig.fmap.mapcontext.MapContext getMapContext()
           Gets this component's MapContext, with the model, and most of the view, and control logic of the layers of this component, including a ViewPort to adapt the information to the projection, and display it in the available area.
 MapControlDrawer getMapControlDrawer()
           
 Behavior getMapTool(java.lang.String name)
           Gets the Behavior registered in this component, identified by name.
 MapControl.MapToolListener getMapToolListener()
           Returns the listener used to catch all mouse events produced in this MapControl instance and that redirects the calls to the current map tool.
 java.util.Set getMapToolsKeySet()
           Returns a set view of the keys that identified the tools registered.
 java.util.HashMap getNamesMapTools()
           Returns all registered Behavior that can define a way to work with this MapControl.
 java.awt.geom.Point2D getPoint()
          Gets the selected point.
 org.cresques.cts.IProjection getProjection()
           Gets this component's MapContext projection.
 org.gvsig.fmap.mapcontext.ViewPort getViewPort()
           Gets the ViewPort of this component's MapContext .
 boolean hasTool(java.lang.String toolName)
           Returns true if this component contains a tool identified by toolName.
 void initializeGrid()
           Updates the grid on the ViewPort of the associated MapControl object according the values in the com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences.
static boolean isDrawAnimationEnabled()
           Determines if its enabled the repaint that invokes the timer according to #getDrawFrameRate().
 boolean isRefentEnabled()
          Determines if snap tools are enabled or disabled.
protected  void paintComponent(java.awt.Graphics g)
           Paints the graphical information of this component using a double buffer.
 void removeCombinedTool(Behavior tool)
           Removes the tool tool used in combination with the current tool of this MapControl.
 boolean removeExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o)
           
 void rePaintDirtyLayers()
           Cancels any current drawing process, changing the status to OUTDATED, and forcing repaint only the layers dirty.
 void setAdjustGrid(boolean adjustGrid)
           
 void setCombinedTool(Behavior combinedTool)
           Sets a tool to be used in combination with the current tool of this MapControl.
 void setCurrentMapTool(Behavior mapTool)
           Sets mapTool as this MapControl's current map tool.
static void setDrawAnimationEnabled(boolean drawAnimationEnabled)
           Sets if its enabled the repaint that invokes the timer according to #getDrawFrameRate().
 void setGridVisibility(boolean showGrid)
           
 void setMapContext(org.gvsig.fmap.mapcontext.MapContext model)
           Sets a MapContext to this component.
 void setMapControlDrawer(MapControlDrawer mapControlDrawer)
           
 void setPrevTool()
           Equivalent operation to undo.
 void setProjection(org.cresques.cts.IProjection proj)
           Sets the projection to this component's MapContext.
 void setRefentEnabled(boolean activated)
          Sets the snap tools enabled or disabled.
 void setTool(java.lang.String toolName)
           Sets as current active Behavior associated to this component, that one which is registered and identified by toolName.
protected  void throwException(java.lang.Throwable t)
           
 void update(org.gvsig.tools.observer.Observable observable, java.lang.Object notification)
           
 void zoomIn()
           Executes a zoom in operation centered at the center of the extent.
 void zoomOut()
           Executes a zoom out operation centered at the center of the extent.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTUALIZADO

public static final int ACTUALIZADO

One of the possible status of MapControl. Determines that all visible information has been drawn and its updated.

See Also:
Constant Field Values

adjustedPoint

protected java.awt.geom.Point2D adjustedPoint
Represents the cursor's point selected in screen coordinates.

See Also:
ViewPort.fromMapPoint(Point2D)

currentMapTool

protected Behavior currentMapTool

Active Behavior that will generate events according a criterion, and then, with a ToolListener associated, will simulate to user that works with this component as a particular tool.

See Also:
getCurrentMapTool(), getCurrentTool(), setTool(String)

currentTool

protected java.lang.String currentTool

Name of the tool used currently to interact with this component.

See Also:
getCurrentTool(), setTool(String)

DESACTUALIZADO

public static final int DESACTUALIZADO

One of the possible status of MapControl. Determines that not all visible information has been drawn or isn't updated.

See Also:
Constant Field Values

geomManager

protected static final org.gvsig.fmap.geom.GeometryManager geomManager

mapAdjustedPoint

protected java.awt.geom.Point2D mapAdjustedPoint
Represents the cursor's point selected in map coordinates.

See Also:
MapControl#toMapPoint

mapControlManager

protected static MapControlManager mapControlManager

mapToolListener

protected MapControl.MapToolListener mapToolListener

Listener of all kind of mouse events produced in this component.

Delegates each mouse event to the current map tool.

See Also:
addBehavior(String, Behavior), addBehavior(String, Behavior[]), getMapTool(String), getMapToolsKeySet(), getNamesMapTools(), setTool(String)

namesMapTools

protected java.util.Map<java.lang.String,Behavior> namesMapTools

All registered Behavior that can define a way to work with this MapControl.

Only one of them can be active at a given moment.

See Also:
addBehavior(String, Behavior), addBehavior(String, Behavior[]), getMapTool(String), getMapToolsKeySet(), getNamesMapTools()

prevTool

protected java.lang.String prevTool

Name of the previous tool used.


vp

protected org.gvsig.fmap.mapcontext.ViewPort vp

Reference to the ViewPort of the MapContext of this component.

After, the view port will change adapting itself according the current projection and the extent.

See Also:
getViewPort(), ViewPort
Constructor Detail

MapControl

public MapControl()

Creates a new MapControl instance with the following characteristics:

Method Detail

addBehavior

public void addBehavior(java.lang.String name,
                        Behavior tool)

Registers a new behavior to this component.

According the nature of the Behavior, different events will be generated. Those events can be caught by a particular ToolListener, allowing user to interact with this MapControl object as a tool.

Parameters:
name - name to identify the behavior to add
tool - the behavior to add
See Also:
addBehavior(String, Behavior[]), getNamesMapTools(), getMapToolsKeySet(), hasTool(String)

addBehavior

public void addBehavior(java.lang.String name,
                        Behavior[] tools)

Registers a new behavior to this component as a CompoundBehavior made up of tools.

According the nature of the behaviors registered, different events will be generated. Those events can be caught by a particular ToolListener, allowing user to interact with this MapControl object as a tool.

Parameters:
name - name to identify the compound behavior to add
tools - the compound behavior to add
See Also:
addBehavior(String, Behavior), getNamesMapTools(), getMapToolsKeySet(), hasTool(String)

addCombinedBehavior

public void addCombinedBehavior(Behavior tool)

Adds a new tool as combined tool.

The new tool will be stored with the previous combined tools, and will be combined with the current tool.

If tool was already stored as a combined tool, doesn't adds it.

Parameters:
tool - a new tool to be used combined with the current tool

addExceptionListener

public void addExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o)
See Also:
ExceptionHandlingSupport.addExceptionListener(ExceptionListener)

applyFrameRate

public void applyFrameRate()

Sets the delay to the timer that refreshes this MapControl instance.

Delay (in ms) = 1000 / getDrawFrameRate()

See Also:
#getDrawFrameRate(), #setDrawFrameRate(int)

calculateSnapPoint

public void calculateSnapPoint(java.awt.Point point)

Tries to find the nearest geometry or grid control point by the position of the current snap tool.

Prioritizes the grid control points than the geometries ones.

If finds any near, stores the map and pixel coordinates for the snap, and enables the bForceCoord attribute for the next draw of the mouse's cursor.

Parameters:
point - current mouse 2D position

cancelDrawing

public void cancelDrawing()

Determines that current drawing process of MapControl's MapContext's data must be canceled.

It has no effects if now isn't drawing that graphical information.

At last resort, the particular implementation of each layer in this MapControl's MapContrext will be that one which will draw the graphical information, and, if supports, which could cancel its drawing subprocess.


commandRefresh

public void commandRefresh()

commandRepaint

public void commandRepaint()

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentHidden(java.awt.event.ComponentEvent)

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentMoved(java.awt.event.ComponentEvent)

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentResized(java.awt.event.ComponentEvent)

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener
See Also:
ComponentListener.componentShown(java.awt.event.ComponentEvent)

dispose

public void dispose()
Specified by:
dispose in interface org.gvsig.tools.dispose.Disposable

drawMap

public void drawMap(boolean doClear)

Forces repaint all visible graphical information in this component.

If doClear == true, before repainting, clears the background color, with the inner viewport's background color.

Parameters:
doClear - true if needs clearing the background color before drawing the map
See Also:
cancelDrawing(), FLayers#setDirty(boolean)

getAdjustedPoint

public java.awt.geom.Point2D getAdjustedPoint()
Returns:
the adjustedPoint

getCanceldraw

public MapControl.CancelDraw getCanceldraw()

Gets the shared object that determines if a drawing process must be cancelled or can continue.

Returns:
the shared object that determines if a drawing process must be cancelled or can continue

getCombinedTool

public Behavior getCombinedTool()

Gets the tool used in combination with the current tool of this MapControl.

Returns:
the tool used in combination with the currentMapTool ; null if there is no combined tool

getCurrentMapTool

public Behavior getCurrentMapTool()

Gets as current active Behavior associated to this component, that one which is registered and identified by toolName.

Changing the current active behavior for this MapControl, implies also updating the previous behavior tool, and the current cursor.

Parameters:
toolName - name of a registered behavior
See Also:
getCurrentTool(), setTool(String)

getCurrentTool

public java.lang.String getCurrentTool()

Returns the name of the current selected tool on this MapControl

Returns:
the name of the current's behavior tool associated to this component
See Also:
getCurrentMapTool(), setTool(String)

getGrid

public Grid getGrid()

getImage

public java.awt.image.BufferedImage getImage()

Gets the BufferedImage used to accelerate the draw of new ''frames'' with changes, or new graphical items in this component.

Returns:
double buffered image used by this component to accelerate the draw of its graphical information, or null if isn't already created
See Also:
BufferedImage

getMapAdjustedPoint

public java.awt.geom.Point2D getMapAdjustedPoint()
Returns:
the mapAdjustedPoint

getMapContext

public org.gvsig.fmap.mapcontext.MapContext getMapContext()

Gets this component's MapContext, with the model, and most of the view, and control logic of the layers of this component, including a ViewPort to adapt the information to the projection, and display it in the available area.

Returns:
this component's MapContext, that includes the ViewPort used to project the graphical information, and display it in the available area
See Also:
MapContext, setMapContext(MapContext)

getMapControlDrawer

public MapControlDrawer getMapControlDrawer()
Returns:
the mapControlDrawer

getMapTool

public Behavior getMapTool(java.lang.String name)

Gets the Behavior registered in this component, identified by name.

Parameters:
name - name of a registered behavior
Returns:
tool the registered behavior in this component as name, or null if no one has that identifier
See Also:
addBehavior(String, Behavior), addBehavior(String, Behavior[]), hasTool(String)

getMapToolListener

public MapControl.MapToolListener getMapToolListener()

Returns the listener used to catch all mouse events produced in this MapControl instance and that redirects the calls to the current map tool.

Returns:
the map tool listener used

getMapToolsKeySet

public java.util.Set getMapToolsKeySet()

Returns a set view of the keys that identified the tools registered.

Returns:
a set view of the keys that identified the tools registered
See Also:
HashMap.keySet(), getNamesMapTools(), addBehavior(String, Behavior), addBehavior(String, Behavior[])

getNamesMapTools

public java.util.HashMap getNamesMapTools()

Returns all registered Behavior that can define a way to work with this MapControl.

Returns:
registered Behavior to this MapControl
See Also:
addBehavior(String, Behavior), addBehavior(String, Behavior[]), getMapToolsKeySet(), hasTool(String)

getPoint

public java.awt.geom.Point2D getPoint()
Gets the selected point. If the snapping is enabled it returns the selected point.

Returns:
The selected point

getProjection

public org.cresques.cts.IProjection getProjection()

Gets this component's MapContext projection.

Returns:
this component's MapContext projection
See Also:
MapContext.getProjection(), setProjection(IProjection)

getViewPort

public org.gvsig.fmap.mapcontext.ViewPort getViewPort()

Gets the ViewPort of this component's MapContext .

See Also:
MapContext.getViewPort()

hasTool

public boolean hasTool(java.lang.String toolName)

Returns true if this component contains a tool identified by toolName.

Parameters:
toolName - identifier of the tool
Returns:
true if this component contains a tool identified by toolName; otherwise false
See Also:
addBehavior(String, Behavior), addBehavior(String, Behavior[])

initializeGrid

public void initializeGrid()

Updates the grid on the ViewPort of the associated MapControl object according the values in the com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferences.

The preferences are:


isDrawAnimationEnabled

public static boolean isDrawAnimationEnabled()

Determines if its enabled the repaint that invokes the timer according to #getDrawFrameRate().

Returns:
true if its enabled; otherwise false

isRefentEnabled

public boolean isRefentEnabled()
Determines if snap tools are enabled or disabled.

Returns:
true to enable the snap tools; false to disable them
See Also:
setRefentEnabled(boolean)

paintComponent

protected void paintComponent(java.awt.Graphics g)

Paints the graphical information of this component using a double buffer.

If the double buffer wasn't created, creates a new one.

Paints the component according the following algorithm:
  If status is UPDATED:
    If there is no double buffer:
      If there is a behavior for managing the MapControl instance, delegates the drawing process to that behavior, calling: behavior_instance.paintComponent(g)   .
      Else, repaints the current graphical information quickly calling: g.drawImage(image,0,0,null)   .
  Else, (status is OUTDATED, or ONLY_GRAPHICS): executes a quickly repaint of the previous information calling g.drawImage(image,0,0,null), and creates a painting request to delegate the heavy drawing process to the Drawer2's worker thread, according the SingleWorketThread pattern, starting a timer to update (invoking repaint() that comprises invoke this method) the view every delay of 360 ms. during the the process drawing.

Overrides:
paintComponent in class javax.swing.JComponent
See Also:
JComponent.paintComponent(java.awt.Graphics), Drawer2

removeCombinedTool

public void removeCombinedTool(Behavior tool)

Removes the tool tool used in combination with the current tool of this MapControl.


removeExceptionListener

public boolean removeExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o)
See Also:
ExceptionHandlingSupport.removeExceptionListener(ExceptionListener)

rePaintDirtyLayers

public void rePaintDirtyLayers()

Cancels any current drawing process, changing the status to OUTDATED, and forcing repaint only the layers dirty.

See Also:
cancelDrawing()

setAdjustGrid

public void setAdjustGrid(boolean adjustGrid)

setCombinedTool

public void setCombinedTool(Behavior combinedTool)

Sets a tool to be used in combination with the current tool of this MapControl.

Parameters:
combinedTool - a tool to be used in combination with the current tool of MapControl

setCurrentMapTool

public void setCurrentMapTool(Behavior mapTool)

Sets mapTool as this MapControl's current map tool.

Parameters:
mapTool - a map tool, or null to disable the interaction with the user
See Also:
getCurrentMapTool(), getCurrentTool(), setTool(String), setPrevTool(), addBehavior(String, Behavior), addBehavior(String, Behavior[])

setDrawAnimationEnabled

public static void setDrawAnimationEnabled(boolean drawAnimationEnabled)

Sets if its enabled the repaint that invokes the timer according to #getDrawFrameRate().

Parameters:
drawAnimationEnabled - true to enable the mode; otherwise false

setGridVisibility

public void setGridVisibility(boolean showGrid)

setMapContext

public void setMapContext(org.gvsig.fmap.mapcontext.MapContext model)

Sets a MapContext to this component.

The MapContext has the model, and most of the view, and control logic of the layers of this component, including a ViewPort to adapt the information to the projection, and to display it in the available area.

If model hadn't a ViewPort, assigns the current one to it, otherwise, use its ViewPort.

After assigning the MapContext and ViewPort, sets the same MapContextListener that was using, and changes the status to OUTDATED.

Parameters:
model - this component's MapContext, that includes the ViewPort.
See Also:
MapContext, getMapContext()

setMapControlDrawer

public void setMapControlDrawer(MapControlDrawer mapControlDrawer)
Parameters:
mapControlDrawer - the mapControlDrawer to set

setPrevTool

public void setPrevTool()

Equivalent operation to undo.

Exchanges the previous tool with the current one.

See Also:
addBehavior(String, Behavior), addBehavior(String, Behavior[]), setTool(String)

setProjection

public void setProjection(org.cresques.cts.IProjection proj)

Sets the projection to this component's MapContext.

Parameters:
proj - the kind of projection to this component's MapContext
See Also:
MapContext.setProjection(IProjection), getProjection()

setRefentEnabled

public void setRefentEnabled(boolean activated)
Sets the snap tools enabled or disabled.

Parameters:
activated - true to enable the snap tools; false to disable them
See Also:
isRefentEnabled()

setTool

public void setTool(java.lang.String toolName)

Sets as current active Behavior associated to this component, that one which is registered and identified by toolName.

Changing the current active behavior for this MapControl, implies also updating the previous behavior tool, and the current cursor.

Parameters:
toolName - name of a registered behavior
See Also:
getCurrentMapTool(), getCurrentTool()

throwException

protected void throwException(java.lang.Throwable t)
See Also:
ExceptionHandlingSupport.throwException(Throwable)

update

public void update(org.gvsig.tools.observer.Observable observable,
                   java.lang.Object notification)
Specified by:
update in interface org.gvsig.tools.observer.Observer

zoomIn

public void zoomIn()

Executes a zoom in operation centered at the center of the extent.

This implementation is designed for being invoked outside a Behavior, for example by an action of pressing a button; and simulates that the event has been produced by releasing the button 1 of the mouse using the registered Behavior in this MapControl object that's responsible for the zoom in operation.

See Also:
zoomOut()

zoomOut

public void zoomOut()

Executes a zoom out operation centered at the center of the extent.

This implementation is thought for being invoked outside a Behavior, for example by an action of pressing a button, and simulates that the event has been produced by releasing the button 1 of the mouse using the registered Behavior in this MapControl object that's responsible for the zoom out operation.

See Also:
zoomIn()


Copyright © 2014 gvSIG Association. All Rights Reserved.