Class MapControl
- All Implemented Interfaces:
ComponentListener,ImageObserver,MenuContainer,Serializable,EventListener,org.gvsig.tools.dispose.Disposable,org.gvsig.tools.observer.Observer
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:
invalid input: ' ' If status is UPDATED:
invalid input: ' ' invalid input: ' ' If there is a double buffer:
invalid input: ' ' invalid input: ' ' invalid input: ' ' If there is a behavior for managing the
MapControl instance, delegates the drawing process to that
behavior, calling: behavior_instance.paintComponent(g).
invalid input: ' ' invalid input: ' ' invalid input: ' ' Else, repaints the current graphical information quickly
calling: g.drawImage(image,0,0,null).
invalid input: ' ' 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
invalid reference
Drawer2repaint()) 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:
- The painting process can be cancelled calling
#cancelDrawing(). - At last resort, the particular implementation of each layer in a
MapControl'sMapContrextwill be that one which will draw the graphical information, and, if supports, which could cancel its drawing subprocess. - It's possible to force repaint all layers, calling
#drawMap(boolean). - It's possible repaint only the dirty layers, calling
#rePaintDirtyLayers(). - It's possible repaint only the
GraphicLayer, calling#drawGraphics().
Tools:
A developer can:
- Register each tool as:
- A single behavior:
#addMapTool(String, Behavior). - Or, a compound behavior:
#addMapTool(String, Behavior).
- A single behavior:
- Get the current active tool:
#getCurrentMapTool(). - Get the current active tool name:
#getCurrentTool(). - Get a registered tool:
#getMapTool(String). - Get the name of all tools registered:
#getMapToolsKeySet(). - Get all tools registered, including the name they were registered:
#getNamesMapTools(). - Determine if has a tool registered:
#hasTool(String). - Set as an active tool, one of the registered:
#setTool(String). - Set as active tool, the previous used:
#setPrevTool(). - Set the current tool:
#setCurrentMapTool(Behavior). - Change the draw frame rate:
and
invalid reference
#setDrawFrameRate(int)#applyFrameRate(). - Get the draw frame rate:
.
invalid reference
#getDrawFrameRate() - Determine if will repaint this component each time timer finishes:
#isDrawAnimationEnabled(). - Change if will repaint this component each time timer finishes:
#setDrawAnimationEnabled(boolean). - Get the shared object that determines if a drawing process must be
cancelled or can continue:
#getCanceldraw(). - Get the combined tool:
#getCombinedTool(). - Set a combined tool:
#setCombinedTool(Behavior). - Remove the combined tool:
.
invalid reference
#removeCombinedTool()
Exception listener:
Adding an ExceptionListener, can get notification about any
exception produced:
- Attending a painting request.
- Working with the active tool.
- Applying a zoom in or zoom out operation.
Other:
Other useful capabilities of MapControl:
- Cancel the current drawing process (notifying it also to the inner
MapContextinstance and its layers):#cancelDrawing(). - Applying a zoom in operation centered at mouse position (without a
ToolListener):#zoomIn(). - Applying a zoom out operation centered at mouse position (without
a
ToolListener):#zoomOut().
- Author:
- Fernando Gonz�lez Cort�s, Pablo Piqueras Bartolom� (pablo.piqueras@iver.es)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassAn instance ofCancelDrawwill be shared by all thisMapControl'sMapContextlayers, allowing receive a notification that, when they're been drawn, to be cancelled.classAn instance ofDrawer2could manage allMapControlpainting requests.classinvalid input: '<'pMapContextListenerlistens all events produced in aMapControl'sMapContextobject during an atomic period of time, and sets it to dirty, executingdrawMap(false), if any of the following conditions is accomplished: Any of theLayerEventin theAtomicEventparameter notifies a visibility change. There is at least oneColorEventin theAtomicEventparameter. There is at least oneExtentEventin theAtomicEventparameter. Any of theLayerCollectionEventin theAtomicEventparameter notifies that a driver's layer has reloaded it successfully. There is at least oneLegendEventin theAtomicEventparameter. There is at least oneSelectionEventin theAtomicEventparameter.classListens all kind of mouse events produced inMapControl, and invokes its current map tool (MapControl#getCurrentMapTool()to simulate a behavior.Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intOne of the possible status ofMapControl.protected Point2DRepresents the cursor's point selected in screen coordinates.protected BehaviorActiveBehaviorthat will generate events according a criterion, and then, with aToolListenerassociated, will simulate to user that works with this component as a particular tool.protected StringName of the tool used currently to interact with this component.static final intOne of the possible status ofMapControl.protected static final org.gvsig.fmap.geom.GeometryManagerprotected Point2DRepresents the cursor's point selected in map coordinates.protected static MapControlManagerprotected MapControl.MapToolListenerListener of all kind of mouse events produced in this component.All registeredBehaviorthat can define a way to work with thisMapControl.static final intstatic final intprotected StringName of the previous tool used.protected org.gvsig.fmap.mapcontext.ViewPortReference to theViewPortof theMapContextof this component.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newMapControlinstance with the following characteristics: Name: MapControl . Disables the double buffer ofJComponent. Sets opaque (seeJComponent.setOpaque(boolean)). Sets its status toOUTDATED. Creates a newCancelDrawobject to notifyMapContext's layers if can continue processing the drawn or must cancel it. Creates a newMapContextwith a newViewPortin the default projection. Creates a newfor edition operations. Creates a newinvalid reference
CommandListenerMapToolListener, and associates it as a listener of whatever kind of mouse events produced in this component. Creates a newfor managing the painting requests. Creates a new timer that will invoke refresh this componentinvalid reference
Drawer2drawFrameRateper second, when is running a drawing process, and its enableddrawAnimationEnabled.MapControl(org.gvsig.fmap.mapcontext.MapContext theMapContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBehavior(String name, Behavior tool) Registers a new behavior to this component.voidaddBehavior(String name, Behavior[] tools) Registers a new behavior to this component as aCompoundBehaviormade up oftools.voidaddChangeToolListener(ChangeListener listener) voidaddCombinedBehavior(Behavior tool) Adds a new tool as combined tool.voidaddExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o) voidaddLayer(org.gvsig.fmap.mapcontext.layers.FLayer layer) voidvoidSets the delay to the timer that refreshes thisMapControlinstance.voidcalculateSnapPoint(Point2D point) Tries to find the nearest geometry or grid control point by the position of the current snap tool.voidDetermines that current drawing process ofMapControl'sMapContext's data must be canceled.voidvoidvoidvoidvoidvoidconvertToMapPoint(Point2D point, boolean useSnapping) voiddispose()voidvoiddrawMap(boolean doClear) Forces repaint all visible graphical information in this component.Gets the shared object that determines if a drawing process must be cancelled or can continue.Gets the tool used in combination with the current tool of thisMapControl.Gets as current activeBehaviorassociated to this component, that one which is registered and identified bytoolName.Returns the name of the current selected tool on this MapControlgetGrid()getImage()Gets theBufferedImageused to accelerate the draw of new ''frames'' with changes, or new graphical items in this component.org.gvsig.fmap.mapcontext.MapContextGets this component'sMapContext, with the model, and most of the view, and control logic of the layers of this component, including aViewPortto adapt the information to the projection, and display it in the available area.getMapTool(String name) Gets theBehaviorregistered in this component, identified byname.Returns the listener used to catch all mouse events produced in thisMapControlinstance and that redirects the calls to the current map tool.Returns a set view of the keys that identified the tools registered.Returns all registeredBehaviorthat can define a way to work with thisMapControl.intgetPoint()Gets the selected point.org.gvsig.crs.projection.lib.ProjectionGets this component'sMapContextprojection.org.gvsig.fmap.mapcontext.ViewPortGets theViewPortof this component'sMapContext.booleanbooleanReturnstrueif this component contains a tool identified bytoolName.voidUpdates the grid on theViewPortof the associatedMapControlobject according the values in the.invalid reference
com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.Preferencesbooleanstatic booleanDetermines if its enabled the repaint that invokes the timer according to.invalid reference
#getDrawFrameRate()booleanDetermines if snap tools are enabled or disabled.protected voidPaints the graphical information of this component using a double buffer.voidvoidremoveChangeToolListener(ChangeListener listener) voidremoveCombinedTool(Behavior tool) Removes the tooltoolused in combination with the current tool of thisMapControl.booleanremoveExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o) voidCancels any current drawing process, changing the status toOUTDATED, and forcing repaint only the layers dirty.voidsetAdjustGrid(boolean adjustGrid) voidsetCombinedTool(Behavior combinedTool) Sets a tool to be used in combination with the current tool of thisMapControl.voidsetCurrentMapTool(Behavior mapTool) SetsmapToolas thisMapControl's current map tool.voidsetDefaultMouseWheelEnabled(boolean defaultMouseWheelEnabled) static voidsetDrawAnimationEnabled(boolean drawAnimationEnabled) Sets if its enabled the repaint that invokes the timer according to.invalid reference
#getDrawFrameRate()voidsetGridVisibility(boolean showGrid) voidsetMapContext(org.gvsig.fmap.mapcontext.MapContext model) Sets aMapContextto this component.voidsetMapControlDrawer(MapControlDrawer mapControlDrawer) voidsetPaintMode(int paintMode) voidEquivalent operation to undo.voidsetProjection(org.gvsig.crs.projection.lib.Projection proj) Sets the projection to this component'sMapContext.voidsetRefentEnabled(boolean activated) Sets the snap tools enabled or disabled.voidSets as current activeBehaviorassociated to this component, that one which is registered and identified bytoolName.protected voidvoidvoidzoomIn()Executes a zoom in operation centered at the center of the extent.voidzoomOut()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, 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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, updateUIMethods 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, validateTreeMethods 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
geomManager
protected static final org.gvsig.fmap.geom.GeometryManager geomManager -
ACTUALIZADO
public static final int ACTUALIZADOOne of the possible status of
MapControl. Determines that all visible information has been drawn and its updated.- See Also:
-
DESACTUALIZADO
public static final int DESACTUALIZADOOne of the possible status of
MapControl. Determines that not all visible information has been drawn or isn't updated.- See Also:
-
PAINT_PARTIAL_DRAWING_LAYERS
public static final int PAINT_PARTIAL_DRAWING_LAYERS- See Also:
-
PAINT_WHEN_DRAW_LAYERS_IS_COMPLETED
public static final int PAINT_WHEN_DRAW_LAYERS_IS_COMPLETED- See Also:
-
namesMapTools
All registered
Behaviorthat can define a way to work with thisMapControl.Only one of them can be active at a given moment.
- See Also:
-
currentMapTool
Active
Behaviorthat will generate events according a criterion, and then, with aToolListenerassociated, will simulate to user that works with this component as a particular tool.- See Also:
-
currentTool
Name of the tool used currently to interact with this component.
- See Also:
-
vp
protected org.gvsig.fmap.mapcontext.ViewPort vpReference to the
ViewPortof theMapContextof this component.After, the view port will change adapting itself according the current projection and the extent.
- See Also:
-
mapToolListener
Listener of all kind of mouse events produced in this component.
Delegates each mouse event to the current map tool.
- See Also:
-
prevTool
Name of the previous tool used.
-
adjustedPoint
Represents the cursor's point selected in screen coordinates.- See Also:
-
mapControlManager
-
mapAdjustedPoint
Represents the cursor's point selected in map coordinates.- See Also:
-
-
Constructor Details
-
MapControl
public MapControl()Creates a new
MapControlinstance with the following characteristics:- Name: MapControl .
- Disables the double buffer of
JComponent. - Sets opaque (see
JComponent.setOpaque(boolean)). - Sets its status to
OUTDATED. - Creates a new
CancelDrawobject to notifyMapContext's layers if can continue processing the drawn or must cancel it. - Creates a new
MapContextwith a newViewPortin the default projection. - Creates a new
for edition operations.
invalid reference
CommandListener - Creates a new
MapToolListener, and associates it as a listener of whatever kind of mouse events produced in this component. - Creates a new
for managing the painting requests.
invalid reference
Drawer2 - Creates a new timer that will invoke refresh this component
drawFrameRateper second, when is running a drawing process, and its enableddrawAnimationEnabled.
-
MapControl
public MapControl(org.gvsig.fmap.mapcontext.MapContext theMapContext)
-
-
Method Details
-
addLayer
public void addLayer(org.gvsig.fmap.mapcontext.layers.FLayer layer) -
addLayerListener
-
setPaintMode
public void setPaintMode(int paintMode) -
getPaintMode
public int getPaintMode() -
setMapContext
public void setMapContext(org.gvsig.fmap.mapcontext.MapContext model) Sets a
MapContextto this component.The
MapContexthas the model, and most of the view, and control logic of the layers of this component, including aViewPortto adapt the information to the projection, and to display it in the available area.If
modelhadn't aViewPort, assigns the current one to it, otherwise, use itsViewPort.After assigning the
MapContextandViewPort, sets the sameMapContextListenerthat was using, and changes the status toOUTDATED.- Parameters:
model- this component'sMapContext, that includes theViewPort.- See Also:
-
getMapControlDrawer
- Returns:
- the mapControlDrawer
-
setMapControlDrawer
- Parameters:
mapControlDrawer- the mapControlDrawer to set
-
getProjection
public org.gvsig.crs.projection.lib.Projection getProjection()Gets this component's
MapContextprojection.- Returns:
- this component's
MapContextprojection - See Also:
-
setProjection
public void setProjection(org.gvsig.crs.projection.lib.Projection proj) Sets the projection to this component's
MapContext.- Parameters:
proj- the kind of projection to this component'sMapContext- See Also:
-
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 aViewPortto adapt the information to the projection, and display it in the available area.- Returns:
- this component's
MapContext, that includes theViewPortused to project the graphical information, and display it in the available area - See Also:
-
addBehavior
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 particularToolListener, allowing user to interact with thisMapControlobject as a tool.- Parameters:
name- name to identify the behavior to addtool- the behavior to add- See Also:
-
addBehavior
Registers a new behavior to this component as a
CompoundBehaviormade up oftools.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 thisMapControlobject as a tool.- Parameters:
name- name to identify the compound behavior to addtools- the compound behavior to add- See Also:
-
getMapTool
Gets the
Behaviorregistered in this component, identified byname.- Parameters:
name- name of a registered behavior- Returns:
- tool the registered behavior in this component as
name, ornullif no one has that identifier - See Also:
-
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:
-
hasTool
Returns
trueif this component contains a tool identified bytoolName.- Parameters:
toolName- identifier of the tool- Returns:
trueif this component contains a tool identified bytoolName; otherwisefalse- See Also:
-
setTool
Sets as current active
Behaviorassociated to this component, that one which is registered and identified bytoolName.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:
-
getTool
-
getCurrentMapTool
Gets as current active
Behaviorassociated to this component, that one which is registered and identified bytoolName.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
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:
-
cancelDrawing
public void cancelDrawing()Determines that current drawing process of
MapControl'sMapContext'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'sMapContrextwill be that one which will draw the graphical information, and, if supports, which could cancel its drawing subprocess. -
paintComponent
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:
invalid input: ' ' If status is UPDATED:
invalid input: ' ' invalid input: ' ' If there is no double buffer:
invalid input: ' ' invalid input: ' ' invalid input: ' ' If there is a behavior for managing theMapControlinstance, delegates the drawing process to that behavior, calling:behavior_instance.paintComponent(g)invalid input: ' ' .
invalid input: ' ' invalid input: ' ' invalid input: ' ' Else, repaints the current graphical information quickly calling:g.drawImage(image,0,0,null)invalid input: ' ' .
invalid input: ' ' Else, (status is OUTDATED, or ONLY_GRAPHICS): executes a quickly repaint of the previous information callingg.drawImage(image,0,0,null), and creates a painting request to delegate the heavy drawing process to the's worker thread, according the SingleWorketThread pattern, starting a timer to update (invokinginvalid reference
Drawer2repaint()that comprises invoke this method) the view every delay of 360 ms. during the the process drawing.- Overrides:
paintComponentin classJComponent- See Also:
-
getImage
Gets the
BufferedImageused 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
nullif isn't already created - See Also:
-
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-trueif needs clearing the background color before drawing the map- See Also:
-
rePaintDirtyLayers
public void rePaintDirtyLayers()Cancels any current drawing process, changing the status to
OUTDATED, and forcing repaint only the layers dirty.- See Also:
-
drawGraphics
public void drawGraphics() -
componentHidden
- Specified by:
componentHiddenin interfaceComponentListener- See Also:
-
componentMoved
- Specified by:
componentMovedin interfaceComponentListener- See Also:
-
componentResized
- Specified by:
componentResizedin interfaceComponentListener- See Also:
-
componentShown
- Specified by:
componentShownin interfaceComponentListener- See Also:
-
addExceptionListener
public void addExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o) - See Also:
-
removeExceptionListener
public boolean removeExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o) - See Also:
-
throwException
- See Also:
-
getViewPort
public org.gvsig.fmap.mapcontext.ViewPort getViewPort()Gets the
ViewPortof this component'sMapContext.- See Also:
-
getNamesMapTools
Returns all registered
Behaviorthat can define a way to work with thisMapControl.- Returns:
- registered
Behaviorto thisMapControl - See Also:
-
commandRepaint
public void commandRepaint() -
commandRefresh
public void commandRefresh() -
setPrevTool
public void setPrevTool()Equivalent operation to undo.
Exchanges the previous tool with the current one.
- See Also:
-
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 registeredBehaviorin thisMapControlobject that's responsible for the zoom in operation.- See Also:
-
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 registeredBehaviorin thisMapControlobject that's responsible for the zoom out operation.- See Also:
-
getMapToolListener
Returns the listener used to catch all mouse events produced in this
MapControlinstance and that redirects the calls to the current map tool.- Returns:
- the map tool listener used
-
setCurrentMapTool
Sets
mapToolas thisMapControl's current map tool.- Parameters:
mapTool- a map tool, ornullto disable the interaction with the user- See Also:
-
applyFrameRate
public void applyFrameRate()Sets the delay to the timer that refreshes this
MapControlinstance.Delay (in ms) = 1000 / getDrawFrameRate()- See Also:
-
isDrawAnimationEnabled
public static boolean isDrawAnimationEnabled()Determines if its enabled the repaint that invokes the timer according to
.invalid reference
#getDrawFrameRate()- Returns:
trueif its enabled; otherwisefalse
-
setDrawAnimationEnabled
public static void setDrawAnimationEnabled(boolean drawAnimationEnabled) Sets if its enabled the repaint that invokes the timer according to
.invalid reference
#getDrawFrameRate()- Parameters:
drawAnimationEnabled-trueto enable the mode; otherwisefalse
-
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
Gets the tool used in combination with the current tool of this
MapControl.- Returns:
- the tool used in combination with the
currentMapTool;nullif there is no combined tool
-
setCombinedTool
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 ofMapControl
-
addCombinedBehavior
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
toolwas already stored as a combined tool, doesn't adds it.- Parameters:
tool- a new tool to be used combined with the current tool
-
removeCombinedTool
Removes the tool
toolused in combination with the current tool of thisMapControl. -
initializeGrid
public void initializeGrid()Updates the grid on the
ViewPortof the associatedMapControlobject according the values in the.invalid reference
com.iver.cit.gvsig.gui.cad.CADToolAdapter.prefs.PreferencesThe preferences are:
- Show/hide the grid.
- Adjust or not the grid.
- Horizontal ( X ) line separation.
- Vertical ( Y ) line separation.
-
setAdjustGrid
public void setAdjustGrid(boolean adjustGrid) -
setGridVisibility
public void setGridVisibility(boolean showGrid) -
isRefentEnabled
public boolean isRefentEnabled()Determines if snap tools are enabled or disabled.- Returns:
trueto enable the snap tools;falseto disable them- See Also:
-
calculateSnapPoint
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
bForceCoordattribute for the next draw of the mouse's cursor.- Parameters:
point- current mouse 2D position
-
setRefentEnabled
public void setRefentEnabled(boolean activated) Sets the snap tools enabled or disabled.- Parameters:
activated-trueto enable the snap tools;falseto disable them- See Also:
-
getGrid
-
update
- Specified by:
updatein interfaceorg.gvsig.tools.observer.Observer
-
getAdjustedPoint
- Returns:
- the adjustedPoint
-
getMapAdjustedPoint
- Returns:
- the mapAdjustedPoint
-
convertToMapPoint
-
getPoint
Gets the selected point. If the snapping is enabled it returns the selected point.- Returns:
- The selected point
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.gvsig.tools.dispose.Disposable
-
isDefaultMouseWheelEnabled
public boolean isDefaultMouseWheelEnabled() -
setDefaultMouseWheelEnabled
public void setDefaultMouseWheelEnabled(boolean defaultMouseWheelEnabled) -
addChangeToolListener
-
getChangeToolListeners
-
removeChangeToolListener
-
removeAllChangeToolListener
public void removeAllChangeToolListener() -
hasChangeToolListeners
public boolean hasChangeToolListeners()
-