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:
#cancelDrawing().MapControl's MapContrext will be that one which
will draw the graphical information, and, if supports, which could cancel its
drawing subprocess.#drawMap(boolean).#rePaintDirtyLayers().GraphicLayer, calling
#drawGraphics().Tools:
A developer can:
#addMapTool(String, Behavior).#addMapTool(String, Behavior).#getCurrentMapTool().#getCurrentTool().#getMapTool(String).#getMapToolsKeySet().#getNamesMapTools().#hasTool(String).#setTool(String).#setPrevTool().#setCurrentMapTool(Behavior).#setDrawFrameRate(int) and #applyFrameRate().#getDrawFrameRate().
#isDrawAnimationEnabled().#setDrawAnimationEnabled(boolean).#getCanceldraw().#getCombinedTool().#setCombinedTool(Behavior).#removeCombinedTool().Exception listener:
Adding an ExceptionListener, can get notification about any
exception produced:
Other:
Other useful capabilities of MapControl:
MapContext instance and its layers): #cancelDrawing().ToolListener): #zoomIn().ToolListener): #zoomOut().MapControl.CancelDraw,
MapControl.Drawer,
MapControl.MapContextListener,
MapControl.MapToolListener,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
class |
MapControl.AddLayerEvent |
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
|
class |
MapControl.MapToolListener
Listens all kind of mouse events produced in
MapControl, and invokes its current map tool (
MapControl#getCurrentMapTool()
to simulate a behavior. |
javax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
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. |
static int |
PAINT_PARTIAL_DRAWING_LAYERS |
static int |
PAINT_WHEN_DRAW_LAYERS_IS_COMPLETED |
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. |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
MapControl()
Creates a new
MapControl instance 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 CancelDraw object to notify
MapContext's layers if can continue processing the drawn or
must cancel it.
Creates a new MapContext with a new
ViewPort in the default projection.
Creates a new CommandListener for edition
operations.
Creates a new MapToolListener, and associates
it as a listener of whatever kind of mouse events produced in this
component.
Creates a new Drawer2 for managing the painting
requests.
Creates a new timer that will invoke refresh this component
drawFrameRate per second, when is running a drawing process,
and its enabled drawAnimationEnabled.
|
MapControl(org.gvsig.fmap.mapcontext.MapContext theMapContext) |
| Modifier and Type | Method and Description |
|---|---|
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 |
addChangeToolListener(javax.swing.event.ChangeListener listener) |
void |
addCombinedBehavior(Behavior tool)
Adds a new tool as combined tool.
|
void |
addExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o) |
void |
addLayer(org.gvsig.fmap.mapcontext.layers.FLayer layer) |
void |
addLayerListener(java.awt.event.ActionListener al) |
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.
|
javax.swing.event.ChangeListener[] |
getChangeToolListeners() |
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. |
int |
getPaintMode() |
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 |
hasChangeToolListeners() |
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. |
boolean |
isDefaultMouseWheelEnabled() |
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 |
removeAllChangeToolListener() |
void |
removeChangeToolListener(javax.swing.event.ChangeListener listener) |
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. |
void |
setDefaultMouseWheelEnabled(boolean defaultMouseWheelEnabled) |
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 |
setPaintMode(int paintMode) |
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.
|
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, 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, updateUIadd, 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, validateTreeaction, 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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final int ACTUALIZADO
One of the possible status of MapControl. Determines that
all visible information has been drawn and its updated.
protected java.awt.geom.Point2D adjustedPoint
ViewPort.fromMapPoint(Point2D)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.
getCurrentMapTool(),
getCurrentTool(),
setTool(String)protected java.lang.String currentTool
Name of the tool used currently to interact with this component.
getCurrentTool(),
setTool(String)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.
protected static final org.gvsig.fmap.geom.GeometryManager geomManager
protected java.awt.geom.Point2D mapAdjustedPoint
MapControl#toMapPointprotected static MapControlManager mapControlManager
protected MapControl.MapToolListener mapToolListener
Listener of all kind of mouse events produced in this component.
Delegates each mouse event to the current map tool.
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.
public static final int PAINT_PARTIAL_DRAWING_LAYERS
public static final int PAINT_WHEN_DRAW_LAYERS_IS_COMPLETED
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.
After, the view port will change adapting itself according the current projection and the extent.
getViewPort(),
ViewPortpublic MapControl()
Creates a new MapControl instance with the following
characteristics:
JComponent .JComponent.setOpaque(boolean) ).OUTDATED .CancelDraw object to notify
MapContext's layers if can continue processing the drawn or
must cancel it.MapContext with a new
ViewPort in the default projection.CommandListener for edition
operations.MapToolListener, and associates
it as a listener of whatever kind of mouse events produced in this
component.Drawer2 for managing the painting
requests.drawFrameRate per second, when is running a drawing process,
and its enabled drawAnimationEnabled.public MapControl(org.gvsig.fmap.mapcontext.MapContext theMapContext)
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.
name - name to identify the behavior to addtool - the behavior to addaddBehavior(String, Behavior[]),
getNamesMapTools(),
getMapToolsKeySet(),
hasTool(String)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.
name - name to identify the compound behavior to addtools - the compound behavior to addaddBehavior(String, Behavior),
getNamesMapTools(),
getMapToolsKeySet(),
hasTool(String)public void addChangeToolListener(javax.swing.event.ChangeListener listener)
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.
tool - a new tool to be used combined with the current toolpublic void addExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o)
ExceptionHandlingSupport.addExceptionListener(ExceptionListener)public void addLayer(org.gvsig.fmap.mapcontext.layers.FLayer layer)
public void addLayerListener(java.awt.event.ActionListener al)
public void applyFrameRate()
Sets the delay to the timer that refreshes this MapControl
instance.
Delay (in ms) = 1000 / getDrawFrameRate()
#getDrawFrameRate(),
#setDrawFrameRate(int)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.
point - current mouse 2D positionpublic 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.
public void commandRefresh()
public void commandRepaint()
public void componentHidden(java.awt.event.ComponentEvent e)
componentHidden in interface java.awt.event.ComponentListenerComponentListener.componentHidden(java.awt.event.ComponentEvent)public void componentMoved(java.awt.event.ComponentEvent e)
componentMoved in interface java.awt.event.ComponentListenerComponentListener.componentMoved(java.awt.event.ComponentEvent)public void componentResized(java.awt.event.ComponentEvent e)
componentResized in interface java.awt.event.ComponentListenerComponentListener.componentResized(java.awt.event.ComponentEvent)public void componentShown(java.awt.event.ComponentEvent e)
componentShown in interface java.awt.event.ComponentListenerComponentListener.componentShown(java.awt.event.ComponentEvent)public void dispose()
dispose in interface org.gvsig.tools.dispose.Disposablepublic 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.
doClear - true if needs clearing the background color
before drawing the mapcancelDrawing(),
FLayers#setDirty(boolean)public java.awt.geom.Point2D getAdjustedPoint()
public MapControl.CancelDraw getCanceldraw()
Gets the shared object that determines if a drawing process must be cancelled or can continue.
public javax.swing.event.ChangeListener[] getChangeToolListeners()
public Behavior getCombinedTool()
Gets the tool used in combination with the current tool of this
MapControl.
currentMapTool
; null if there is
no combined toolpublic 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.
toolName - name of a registered behaviorgetCurrentTool(),
setTool(String)public java.lang.String getCurrentTool()
Returns the name of the current selected tool on this MapControl
getCurrentMapTool(),
setTool(String)public Grid getGrid()
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.
null if isn't
already createdBufferedImagepublic java.awt.geom.Point2D getMapAdjustedPoint()
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.
MapContext, that includes the
ViewPort used to project the
graphical information, and display it in the available areaMapContext,
setMapContext(MapContext)public MapControlDrawer getMapControlDrawer()
public Behavior getMapTool(java.lang.String name)
Gets the Behavior registered in this component, identified
by name.
name - name of a registered behaviorname, or null if
no one has that identifieraddBehavior(String, Behavior),
addBehavior(String, Behavior[]),
hasTool(String)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.
public java.util.Set getMapToolsKeySet()
Returns a set view of the keys that identified the tools registered.
HashMap.keySet(),
getNamesMapTools(),
addBehavior(String, Behavior),
addBehavior(String, Behavior[])public java.util.HashMap getNamesMapTools()
Returns all registered Behavior that can define a way to
work with this MapControl.
Behavior to this MapControladdBehavior(String, Behavior),
addBehavior(String, Behavior[]),
getMapToolsKeySet(),
hasTool(String)public int getPaintMode()
public java.awt.geom.Point2D getPoint()
public org.cresques.cts.IProjection getProjection()
Gets this component's MapContext projection.
MapContext projectionMapContext.getProjection(),
setProjection(IProjection)public org.gvsig.fmap.mapcontext.ViewPort getViewPort()
Gets the ViewPort of this component's MapContext .
MapContext.getViewPort()public boolean hasChangeToolListeners()
public boolean hasTool(java.lang.String toolName)
Returns true if this component contains a tool identified by
toolName.
toolName - identifier of the tooltrue if this component contains a tool identified by
toolName; otherwise falseaddBehavior(String, Behavior),
addBehavior(String, Behavior[])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:
public boolean isDefaultMouseWheelEnabled()
public static boolean isDrawAnimationEnabled()
Determines if its enabled the repaint that invokes the timer according to
#getDrawFrameRate().
true if its enabled; otherwise falsepublic boolean isRefentEnabled()
true to enable the snap tools; false to
disable themsetRefentEnabled(boolean)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.
paintComponent in class javax.swing.JComponentJComponent.paintComponent(java.awt.Graphics),
Drawer2public void removeAllChangeToolListener()
public void removeChangeToolListener(javax.swing.event.ChangeListener listener)
public void removeCombinedTool(Behavior tool)
Removes the tool tool used in combination with the current
tool of this MapControl.
public boolean removeExceptionListener(org.gvsig.utils.exceptionHandling.ExceptionListener o)
ExceptionHandlingSupport.removeExceptionListener(ExceptionListener)public void rePaintDirtyLayers()
Cancels any current drawing process, changing the status to
OUTDATED, and forcing repaint only the layers dirty.
cancelDrawing()public void setAdjustGrid(boolean adjustGrid)
public void setCombinedTool(Behavior combinedTool)
Sets a tool to be used in combination with the current tool of this
MapControl.
combinedTool - a tool to be used in combination with the current tool of
MapControlpublic void setCurrentMapTool(Behavior mapTool)
Sets mapTool as this MapControl's current map
tool.
mapTool - a map tool, or null to disable the interaction
with the usergetCurrentMapTool(),
getCurrentTool(),
setTool(String),
setPrevTool(),
addBehavior(String, Behavior),
addBehavior(String, Behavior[])public void setDefaultMouseWheelEnabled(boolean defaultMouseWheelEnabled)
public static void setDrawAnimationEnabled(boolean drawAnimationEnabled)
Sets if its enabled the repaint that invokes the timer according to
#getDrawFrameRate().
drawAnimationEnabled - true to enable the mode; otherwise
falsepublic void setGridVisibility(boolean showGrid)
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.
model - this component's MapContext, that includes the
ViewPort.MapContext,
getMapContext()public void setMapControlDrawer(MapControlDrawer mapControlDrawer)
mapControlDrawer - the mapControlDrawer to setpublic void setPaintMode(int paintMode)
public void setPrevTool()
Equivalent operation to undo.
Exchanges the previous tool with the current one.
public void setProjection(org.cresques.cts.IProjection proj)
Sets the projection to this component's MapContext.
proj - the kind of projection to this component's MapContextMapContext.setProjection(IProjection),
getProjection()public void setRefentEnabled(boolean activated)
activated - true to enable the snap tools; false
to disable themisRefentEnabled()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.
toolName - name of a registered behaviorgetCurrentMapTool(),
getCurrentTool()protected void throwException(java.lang.Throwable t)
ExceptionHandlingSupport.throwException(Throwable)public void update(org.gvsig.tools.observer.Observable observable,
java.lang.Object notification)
update in interface org.gvsig.tools.observer.Observerpublic 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.
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.
zoomIn()Copyright © 2021 gvSIG Association. All rights reserved.