Package org.jxmapviewer
Class JXMapKit
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jxmapviewer.JXMapKit
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible
public class JXMapKit
extends javax.swing.JPanel
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 OpenStreetMap.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJXMapKit.DefaultProvidersNested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent -
Field Summary
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW -
Constructor Summary
Constructors Constructor Description JXMapKit()Creates a new JXMapKit -
Method Summary
Modifier and Type Method Description GeoPositiongetAddressLocation()GeoPositiongetCenterPosition()JXMapKit.DefaultProvidersgetDefaultProvider()JXMapViewergetMainMap()Returns a reference to the main embedded JXMapViewer componentJXMapViewergetMiniMap()Returns a reference to the mini embedded JXMapViewer componentjavax.swing.ActiongetZoomInAction()Returns an action which can be attached to buttons or menu items to make the map zoom injavax.swing.JButtongetZoomInButton()returns a reference to the zoom in buttonjavax.swing.ActiongetZoomOutAction()Returns an action which can be attached to buttons or menu items to make the map zoom outjavax.swing.JButtongetZoomOutButton()returns a reference to the zoom out buttonjavax.swing.JSlidergetZoomSlider()returns a reference to the zoom sliderbooleanisAddressLocationShown()booleanisDataProviderCreditShown()booleanisMiniMapVisible()Indicates if the mini-map is currently visiblebooleanisZoomButtonsVisible()Indicates if the zoom buttons are visible.booleanisZoomSliderVisible()Indicates if the zoom slider is currently visiblestatic voidmain(java.lang.String... args)voidsetAddressLocation(GeoPosition pos)voidsetAddressLocationShown(boolean b)voidsetCenterPosition(GeoPosition pos)voidsetDataProviderCreditShown(boolean b)voidsetDefaultProvider(JXMapKit.DefaultProviders prov)voidsetMiniMapVisible(boolean miniMapVisible)Sets if the mini-map should be visiblevoidsetTileFactory(TileFactory fact)Sets the tile factory for both embedded JXMapViewer components.voidsetZoom(int zoom)Set the current zoomlevel for the main map.voidsetZoomButtonsVisible(boolean zoomButtonsVisible)Sets if the zoom buttons should be visible.voidsetZoomSliderVisible(boolean zoomSliderVisible)Sets if the zoom slider should be visibleMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
JXMapKit
public JXMapKit()Creates a new JXMapKit
-
-
Method Details
-
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 javax.swing.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 javax.swing.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
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
- Parameters:
pos- the new center position
-
getCenterPosition
- Returns:
- the center geo position
-
getAddressLocation
- Returns:
- the adress location
-
setAddressLocation
- Parameters:
pos- the address location
-
getMainMap
Returns a reference to the main embedded JXMapViewer component- Returns:
- the main map
-
getMiniMap
Returns a reference to the mini embedded JXMapViewer component- Returns:
- the minimap JXMapViewer component
-
getZoomInButton
public javax.swing.JButton getZoomInButton()returns a reference to the zoom in button- Returns:
- a jbutton
-
getZoomOutButton
public javax.swing.JButton getZoomOutButton()returns a reference to the zoom out button- Returns:
- a jbutton
-
getZoomSlider
public javax.swing.JSlider getZoomSlider()returns a reference to the zoom slider- Returns:
- a jslider
-
setAddressLocationShown
public void setAddressLocationShown(boolean b)- Parameters:
b- the visibility flag
-
isAddressLocationShown
public boolean isAddressLocationShown()- Returns:
- true if the address location is shown
-
setDataProviderCreditShown
public void setDataProviderCreditShown(boolean b)- Parameters:
b- the visibility flag
-
isDataProviderCreditShown
public boolean isDataProviderCreditShown()- Returns:
- true if the data provider credit is shown
-
setDefaultProvider
- Parameters:
prov- the default provider
-
getDefaultProvider
- Returns:
- the default provider
-
main
public static void main(java.lang.String... args)- Parameters:
args- the program args
-