Package org.openstreetmap.josm.gui.bbox
Class SlippyMapBBoxChooser
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.openstreetmap.gui.jmapviewer.JMapViewer
-
- org.openstreetmap.josm.gui.bbox.JosmMapViewer
-
- org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,javax.swing.event.ChangeListener,org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener,BBoxChooser,LayerManager.LayerChangeListener,MainLayerManager.ActiveLayerChangeListener
public class SlippyMapBBoxChooser extends JosmMapViewer implements BBoxChooser, javax.swing.event.ChangeListener, MainLayerManager.ActiveLayerChangeListener, LayerManager.LayerChangeListener
This panel displays a map and lets the user chose aBBox.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.bbox.JosmMapViewer
JosmMapViewer.AbstractImageryInfoBasedTileSourceProvider, JosmMapViewer.CurrentLayersTileSourceProvider, JosmMapViewer.DefaultOsmTileSourceProvider, JosmMapViewer.TileSourceProvider, JosmMapViewer.TMSTileSourceProvider
-
Nested classes/interfaces inherited from class org.openstreetmap.gui.jmapviewer.JMapViewer
org.openstreetmap.gui.jmapviewer.JMapViewer.ZOOM_BUTTON_STYLE
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private Boundsbboxstatic java.lang.StringCURSOR_COORDINATE_PROPThe property name used for theILatLonof the mouse cursor on the map.private org.openstreetmap.gui.jmapviewer.interfaces.ICoordinateiSelectionRectEndprivate org.openstreetmap.gui.jmapviewer.interfaces.ICoordinateiSelectionRectStartprivate SizeButtoniSizeButtonprivate SourceButtoniSourceButtonprivate static StringPropertyPROP_MAPSTYLEprivate static BooleanPropertyPROP_SHOWDLAREAprivate static java.util.concurrent.CopyOnWriteArrayList<JosmMapViewer.TileSourceProvider>providersstatic java.lang.StringRESIZE_PROPThe property name used for the resize button.private javax.swing.ButtonModelshowDownloadAreaButtonModel-
Fields inherited from class org.openstreetmap.josm.gui.bbox.JosmMapViewer
cachedLoader, uncachedLoader
-
Fields inherited from class org.openstreetmap.gui.jmapviewer.JMapViewer
attribution, center, debug, evtListenerList, mapMarkerList, mapMarkersVisible, mapPolygonList, mapPolygonsVisible, mapRectangleList, mapRectanglesVisible, MAX_ZOOM, MIN_ZOOM, scrollWrapEnabled, tileController, tileGridVisible, tileSource, zoom, zoomButtonStyle, zoomInButton, zoomOutButton, zoomReverseWheel, zoomSlider
-
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
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface org.openstreetmap.josm.gui.bbox.BBoxChooser
BBOX_PROP
-
-
Constructor Summary
Constructors Constructor Description SlippyMapBBoxChooser()Constructs a newSlippyMapBBoxChooser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactiveOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)Called whenever the active or edit layer changed.static voidaddTileSourceProvider(JosmMapViewer.TileSourceProvider tileSourceProvider)Plugins that wish to add custom tile sources to slippy map choose should call this methodprivate static java.util.Map<java.lang.String,org.openstreetmap.gui.jmapviewer.interfaces.TileSource>getAllTileSources()BoundsgetBoundingBox()Replies the currently selected bounding box in this BBoxChooser.private doublegetDist100Pixel()Get the distance in meter that correspond to 100 px on screen.private static java.lang.StringgetTileSourceId(org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)In case the tile source has no ID, use the nameBoundsgetVisibleMapArea()Returns the currently visible map areabooleanhandleAttribution(java.awt.Point p, boolean click)Handles a click/move on the attributionvoidhandleMouseMoved(java.awt.Point point)Handles aSlippyMapController.mouseMoved(java.awt.event.MouseEvent)eventvoidlayerAdded(LayerManager.LayerAddEvent e)Notifies this listener that a layer has been added.voidlayerOrderChanged(LayerManager.LayerOrderChangeEvent e)Notifies this listener that the order of layers was changed.voidlayerRemoving(LayerManager.LayerRemoveEvent e)Notifies this listener that a layer was just removed.voidpaintComponent(java.awt.Graphics g)Draw the map.voidrefreshTileSources()Refreshes the tile sourcesvoidresizeSlippyMap()Performs resizing of the DownloadDialog in order to enlarge or shrink the map.voidsetBoundingBox(Bounds bbox)Sets the current bounding box in this bbox chooser without emitting a property change event.voidsetSelection(java.awt.Point aStart, java.awt.Point aEnd)Callback for the OsmMapControl.voidsetSizeButtonVisible(boolean visible)Enables or disables painting of the shrink/enlarge buttonvoidstateChanged(javax.swing.event.ChangeEvent e)voidtoggleMapSource(org.openstreetmap.gui.jmapviewer.interfaces.TileSource tileSource)Sets the active tile source-
Methods inherited from class org.openstreetmap.josm.gui.bbox.JosmMapViewer
imageryInfosToTileSources, setFileCacheEnabled, setMaxTilesInMemory
-
Methods inherited from class org.openstreetmap.gui.jmapviewer.JMapViewer
addJMVListener, addMapMarker, addMapPolygon, addMapRectangle, getAttribution, getCenter, getLatOffset, getMapMarkerList, getMapMarkersVisible, getMapPolygonList, getMapPosition, getMapPosition, getMapPosition, getMapPosition, getMapRectangleList, getMeterPerPixel, getPosition, getPosition, getPosition, getRadius, getTileCache, getTileController, getToolTipText, getZoom, getZoomButtonStyle, getZoomControlsVisible, initializeZoomSlider, isMapPolygonsVisible, isMapRectanglesVisible, isScrollWrapEnabled, isTileGridVisible, moveMap, paintMarker, paintPolygon, paintRectangle, removeAllMapMarkers, removeAllMapPolygons, removeAllMapRectangles, removeJMVListener, removeMapMarker, removeMapPolygon, removeMapRectangle, setCenter, setDisplayPosition, setDisplayPosition, setDisplayPosition, setDisplayPosition, setDisplayToFitMapElements, setDisplayToFitMapMarkers, setDisplayToFitMapPolygons, setDisplayToFitMapRectangles, setMapMarkerList, setMapMarkerVisible, setMapPolygonList, setMapPolygonsVisible, setMapRectangleList, setMapRectanglesVisible, setScrollWrapEnabled, setTileGridVisible, setTileLoader, setTileSource, setZoom, setZoom, setZoomButtonStyle, setZoomContolsVisible, setZoomControlsVisible, tileLoadingFinished, zoomChanged, zoomIn, zoomIn, zoomOut, zoomOut
-
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, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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, 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, 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, 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, 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
-
-
-
-
Field Detail
-
providers
private static final java.util.concurrent.CopyOnWriteArrayList<JosmMapViewer.TileSourceProvider> providers
-
PROP_MAPSTYLE
private static final StringProperty PROP_MAPSTYLE
-
PROP_SHOWDLAREA
private static final BooleanProperty PROP_SHOWDLAREA
-
RESIZE_PROP
public static final java.lang.String RESIZE_PROP
The property name used for the resize button.- See Also:
Container.addPropertyChangeListener(java.beans.PropertyChangeListener)
-
CURSOR_COORDINATE_PROP
public static final java.lang.String CURSOR_COORDINATE_PROP
The property name used for theILatLonof the mouse cursor on the map.- See Also:
Container.addPropertyChangeListener(java.beans.PropertyChangeListener)
-
iSizeButton
private final SizeButton iSizeButton
-
showDownloadAreaButtonModel
private final javax.swing.ButtonModel showDownloadAreaButtonModel
-
iSourceButton
private final SourceButton iSourceButton
-
iSelectionRectStart
private transient org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate iSelectionRectStart
-
iSelectionRectEnd
private transient org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate iSelectionRectEnd
-
-
Constructor Detail
-
SlippyMapBBoxChooser
public SlippyMapBBoxChooser()
Constructs a newSlippyMapBBoxChooser.
-
-
Method Detail
-
addTileSourceProvider
public static void addTileSourceProvider(JosmMapViewer.TileSourceProvider tileSourceProvider)
Plugins that wish to add custom tile sources to slippy map choose should call this method- Parameters:
tileSourceProvider- new tile source provider
-
getAllTileSources
private static java.util.Map<java.lang.String,org.openstreetmap.gui.jmapviewer.interfaces.TileSource> getAllTileSources()
-
getTileSourceId
private static java.lang.String getTileSourceId(org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
In case the tile source has no ID, use the name
-
getDist100Pixel
private double getDist100Pixel()
Get the distance in meter that correspond to 100 px on screen.- Returns:
- the distance in meter that correspond to 100 px on screen
- See Also:
NavigatableComponent.getDist100Pixel()
-
handleAttribution
public boolean handleAttribution(java.awt.Point p, boolean click)
Handles a click/move on the attribution- Parameters:
p- The point in the viewclick- true if it was a click, false for hover- Returns:
- if the attribution handled the event
-
paintComponent
public void paintComponent(java.awt.Graphics g)
Draw the map.- Overrides:
paintComponentin classorg.openstreetmap.gui.jmapviewer.JMapViewer
-
activeOrEditLayerChanged
public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Description copied from interface:MainLayerManager.ActiveLayerChangeListenerCalled whenever the active or edit layer changed.You can be sure that this layer is still contained in this set.
Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
- Specified by:
activeOrEditLayerChangedin interfaceMainLayerManager.ActiveLayerChangeListener- Parameters:
e- The change event.
-
stateChanged
public void stateChanged(javax.swing.event.ChangeEvent e)
- Specified by:
stateChangedin interfacejavax.swing.event.ChangeListener
-
handleMouseMoved
public void handleMouseMoved(java.awt.Point point)
Handles aSlippyMapController.mouseMoved(java.awt.event.MouseEvent)event- Parameters:
point- The point in the view
-
setSelection
public void setSelection(java.awt.Point aStart, java.awt.Point aEnd)
Callback for the OsmMapControl. (Re-)Sets the start and end point of the selection rectangle.- Parameters:
aStart- selection startaEnd- selection end
-
resizeSlippyMap
public void resizeSlippyMap()
Performs resizing of the DownloadDialog in order to enlarge or shrink the map.
-
toggleMapSource
public void toggleMapSource(org.openstreetmap.gui.jmapviewer.interfaces.TileSource tileSource)
Sets the active tile source- Parameters:
tileSource- The active tile source
-
getBoundingBox
public Bounds getBoundingBox()
Description copied from interface:BBoxChooserReplies the currently selected bounding box in this BBoxChooser. Replies null, if currently there isn't a bbox chosen in this BBoxChooser.- Specified by:
getBoundingBoxin interfaceBBoxChooser- Returns:
- the currently selected bounding box
-
setBoundingBox
public void setBoundingBox(Bounds bbox)
Sets the current bounding box in this bbox chooser without emitting a property change event.- Specified by:
setBoundingBoxin interfaceBBoxChooser- Parameters:
bbox- the bounding box. null to reset the bounding box
-
setSizeButtonVisible
public void setSizeButtonVisible(boolean visible)
Enables or disables painting of the shrink/enlarge button- Parameters:
visible-trueto enable painting of the shrink/enlarge button
-
refreshTileSources
public final void refreshTileSources()
Refreshes the tile sources- Since:
- 6364
-
layerAdded
public void layerAdded(LayerManager.LayerAddEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that a layer has been added.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerAddedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The new added layer event
-
layerRemoving
public void layerRemoving(LayerManager.LayerRemoveEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that a layer was just removed.Listeners are called in the EDT thread after the layer was removed. Use
LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)to remove more layers. You should not do blocking or long-running tasks in this method.- Specified by:
layerRemovingin interfaceLayerManager.LayerChangeListener- Parameters:
e- The layer to be removed (as event)
-
layerOrderChanged
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Description copied from interface:LayerManager.LayerChangeListenerNotifies this listener that the order of layers was changed.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerOrderChangedin interfaceLayerManager.LayerChangeListener- Parameters:
e- The order change event.
-
getVisibleMapArea
public Bounds getVisibleMapArea()
Returns the currently visible map area- Returns:
- the currently visible map area
-
-