Package org.geotools.swing
Class JMapFrame
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
,WindowConstants
public class JMapFrame extends 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(MapContent)
method:MapContent content = new MapContent(); content.setTitle("My beautiful map"); // add some layers to the MapContent... JMapFrame.showMap(content);
- Since:
- 2.6
- Author:
- Michael Bedward
- See Also:
MapLayerTable
,JMapStatusBar
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JMapFrame.Tool
Constants for available toolbar buttons used with theenableTool(org.geotools.swing.JMapFrame.Tool...)
method.-
Nested classes/interfaces inherited from class JFrame
JFrame.AccessibleJFrame
-
Nested classes/interfaces inherited from class Frame
Frame.AccessibleAWTFrame
-
Nested classes/interfaces inherited from class Window
Window.AccessibleAWTWindow, Window.Type
-
Nested classes/interfaces inherited from class Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static String
TOOLBAR_INFO_BUTTON_NAME
Name assigned to toolbar button for feature info queries.static String
TOOLBAR_PAN_BUTTON_NAME
Name assigned to toolbar button for map panning.static String
TOOLBAR_POINTER_BUTTON_NAME
Name assigned to toolbar button for default pointer.static String
TOOLBAR_RESET_BUTTON_NAME
Name assigned to toolbar button for map reset.static String
TOOLBAR_ZOOMIN_BUTTON_NAME
Name assigned to toolbar button for map zoom in.static String
TOOLBAR_ZOOMOUT_BUTTON_NAME
Name assigned to toolbar button for map zoom out.-
Fields inherited from class JFrame
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class 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 Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
-
Constructor Summary
Constructors Constructor Description JMapFrame()
Default constructor.JMapFrame(MapContent content)
Constructs a newJMapFrame
object with specified map content.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enableLayerTable(boolean enabled)
Set whether a map layer table will be displayed to show the list of layers in the map content and set their order, visibility and selected status.void
enableStatusBar(boolean enabled)
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 toenableToolBar(boolean)
.void
enableToolBar(boolean enabled)
Sets whether to display the default toolbar (default is false).MapContent
getMapContent()
Get the map content associated with this frame.JMapPane
getMapPane()
Provides access to the instance ofJMapPane
being used by this frame.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
setMapContent(MapContent content)
Set the MapContent object used by this frame.void
setVisible(boolean state)
CallsinitComponents()
if it has not already been called explicitly to construct the frame's components before showing the frame.static void
showMap(MapContent content)
Creates a new map frame with a toolbar, map pane and status bar; sets the suppliedMapContent
; and displays the frame.-
Methods inherited from class 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 Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
-
Methods inherited from class Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront
-
Methods inherited from class 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, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class 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, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface MenuContainer
getFont, postEvent
-
-
-
-
Field Detail
-
TOOLBAR_INFO_BUTTON_NAME
public static final String TOOLBAR_INFO_BUTTON_NAME
Name assigned to toolbar button for feature info queries.- See Also:
- Constant Field Values
-
TOOLBAR_PAN_BUTTON_NAME
public static final String TOOLBAR_PAN_BUTTON_NAME
Name assigned to toolbar button for map panning.- See Also:
- Constant Field Values
-
TOOLBAR_POINTER_BUTTON_NAME
public static final String TOOLBAR_POINTER_BUTTON_NAME
Name assigned to toolbar button for default pointer.- See Also:
- Constant Field Values
-
TOOLBAR_RESET_BUTTON_NAME
public static final String TOOLBAR_RESET_BUTTON_NAME
Name assigned to toolbar button for map reset.- See Also:
- Constant Field Values
-
TOOLBAR_ZOOMIN_BUTTON_NAME
public static final String TOOLBAR_ZOOMIN_BUTTON_NAME
Name assigned to toolbar button for map zoom in.- See Also:
- Constant Field Values
-
TOOLBAR_ZOOMOUT_BUTTON_NAME
public static final String TOOLBAR_ZOOMOUT_BUTTON_NAME
Name assigned to toolbar button for map zoom out.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JMapFrame
public JMapFrame()
Default constructor. Creates aJMapFrame
with no map content or renderer set
-
JMapFrame
public JMapFrame(MapContent content)
Constructs a newJMapFrame
object with specified map content.- Parameters:
content
- the map content
-
-
Method Detail
-
showMap
public static void showMap(MapContent content)
Creates a new map frame with a toolbar, map pane and status bar; sets the suppliedMapContent
; and displays the frame. If MapContent.getTitle() returns a non-empty string, this is used as the frame's title.This method can be called safely from any thread.
- Parameters:
content
- the map content
-
enableToolBar
public void enableToolBar(boolean enabled)
Sets whether to display the default toolbar (default is false). Calling this with state == true is equivalent to callingenableTool(org.geotools.swing.JMapFrame.Tool...)
with allJMapFrame.Tool
constants.- Parameters:
enabled
- whether the toolbar is required
-
enableTool
public void enableTool(JMapFrame.Tool... tool)
This method is an alternative toenableToolBar(boolean)
. It requests that a tool bar be created with specific tools, identified byJMapFrame.Tool
constants.
Calling this method with no arguments ormyMapFrame.enableTool(Tool.PAN, Tool.ZOOM);
null
is equivalent toenableToolBar(false)
.- Parameters:
tool
- tools to display on the toolbar
-
enableStatusBar
public void enableStatusBar(boolean enabled)
Set whether a status bar will be displayed to display cursor position and map bounds.- Parameters:
enabled
- whether the status bar is required.
-
enableLayerTable
public void enableLayerTable(boolean enabled)
Set whether a map layer table will be displayed to show the list of layers in the map content and set their order, visibility and selected status.- Parameters:
enabled
- whether the map layer table is required.
-
setVisible
public void setVisible(boolean state)
CallsinitComponents()
if it has not already been called explicitly to construct the frame's components before showing the frame.- Overrides:
setVisible
in classWindow
- 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 bysetVisible(boolean)
when the frame is first shown.
-
getMapContent
public MapContent getMapContent()
Get the map content associated with this frame. Returnsnull
if no map content has been set explicitly with the constructor orsetMapContent(org.geotools.map.MapContent)
.- Returns:
- the current
MapContent
object
-
setMapContent
public void setMapContent(MapContent content)
Set the MapContent object used by this frame.- Parameters:
content
- the map content- Throws:
IllegalArgumentException
- if content is null
-
getMapPane
public JMapPane getMapPane()
Provides access to the instance ofJMapPane
being used by this frame.- Returns:
- the
JMapPane
object
-
getToolBar
public JToolBar getToolBar()
Provides access to the toolbar being used by this frame. IfinitComponents()
has not been called yet this method will invoke it.- Returns:
- the toolbar or null if the toolbar was not enabled
-
-