org.geotools.swing
Class JMapFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.geotools.swing.JMapFrame
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants
Direct Known Subclasses:
ShapefileViewer

public class JMapFrame
extends javax.swing.JFrame

A Swing frame containing a map display pane and (optionally) a toolbar, status bar and map layer table.

Simplest use is with the static showMap(MapContext) method:


 MapContext context = new DefaultMapContext();
 context.setTitle("Maps R Us");

 // add some layers to the MapContext...

 JMapFrame.showMap(context);
 

Since:
2.6
Author:
Michael Bedward
See Also:
MapLayerTable, StatusBar, Serialized Form

Nested Class Summary
static class JMapFrame.Tool
          Constants for available toolbar buttons used with the enableTool(org.geotools.swing.JMapFrame.Tool...) method.
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JMapFrame()
          Default constructor.
JMapFrame(MapContext context)
          Constructs a new JMapFrame object with specified context and a default renderer (an instance of StreamingRenderer).
JMapFrame(MapContext context, GTRenderer renderer)
          Constructs a new JMapFrame object with specified context and renderer
 
Method Summary
 void enableLayerTable(boolean state)
          Set whether a map layer table will be displayed to show the list of layers in the map context and set their order, visibility and selected status.
 void enableStatusBar(boolean state)
          Set whether a status bar will be displayed to display cursor position and map bounds.
 void enableTool(JMapFrame.Tool... tool)
          This method is an alternative to enableToolBar(boolean).
 void enableToolBar(boolean state)
          Set whether a toolbar, with a basic set of map tools, will be displayed (default is false).
 MapContext getMapContext()
          Get the map context associated with this frame.
 JMapPane getMapPane()
          Provides access to the instance of JMapPane being used by this frame.
 GTRenderer getRenderer()
          Get the renderer being used by this frame.
 javax.swing.JToolBar getToolBar()
          Provides access to the toolbar being used by this frame.
 void initComponents()
          Creates and lays out the frame's components that have been specified with the enable methods (e.g.
 void setMapContext(MapContext context)
          Set the MapContext object used by this frame.
 void setRenderer(GTRenderer renderer)
          Set the renderer to be used by this frame.
 void setVisible(boolean state)
          Calls initComponents() if it has not already been called explicitly to construct the frame's components before showing the frame.
static void showMap(MapContext context)
          Creates a new JMapFrame object with a toolbar, map pane and status bar; sets the supplied MapContext; and displays the frame on the AWT event dispatching thread.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

JMapFrame

public JMapFrame()
Default constructor. Creates a JMapFrame with no context or renderer set


JMapFrame

public JMapFrame(MapContext context)
Constructs a new JMapFrame object with specified context and a default renderer (an instance of StreamingRenderer).

Parameters:
context - the map context with layers to be displayed

JMapFrame

public JMapFrame(MapContext context,
                 GTRenderer renderer)
Constructs a new JMapFrame object with specified context and renderer

Parameters:
context - the map context with layers to be displayed
renderer - the renderer to be used
Method Detail

showMap

public static void showMap(MapContext context)
Creates a new JMapFrame object with a toolbar, map pane and status bar; sets the supplied MapContext; and displays the frame on the AWT event dispatching thread. The context's title is used as the frame's title.

Parameters:
context - the map context containing the layers to display

enableToolBar

public void enableToolBar(boolean state)
Set whether a toolbar, with a basic set of map tools, will be displayed (default is false). Calling this with state == true is equivalent to calling enableTool(org.geotools.swing.JMapFrame.Tool...) with all JMapFrame.Tool constants.

Parameters:
state - whether the toolbar is required

enableTool

public void enableTool(JMapFrame.Tool... tool)
This method is an alternative to enableToolBar(boolean). It requests that a tool bar be created with specific tools, identified by JMapFrame.Tool constants.
 myMapFrame.enableTool(Tool.PAN, Tool.ZOOM);
 

Parameters:
tool - one or more JMapFrame.Tool constants

enableStatusBar

public void enableStatusBar(boolean state)
Set whether a status bar will be displayed to display cursor position and map bounds.

Parameters:
state - whether the status bar is required.

enableLayerTable

public void enableLayerTable(boolean state)
Set whether a map layer table will be displayed to show the list of layers in the map context and set their order, visibility and selected status.

Parameters:
state - whether the map layer table is required.

setVisible

public void setVisible(boolean state)
Calls initComponents() if it has not already been called explicitly to construct the frame's components before showing the frame.

Overrides:
setVisible in class java.awt.Window
Parameters:
state - true to show the frame; false to hide.

initComponents

public void initComponents()
Creates and lays out the frame's components that have been specified with the enable methods (e.g. enableToolBar(boolean) ). If not called explicitly by the client this method will be invoked by setVisible(boolean) when the frame is first shown.


getMapContext

public MapContext getMapContext()
Get the map context associated with this frame. Returns null if no map context has been set explicitly with the constructor or setMapContext(org.geotools.map.MapContext).

Returns:
the current MapContext object

setMapContext

public void setMapContext(MapContext context)
Set the MapContext object used by this frame.

Parameters:
context - a MapContext instance
Throws:
java.lang.IllegalArgumentException - if context is null

getRenderer

public GTRenderer getRenderer()
Get the renderer being used by this frame. Returns null if no renderer was set via the constructor or setRenderer(org.geotools.renderer.GTRenderer).

Returns:
the current GTRenderer object

setRenderer

public void setRenderer(GTRenderer renderer)
Set the renderer to be used by this frame.

Parameters:
renderer - a GTRenderer instance
Throws:
java.lang.IllegalArgumentException - if renderer is null

getMapPane

public JMapPane getMapPane()
Provides access to the instance of JMapPane being used by this frame.

Returns:
the JMapPane object

getToolBar

public javax.swing.JToolBar getToolBar()
Provides access to the toolbar being used by this frame. If initComponents() has not been called yet this method will invoke it.

Returns:
the toolbar or null if the toolbar was not enabled


Copyright © 1996-2010 Geotools. All Rights Reserved.