dods.clients.importwizard.TMAP.map
Class MapCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by dods.clients.importwizard.TMAP.map.MapCanvas
All Implemented Interfaces:
MapConstants, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, SwingConstants

public class MapCanvas
extends JLabel
implements MapConstants, MouseListener, MouseMotionListener

Modified to a JLabel class modified by Sheila (zhifang) Jiang

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 MapGrid grid
          The current grid being used by the map.
 double max_img_scaling
          The maximum image scaling to be allowed.
 double min_img_scaling
          The minimum image scaling to be allowed.
 boolean pan_down
          Flag to indicate movement of the base image is desired.
 boolean pan_down_fast
          Flag to indicate movement of the base image is desired.
 boolean pan_left
          Flag to indicate movement of the base image is desired.
 boolean pan_left_fast
          Flag to indicate movement of the base image is desired.
 boolean pan_right
          Flag to indicate movement of the base image is desired.
 boolean pan_right_fast
          Flag to indicate movement of the base image is desired.
 boolean pan_up
          Flag to indicate movement of the base image is desired.
 boolean pan_up_fast
          Flag to indicate movement of the base image is desired.
 MapRegion[] regionArray
           
 boolean tool_driven
          Flag determining whether scrolling is controlled by the active MapTool or externally by the application programmer.
 MapTool[] toolArray
           
 double zoom_factor
          The zoom factor to be applied when using the methods zoom_in() and zoom_out().
 
Fields inherited from class javax.swing.JLabel
labelFor
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface dods.clients.importwizard.TMAP.map.MapConstants
DEPTH_AXIS, HEIGHT_AXIS, HI, LATITUDE_AXIS, LO, LONGITUDE_AXIS, MID, PT, SNAP_MID, SNAP_ON, TIME_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MapCanvas(ImageIcon image_icon, int width, int height, MapTool[] toolArray, MapGrid grid)
          Constructs and initializes a MapCanvas with the specified parameters.
MapCanvas(ImageIcon image_icon, int width, int height, MapTool[] toolArray, MapGrid grid, int x, int y, double scaling)
          Constructs and initializes a MapCanvas with the specified parameters.
 
Method Summary
 void center_tool(double zoom_factor)
           
 Image get_image()
           
 String get_internals()
          Returns a string with information for initial positioning and and sizing of the base map.
 MapGrid getGrid()
           
 Dimension getMinimumSize()
          This method is necessary for layout managers.
 Dimension getPreferredSize()
          This method is necessary for layout managers.
 int getSelected()
           
 MapTool getTool()
           
 MapTool getTool(int i)
           
 void mouseClicked(MouseEvent evt)
           
 void mouseDragged(MouseEvent evt)
           
 void mouseEntered(MouseEvent evt)
           
 void mouseExited(MouseEvent evt)
           
 void mouseMoved(MouseEvent evt)
           
 void mousePressed(MouseEvent evt)
           
 void mouseReleased(MouseEvent evt)
           
 void newToolFromOld(int i, MapTool new_tool, MapTool old_tool)
           
 void paintComponent(Graphics g)
          Paints the canvas with the base image and the current tool.
 boolean panning()
           
 void resume_scrolling()
          Resumes scrolling.
 void scroll_X(int delta)
          Causes the map to scroll an amount in the X direction.
 void scroll_Y(int delta)
          Causes the map to scroll an amount in the Y direction.
 void selectTool(int id)
           
 void setGrid(MapGrid grid)
           
 void setImage(ImageIcon image)
           
 void setRegionArray(MapRegion[] regionArray)
           
 void setTool(int i, MapTool tool)
           
 void setToolArray(MapTool[] toolArray)
           
 void suspend_scrolling()
          Suspends scrolling.
 void update(Graphics g)
          Overrides the default method and omits the background fill.
 void zoom_in()
           
 void zoom_out()
          Decreases the base image size the internally maintained zoom factor.
 void zoom(double zoom_factor)
          Increases/decreases the base image size by the specified zoom factor.
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, 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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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
 
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pan_down

public boolean pan_down
Flag to indicate movement of the base image is desired.


pan_down_fast

public boolean pan_down_fast
Flag to indicate movement of the base image is desired.


pan_left

public boolean pan_left
Flag to indicate movement of the base image is desired.


pan_left_fast

public boolean pan_left_fast
Flag to indicate movement of the base image is desired.


pan_right

public boolean pan_right
Flag to indicate movement of the base image is desired.


pan_right_fast

public boolean pan_right_fast
Flag to indicate movement of the base image is desired.


pan_up

public boolean pan_up
Flag to indicate movement of the base image is desired.


pan_up_fast

public boolean pan_up_fast
Flag to indicate movement of the base image is desired.


tool_driven

public boolean tool_driven
Flag determining whether scrolling is controlled by the active MapTool or externally by the application programmer.


zoom_factor

public double zoom_factor
The zoom factor to be applied when using the methods zoom_in() and zoom_out().


max_img_scaling

public double max_img_scaling
The maximum image scaling to be allowed. It doesn't make sense to scale more than 2X the original image


min_img_scaling

public double min_img_scaling
The minimum image scaling to be allowed. This will be set automatically when the MapCanvas is created. The initial min_img_scaling will be such that the map cannot be made smaller than the MapCanvas area in both the X and Y dimensions.


toolArray

public MapTool[] toolArray

regionArray

public MapRegion[] regionArray

grid

public MapGrid grid
The current grid being used by the map.

Constructor Detail

MapCanvas

public MapCanvas(ImageIcon image_icon,
                 int width,
                 int height,
                 MapTool[] toolArray,
                 MapGrid grid)
Constructs and initializes a MapCanvas with the specified parameters.

Parameters:
base_image - the image over which the tool will be drawn
width - the width in pixels of the MapCanvas
height - the height in pixels of the MapCanvas
tool - the tool for user interaction
grid - the grid associated with the underlying basemap.

MapCanvas

public MapCanvas(ImageIcon image_icon,
                 int width,
                 int height,
                 MapTool[] toolArray,
                 MapGrid grid,
                 int x,
                 int y,
                 double scaling)
Constructs and initializes a MapCanvas with the specified parameters.

Parameters:
base_image - the image over which the tool will be drawn
width - the width in pixels of the MapCanvas
height - the height in pixels of the MapCanvas
tool - the tool for user interaction
grid - the grid associated with the underlying basemap.
Method Detail

panning

public boolean panning()

update

public void update(Graphics g)
Overrides the default method and omits the background fill.

Overrides:
update in class JComponent
Parameters:
g - the specified Graphics window

paintComponent

public void paintComponent(Graphics g)
Paints the canvas with the base image and the current tool.

Overrides:
paintComponent in class JComponent
Parameters:
g - the specified Graphics window

scroll_X

public void scroll_X(int delta)
Causes the map to scroll an amount in the X direction.

Parameters:
delta - the number of pixels to scroll.

scroll_Y

public void scroll_Y(int delta)
Causes the map to scroll an amount in the Y direction.

Parameters:
delta - the number of pixels to scroll.

suspend_scrolling

public void suspend_scrolling()
Suspends scrolling.

Scrolling can be resumed with resume_scrolling().


resume_scrolling

public void resume_scrolling()
Resumes scrolling.

Scrolling can be suspended with suspend_scrolling().


mouseMoved

public void mouseMoved(MouseEvent evt)
Specified by:
mouseMoved in interface MouseMotionListener

mousePressed

public void mousePressed(MouseEvent evt)
Specified by:
mousePressed in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent evt)
Specified by:
mouseDragged in interface MouseMotionListener

mouseReleased

public void mouseReleased(MouseEvent evt)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent evt)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent evt)
Specified by:
mouseExited in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent evt)
Specified by:
mouseClicked in interface MouseListener

zoom_in

public void zoom_in()
             throws MaxZoomException,
                    MinZoomException
Throws:
MaxZoomException
MinZoomException

zoom_out

public void zoom_out()
              throws MaxZoomException,
                     MinZoomException
Decreases the base image size the internally maintained zoom factor.

Throws:
MaxZoomException - already at max zoom.
MinZoomException - already at min zoom.

zoom

public void zoom(double zoom_factor)
          throws MaxZoomException,
                 MinZoomException
Increases/decreases the base image size by the specified zoom factor.

Parameters:
zoom_factor. -
Throws:
MaxZoomException - already at max zoom.
MinZoomException - already at min zoom.

center_tool

public void center_tool(double zoom_factor)

getSelected

public int getSelected()

getTool

public MapTool getTool()

getTool

public MapTool getTool(int i)

newToolFromOld

public void newToolFromOld(int i,
                           MapTool new_tool,
                           MapTool old_tool)

setTool

public void setTool(int i,
                    MapTool tool)

setToolArray

public void setToolArray(MapTool[] toolArray)

selectTool

public void selectTool(int id)

setRegionArray

public void setRegionArray(MapRegion[] regionArray)

setGrid

public void setGrid(MapGrid grid)

getGrid

public MapGrid getGrid()

setImage

public void setImage(ImageIcon image)

get_image

public Image get_image()

get_internals

public String get_internals()
Returns a string with information for initial positioning and and sizing of the base map. This information can be used to initialize a new MapCanvas with the constructor which includes the x, y and scaling parameters.


getMinimumSize

public Dimension getMinimumSize()
This method is necessary for layout managers.

Overrides:
getMinimumSize in class JComponent

getPreferredSize

public Dimension getPreferredSize()
This method is necessary for layout managers.

Overrides:
getPreferredSize in class JComponent