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:
  • Field Details

    • TOOLBAR_INFO_BUTTON_NAME

      public static final String TOOLBAR_INFO_BUTTON_NAME
      Name assigned to toolbar button for feature info queries.
      See Also:
    • TOOLBAR_PAN_BUTTON_NAME

      public static final String TOOLBAR_PAN_BUTTON_NAME
      Name assigned to toolbar button for map panning.
      See Also:
    • TOOLBAR_POINTER_BUTTON_NAME

      public static final String TOOLBAR_POINTER_BUTTON_NAME
      Name assigned to toolbar button for default pointer.
      See Also:
    • TOOLBAR_RESET_BUTTON_NAME

      public static final String TOOLBAR_RESET_BUTTON_NAME
      Name assigned to toolbar button for map reset.
      See Also:
    • TOOLBAR_ZOOMIN_BUTTON_NAME

      public static final String TOOLBAR_ZOOMIN_BUTTON_NAME
      Name assigned to toolbar button for map zoom in.
      See Also:
    • TOOLBAR_ZOOMOUT_BUTTON_NAME

      public static final String TOOLBAR_ZOOMOUT_BUTTON_NAME
      Name assigned to toolbar button for map zoom out.
      See Also:
  • Constructor Details

    • JMapFrame

      public JMapFrame()
      Default constructor. Creates a JMapFrame with no map content or renderer set
    • JMapFrame

      public JMapFrame(MapContent content)
      Constructs a new JMapFrame object with specified map content.
      Parameters:
      content - the map content
  • Method Details

    • showMap

      public static void showMap(MapContent content)
      Creates a new map frame with a toolbar, map pane and status bar; sets the supplied MapContent; 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 calling enableTool(org.geotools.swing.JMapFrame.Tool...) with all JMapFrame.Tool constants.
      Parameters:
      enabled - 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);
       
      Calling this method with no arguments or null is equivalent to enableToolBar(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)
      Calls initComponents() if it has not already been called explicitly to construct the frame's components before showing the frame.
      Overrides:
      setVisible in class 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.
    • getMapContent

      public MapContent getMapContent()
      Get the map content associated with this frame. Returns null if no map content has been set explicitly with the constructor or setMapContent(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 of JMapPane being used by this frame.
      Returns:
      the JMapPane object
    • getToolBar

      public 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