org.jdesktop.swingx
Class JXMapKit

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.jdesktop.swingx.JXPanel
                      extended by org.jdesktop.swingx.JXMapKit
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class JXMapKit
extends org.jdesktop.swingx.JXPanel

The JXMapKit is a pair of JXMapViewers preconfigured to be easy to use with common features built in. This includes zoom buttons, a zoom slider, and a mini-map in the lower right corner showing an overview of the map. Each feature can be turned off using an appropriate isXvisible property. For example, to turn off the minimap call

jxMapKit.setMiniMapVisible(false);

The JXMapViewer is preconfigured to connect to maps.swinglabs.org which serves up global satellite imagery from NASA's Blue Marble NG image collection.

See Also:
Serialized Form

Nested Class Summary
static class JXMapKit.DefaultProviders
           
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JXMapKit()
          Creates a new JXMapKit
 
Method Summary
 GeoPosition getAddressLocation()
           
 GeoPosition getCenterPosition()
           
 JXMapKit.DefaultProviders getDefaultProvider()
           
 JXMapViewer getMainMap()
          Returns a reference to the main embedded JXMapViewer component
 JXMapViewer getMiniMap()
          Returns a reference to the mini embedded JXMapViewer component
 Action getZoomInAction()
          Returns an action which can be attached to buttons or menu items to make the map zoom in
 JButton getZoomInButton()
          returns a reference to the zoom in button
 Action getZoomOutAction()
          Returns an action which can be attached to buttons or menu items to make the map zoom out
 JButton getZoomOutButton()
          returns a reference to the zoom out button
 JSlider getZoomSlider()
          returns a reference to the zoom slider
 boolean isAddressLocationShown()
           
 boolean isDataProviderCreditShown()
           
 boolean isMiniMapVisible()
          Indicates if the mini-map is currently visible
 boolean isZoomButtonsVisible()
          Indicates if the zoom buttons are visible.
 boolean isZoomSliderVisible()
          Indicates if the zoom slider is currently visible
static void main(String... args)
           
 void setAddressLocation(GeoPosition pos)
           
 void setAddressLocationShown(boolean b)
           
 void setCenterPosition(GeoPosition pos)
           
 void setDataProviderCreditShown(boolean b)
           
 void setDefaultProvider(JXMapKit.DefaultProviders prov)
           
 void setMiniMapVisible(boolean miniMapVisible)
          Sets if the mini-map should be visible
 void setTileFactory(TileFactory fact)
          Sets the tile factory for both embedded JXMapViewer components.
 void setZoom(int zoom)
          Set the current zoomlevel for the main map.
 void setZoomButtonsVisible(boolean zoomButtonsVisible)
          Sets if the zoom buttons should be visible.
 void setZoomSliderVisible(boolean zoomSliderVisible)
          Sets if the zoom slider should be visible
 
Methods inherited from class org.jdesktop.swingx.JXPanel
getAlpha, getBackgroundPainter, getEffectiveAlpha, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, isInheritAlpha, isPaintBorderInsets, paint, paintComponent, setAlpha, setBackground, setBackgroundPainter, setInheritAlpha, setPaintBorderInsets, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth
 
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, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, 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, 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, imageUpdate, 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
 

Constructor Detail

JXMapKit

public JXMapKit()
Creates a new JXMapKit

Method Detail

setZoom

public void setZoom(int zoom)
Set the current zoomlevel for the main map. The minimap will be updated accordingly

Parameters:
zoom - the new zoom level

getZoomOutAction

public Action getZoomOutAction()
Returns an action which can be attached to buttons or menu items to make the map zoom out

Returns:
a preconfigured Zoom Out action

getZoomInAction

public Action getZoomInAction()
Returns an action which can be attached to buttons or menu items to make the map zoom in

Returns:
a preconfigured Zoom In action

isMiniMapVisible

public boolean isMiniMapVisible()
Indicates if the mini-map is currently visible

Returns:
the current value of the mini-map property

setMiniMapVisible

public void setMiniMapVisible(boolean miniMapVisible)
Sets if the mini-map should be visible

Parameters:
miniMapVisible - a new value for the miniMap property

isZoomSliderVisible

public boolean isZoomSliderVisible()
Indicates if the zoom slider is currently visible

Returns:
the current value of the zoomSliderVisible property

setZoomSliderVisible

public void setZoomSliderVisible(boolean zoomSliderVisible)
Sets if the zoom slider should be visible

Parameters:
zoomSliderVisible - the new value of the zoomSliderVisible property

isZoomButtonsVisible

public boolean isZoomButtonsVisible()
Indicates if the zoom buttons are visible. This is a bound property and can be listed for using a PropertyChangeListener

Returns:
current value of the zoomButtonsVisible property

setZoomButtonsVisible

public void setZoomButtonsVisible(boolean zoomButtonsVisible)
Sets if the zoom buttons should be visible. This ia bound property. Changes can be listened for using a PropertyChaneListener

Parameters:
zoomButtonsVisible - new value of the zoomButtonsVisible property

setTileFactory

public void setTileFactory(TileFactory fact)
Sets the tile factory for both embedded JXMapViewer components. Calling this method will also reset the center and zoom levels of both maps, as well as the bounds of the zoom slider.

Parameters:
fact - the new TileFactory

setCenterPosition

public void setCenterPosition(GeoPosition pos)

getCenterPosition

public GeoPosition getCenterPosition()

getAddressLocation

public GeoPosition getAddressLocation()

setAddressLocation

public void setAddressLocation(GeoPosition pos)

getMainMap

public JXMapViewer getMainMap()
Returns a reference to the main embedded JXMapViewer component

Returns:
the main map

getMiniMap

public JXMapViewer getMiniMap()
Returns a reference to the mini embedded JXMapViewer component

Returns:
the minimap JXMapViewer component

getZoomInButton

public JButton getZoomInButton()
returns a reference to the zoom in button

Returns:
a jbutton

getZoomOutButton

public JButton getZoomOutButton()
returns a reference to the zoom out button

Returns:
a jbutton

getZoomSlider

public JSlider getZoomSlider()
returns a reference to the zoom slider

Returns:
a jslider

setAddressLocationShown

public void setAddressLocationShown(boolean b)

isAddressLocationShown

public boolean isAddressLocationShown()

setDataProviderCreditShown

public void setDataProviderCreditShown(boolean b)

isDataProviderCreditShown

public boolean isDataProviderCreditShown()

setDefaultProvider

public void setDefaultProvider(JXMapKit.DefaultProviders prov)

getDefaultProvider

public JXMapKit.DefaultProviders getDefaultProvider()

main

public static void main(String... args)