Package hec.map
Class MapCanvas
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
hec.map.MapCanvas
- All Implemented Interfaces:
ComponentListener
,ImageObserver
,MenuContainer
,Serializable
,Runnable
,EventListener
,Accessible
Geo-referenced drawing area for the MapPanel.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
the background color of the MapCanvasprotected boolean
flag indicating whether grids are drawn or not.protected String
Descriptionprotected MessageFormat
Descriptionstatic String
protected boolean
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_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMapLabelItem
(MapLabelItem newlabel) adds a label to the labelitem setvoid
addMapLegendItem
(LegendItem item) void
addMapTextObject
(MapTextObject textobj) Adds a feature to the MapTextObject attribute of the MapCanvas objectvoid
Method Descriptionvoid
Method Descriptionvoid
Method Descriptionvoid
Method Descriptiondouble
Method Descriptionstatic double
computeMapScale
(int localWidth, double worldViewWidth) Creates a new Image Buffer that will be the "double" buffere for this canvas.void
drawLegendItems
(Graphics g, MapScale scale) void
getBackgroundColor Get the color to be used as the background for the canvas.Returns the graphics context for the image bufferboolean
getDrawGrids Gets whether grids should be drawn on the canvasGets the MapMouseAdapter attribute of the MapCanvas objectget the current MapMouseAdapterGets the ToolTipText attribute of the MapCanvas objectboolean
imageUpdate
(Image img, int infoflags, int x, int y, int width, int height) Method Descriptionvoid
Overrides the default paint to call the paintMap function.void
void
void
paintCoordinateGrid
(Graphics bg, MapScale scale) Method Descriptionvoid
paintGlyph
(MapGlyph glyph, int i, int mapScale, Graphics bg, MapScale scale) void
paintGlyphs
(Graphics g, Image imageBuffer) protected void
Draws the map to the specified graphics context.void
paintMapBorders
(MapGlyph glyph, MapScale scale, Graphics bg) protected void
void
Method Descriptionboolean
void
repaint()
void
run()
Paints map from within a thread.void
setBackgroundColor
(Color color) setBackgroundColor Set the color to be used as the background for the canvas.void
void
setDrawGrids
(boolean drawGrids) setDrawGrids Sets whether grids should be drawn on the canvassetMouseAdapter
(MapMouseAdapter adapter) Set the active mouse adapter for the canvas.void
stop()
Method Descriptionprotected void
check to make sure we have a valid image.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, 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
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
MAP_SCALE_FORMAT
Description -
m_mapScaleInformation
Description -
_backgroundColor
the background color of the MapCanvas -
_drawGrids
protected boolean _drawGridsflag indicating whether grids are drawn or not. -
USE_RENDER
-
useRenderer
protected boolean useRenderer
-
-
Constructor Details
-
MapCanvas
Create a new MapCanvas object- Parameters:
parent
- Description
-
-
Method Details
-
setMouseAdapter
Set the active mouse adapter for the canvas.- Parameters:
adapter
- The new MouseAdapter value- Returns:
- Description of the Returned Value
-
setCursor
-
getMouseAdapter
get the current MapMouseAdapter- Returns:
- the current MapMouseAdapter or null if there isn't a selected MouseAdapter
-
getImageBuffer
-
getBufferedGraphics
Returns the graphics context for the image buffer- Returns:
- The BufferedGraphics value
-
getMapMouseAdapter
Gets the MapMouseAdapter attribute of the MapCanvas object- Returns:
- The MapMouseAdapter value
-
getToolTipText
Gets the ToolTipText attribute of the MapCanvas object- Overrides:
getToolTipText
in classJComponent
- Parameters:
e
- Description- Returns:
- The ToolTipText value
-
addMapLegendItem
-
removeMapLegendItem
-
addMapTextObject
Adds a feature to the MapTextObject attribute of the MapCanvas object- Parameters:
textobj
- The feature to be added to the MapTextObject attribute
-
addMapLabelItem
adds a label to the labelitem set- Parameters:
newlabel
- The feature to be added to the MapLabelItem attribute
-
run
public void run()Paints map from within a thread. This method implements run as required by the Runnable interface. When the paint is complete, the map panel is notified that it can forget about this thread. -
redrawMaps
public void redrawMaps()Method Description -
validateImage
protected void validateImage()check to make sure we have a valid image. If we don't recreate the image.
from VolatileImage JavaDoc's:
The drawing surface of an image (the memory where the image contents actually reside) can be lost or invalidated, causing the contents of that memory to go away. The drawing surface thus needs to be restored or recreated and the contents of that surface need to be re-rendered. -
paintComponent
Overrides the default paint to call the paintMap function. This indirection is here to allow drawing to be skipped under some circumstances.- Overrides:
paintComponent
in classJComponent
- Parameters:
g
- Description of Parameter- See Also:
-
paintComponentDefault
-
drawLegendItems
-
paintComponentThreaded
-
computeMapScale
public double computeMapScale()Method Description- Returns:
- Description
-
computeMapScale
public static double computeMapScale(int localWidth, double worldViewWidth) -
imageUpdate
Method Description- Specified by:
imageUpdate
in interfaceImageObserver
- Overrides:
imageUpdate
in classComponent
- Parameters:
img
- Descriptioninfoflags
- Descriptionx
- Descriptiony
- Descriptionwidth
- Descriptionheight
- Description- Returns:
- Description
-
componentHidden
Method Description- Specified by:
componentHidden
in interfaceComponentListener
- Parameters:
e
- Description
-
componentMoved
Method Description- Specified by:
componentMoved
in interfaceComponentListener
- Parameters:
e
- Description
-
componentResized
Method Description- Specified by:
componentResized
in interfaceComponentListener
- Parameters:
e
- Description
-
createImageBuffer
Creates a new Image Buffer that will be the "double" buffere for this canvas. If the size of this component is (0,0) then the Image Buffer will be NULL -
componentShown
Method Description- Specified by:
componentShown
in interfaceComponentListener
- Parameters:
e
- Description
-
paintCoordinateGrid
Method Description- Parameters:
bg
- Descriptionscale
- Description
-
stop
public void stop()Method Description -
paintMap
Draws the map to the specified graphics context.- Parameters:
g
- Description of Parameter
-
repaint
public void repaint() -
paintMapDefault
-
paintGlyphs
-
paintGlyph
-
paintMapBorders
-
drawMapLabels
-
setBackgroundColor
setBackgroundColor Set the color to be used as the background for the canvas. By default, this is white- Parameters:
color
- The new background color
-
getBackgroundColor
getBackgroundColor Get the color to be used as the background for the canvas.- Returns:
- The background color
-
setDrawGrids
public void setDrawGrids(boolean drawGrids) setDrawGrids Sets whether grids should be drawn on the canvas- Parameters:
drawGrids
- True to draw grids, false to omit grids.
-
getDrawGrids
public boolean getDrawGrids()getDrawGrids Gets whether grids should be drawn on the canvas- Returns:
- True if grids are to be drawn, false otherwise.
-