public class MapControl extends JComponent implements ComponentListener, Observer, 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()
.Modifier and Type | Class and Description |
---|---|
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. |
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
ACTUALIZADO
One of the possible status of
MapControl . |
protected 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 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 GeometryManager |
geomManager |
protected 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 Map<String,Behavior> |
namesMapTools
All registered
Behavior that can define a way to work with
this MapControl . |
protected String |
prevTool
Name of the previous tool used.
|
protected ViewPort |
vp
Reference to the
ViewPort of the MapContext of this component. |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
MapControl()
Creates a new
MapControl instance with the following
characteristics:
Name: MapControl . |
MapControl(MapContext theMapContext) |
Modifier and Type | Method and Description |
---|---|
void |
addBehavior(String name,
Behavior tool)
Registers a new behavior to this component.
|
void |
addBehavior(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(ExceptionListener o) |
void |
applyFrameRate()
Sets the delay to the timer that refreshes this
MapControl
instance. |
void |
calculateSnapPoint(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(ComponentEvent e) |
void |
componentMoved(ComponentEvent e) |
void |
componentResized(ComponentEvent e) |
void |
componentShown(ComponentEvent e) |
void |
dispose()
Disposes the current object, to allow it to close and dispose any used
resources.
|
void |
drawGraphics()
Deprecated.
use
drawMap(boolean) instead, or even
better getMapContext() .invalidate(). |
void |
drawMap(boolean doClear)
Forces repaint all visible graphical information in this component.
|
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 . |
String |
getCurrentTool()
Returns the name of the current selected tool on this MapControl
|
Grid |
getGrid() |
BufferedImage |
getImage()
Gets the
BufferedImage used to accelerate the draw
of new ''frames'' with changes, or new graphical items in this component. |
Point2D |
getMapAdjustedPoint() |
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(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. |
Set |
getMapToolsKeySet()
Returns a set view of the keys that identified the tools registered.
|
HashMap |
getNamesMapTools()
Returns all registered
Behavior that can define a way to
work with this MapControl . |
Point2D |
getPoint()
Gets the selected point.
|
IProjection |
getProjection()
Gets this component's
MapContext projection. |
ViewPort |
getViewPort()
Gets the
ViewPort of this component's MapContext . |
boolean |
hasTool(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(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(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(MapContext model)
Sets a
MapContext to this component. |
void |
setMapControlDrawer(MapControlDrawer mapControlDrawer) |
void |
setPrevTool()
Equivalent operation to undo.
|
void |
setProjection(IProjection proj)
Sets the projection to this component's
MapContext . |
void |
setRefentEnabled(boolean activated)
Sets the snap tools enabled or disabled.
|
void |
setTool(String toolName)
Sets as current active
Behavior associated to this
component, that one which is registered and identified by
toolName . |
protected void |
throwException(Throwable t) |
void |
update(Observable observable,
Object notification)
Called whenever a
Observable object is changed and this
Observer has registered on it to receive notifications. |
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, 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, 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, updateUI
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
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, 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
protected static final GeometryManager geomManager
public static final int ACTUALIZADO
One of the possible status of MapControl
. Determines that
all visible information has been drawn and its updated.
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 Map<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.
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 String currentTool
Name of the tool used currently to interact with this component.
getCurrentTool()
,
setTool(String)
protected 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()
,
ViewPort
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 String prevTool
Name of the previous tool used.
protected Point2D adjustedPoint
ViewPort.fromMapPoint(Point2D)
protected static MapControlManager mapControlManager
protected Point2D mapAdjustedPoint
MapControl#toMapPoint
public 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(MapContext theMapContext)
public void setMapContext(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 MapControlDrawer getMapControlDrawer()
public void setMapControlDrawer(MapControlDrawer mapControlDrawer)
mapControlDrawer
- the mapControlDrawer to setpublic IProjection getProjection()
Gets this component's MapContext
projection.
MapContext
projectionMapContext.getProjection()
,
setProjection(IProjection)
public void setProjection(IProjection proj)
Sets the projection to this component's MapContext
.
proj
- the kind of projection to this component's MapContext
MapContext.setProjection(IProjection)
,
getProjection()
public 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 void addBehavior(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(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 Behavior getMapTool(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 Set getMapToolsKeySet()
Returns a set view of the keys that identified the tools registered.
HashMap.keySet()
,
getNamesMapTools()
,
addBehavior(String, Behavior)
,
addBehavior(String, Behavior[])
public boolean hasTool(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 false
addBehavior(String, Behavior)
,
addBehavior(String, Behavior[])
public void setTool(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()
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.
toolName
- name of a registered behaviorgetCurrentTool()
,
setTool(String)
public String getCurrentTool()
Returns the name of the current selected tool on this MapControl
getCurrentMapTool()
,
setTool(String)
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.
protected void paintComponent(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 JComponent
JComponent.paintComponent(java.awt.Graphics)
,
Drawer2
public 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 createdBufferedImage
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.
doClear
- true
if needs clearing the background color
before drawing the mapcancelDrawing()
,
FLayers#setDirty(boolean)
public void rePaintDirtyLayers()
Cancels any current drawing process, changing the status to
OUTDATED
, and forcing repaint only the layers dirty.
cancelDrawing()
public void drawGraphics()
public void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
ComponentListener.componentHidden(java.awt.event.ComponentEvent)
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
ComponentListener.componentMoved(java.awt.event.ComponentEvent)
public void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
ComponentListener.componentResized(java.awt.event.ComponentEvent)
public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
ComponentListener.componentShown(java.awt.event.ComponentEvent)
public void addExceptionListener(ExceptionListener o)
public boolean removeExceptionListener(ExceptionListener o)
protected void throwException(Throwable t)
public ViewPort getViewPort()
Gets the ViewPort
of this component's MapContext
.
MapContext.getViewPort()
public HashMap getNamesMapTools()
Returns all registered Behavior
that can define a way to
work with this MapControl
.
Behavior
to this MapControl
addBehavior(String, Behavior)
,
addBehavior(String, Behavior[])
,
getMapToolsKeySet()
,
hasTool(String)
public void commandRepaint()
public void commandRefresh()
public void setPrevTool()
Equivalent operation to undo.
Exchanges the previous tool with the current one.
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.
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()
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 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 applyFrameRate()
Sets the delay to the timer that refreshes this MapControl
instance.
Delay (in ms) = 1000 / getDrawFrameRate()
#getDrawFrameRate()
,
#setDrawFrameRate(int)
public static boolean isDrawAnimationEnabled()
Determines if its enabled the repaint that invokes the timer according to
#getDrawFrameRate()
.
true
if its enabled; otherwise false
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
false
public MapControl.CancelDraw getCanceldraw()
Gets the shared object that determines if a drawing process must be cancelled or can continue.
public Behavior getCombinedTool()
Gets the tool used in combination with the current tool of this
MapControl
.
currentMapTool
; null
if there is
no combined toolpublic 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
MapControl
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 removeCombinedTool(Behavior tool)
Removes the tool tool
used in combination with the current
tool of this MapControl
.
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 void setAdjustGrid(boolean adjustGrid)
public void setGridVisibility(boolean showGrid)
public boolean isRefentEnabled()
true
to enable the snap tools; false
to
disable themsetRefentEnabled(boolean)
public void calculateSnapPoint(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 setRefentEnabled(boolean activated)
activated
- true
to enable the snap tools; false
to disable themisRefentEnabled()
public Grid getGrid()
public void update(Observable observable, Object notification)
Observer
Observable
object is changed and this
Observer
has registered on it to receive notifications.
Implementations of this method will be called for each simple notification or, if a complex notification is created, for each of the child notifications.
In the latter case, don't assume any ordering in the notification between
this Observer
and other Observer
s listening to the same
Observable
.
In a complex notification scenario, if you want to receive only the
complex notification and not each of the child notifications, just
implement the ComplexObserver
and prepare this method
implementation to handle receiving DefaultComplexNotification
instances
as well as direct notification objects.
public Point2D getAdjustedPoint()
public Point2D getMapAdjustedPoint()
public Point2D getPoint()
public void dispose()
Disposable
NOTE:After calling this method, the object may not be usable anymore.
dispose
in interface Disposable