public class MapComponent
ImplementsAnimation, Editable, Iterable<Component>, StyleListener
Constructors
Methods
public static long distance(double latitude1, double longitude1, double latitude2, double longitude2) | Returns the distance between 2 points in meters |
public void paintBackground(Graphics g) | This method paints the Component background, it should be overriden by subclasses to perform custom background drawing. |
protected void laidOut() | This is a callback method to inform the Component when it’s been laidout on the parent Container |
protected boolean shouldBlockSideSwipe() | A component that might need side swipe such as the slider could block it from being used for some other purpose when on top of said component. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
protected void focusGained() | Callback allowing a developer to track when the component gains focus |
protected boolean mouseWheel(WheelEvent ev) | Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy. |
public void pointerDragged(int x, int y) | If this Component is focused, the pointer dragged event will call this method |
public void pointerPressed(int x, int y) | If this Component is focused, the pointer pressed event will call this method |
public void pointerDragged(int[] x, int[] y) | If this Component is focused, the pointer dragged event will call this method |
protected void pointerTapped(int x, int y, int tapCount) | |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
public Coord getCoordFromPosition(int x, int y) | Gets the Coord location on the map from a x, y position. |
public Point getPointFromCoord(Coord coord) | Gets the screen coordinates of a specific Coord |
public void keyPressed(int keyCode) | If this Component is focused, the key pressed event will call this method |
public void addLayer(Layer layer) | Adds a layer to the map |
public void addLayer(Layer layer, int minZoomLevel, int maxZoomLevel) | Adds a layer to the map |
public void removeLayer(Layer layer) | Removes a Layer from the map |
public void removeAllLayers() | Removes all layers from the map |
public int getLayersConut() | Returns layers count |
public Layer getLayerAt(int index) | Returns Layer at index |
public MapProvider getProvider() | Gets the map provider |
public void repaint() | Repaint this Component, the repaint call causes a callback of the paint method on the event dispatch thread. |
public void moveLeft() | move the map 25% left |
public void moveRight() | move the map 25% right |
public void moveUp() | move the map 25% up |
public void moveDown() | move the map 25% down |
public void zoomIn() | zoom in the map one level if possible |
public void zoomOut() | zoom out the map one level if possible |
public void zoomTo(BoundingBox boundingBox) | Zoom the map the the giving bounding box |
public void zoomTo(Coord coord, int zoomLevel) | Zoom map to the center of the given coordinate with the given zoom level |
public void zoomToLayers() | zoom map to largest zoom while all Layers are contained |
public Coord getCenter() | Gets the center location of the map in WGS84 format. |
public int getZoomLevel() | Returns the current zoom level of the map. |
public void setZoomLevel(int zoom) | Sets the current zoom level of the map. |
public int getMaxZoomLevel() | Returns the max zoom level of the map |
public int getMinZoomLevel() | Returns the min zoom level of the map |
public Coord center() | Gets the center of the map. |
protected boolean isLeftKey(int keyCode) | Checks if key code is left keycode. |
protected boolean isRightKey(int keyCode) | Returns true if this is a right keycode |
protected boolean isDownKey(int keyCode) | Returns true if this is a down keycode |
protected boolean isUpKey(int keyCode) | Returns true if this is a up keycode |
protected boolean isZoomInKey(int keyCode) | Returns true if this is a zoom in keycode |
protected boolean isZoomOutKey(int keyCode) | Returns true if this is a zoom out keycode |
protected boolean isZoomToLayersKey(int keyCode) | Returns true if this is a zoom to layers keycode |
public void addMapListener(MapListener listener) | Adds a listener to map panning/zooming |
public void removeMapListener(MapListener listener) | Removes the map listener callback |
public String[] getPropertyNames() | A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code |
public Class[] getPropertyTypes() | Matches the property names method (see that method for further details). |
public Object getPropertyValue(String name) | Returns the current value of the property name, this method is used by the GUI builder |
public String setPropertyValue(String name, Object value) | Sets a new value to the given property, returns an error message if failed and null if successful. |
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
Inherited methods
From Container
encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, deinitialize, initComponent, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyTypeNames, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Constructor details
MapComponent
public MapComponent()MapComponent
public MapComponent(MapProvider provider)Parameters
providerMapProvider- map provider
MapComponent
public MapComponent(MapProvider provider, Location centerPosition, int zoomLevel)Parameters
providerMapProvider- map provider
centerPositionLocation- center position
zoomLevelint- zoom level
MapComponent
public MapComponent(MapProvider provider, Location centerPosition, int zoomLevel, boolean cacheEnabled)Parameters
providerMapProvider- map provider
centerPositionLocation- center position
zoomLevelint- zoom level
cacheEnabledboolean- is cache enabled
MapComponent
public MapComponent(MapProvider provider, Coord centerPosition, int zoomLevel)Parameters
providerMapProvider- map provider
centerPositionCoord- center position
zoomLevelint- zoom level
MapComponent
public MapComponent(MapProvider provider, Coord centerPosition, int zoomLevel, boolean cacheEnabled)Parameters
providerMapProvider- map provider
centerPositionCoord- center position
zoomLevelint- zoom level
cacheEnabledboolean- is cache enabled
Method details
distance
public static long distance(double latitude1, double longitude1, double latitude2, double longitude2)Returns
paintBackground
public void paintBackground(Graphics g)Parameters
gGraphics- the component graphics
laidOut
protected void laidOut()shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()calcPreferredSize
protected Dimension calcPreferredSize()Returns
focusGained
protected void focusGained()mouseWheel
protected boolean mouseWheel(WheelEvent ev)Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy.
A component that moves its own content – an editor that scrolls itself, a viewer that pans – implements this. Everything else leaves it alone and the wheel scrolls the nearest scrollable ancestor, which is what a wheel means.
This exists because a wheel used to arrive as a synthetic press, drag and release played into the component tree: a component that wanted the wheel got it by handling pointer events, and so did every component that did not want it. The events are gone and this is what replaces them, for the few components that have something of their own to move.
Parameters
evWheelEvent- the wheel event, carrying the scroll deltas in display pixels
Returns
pointerDragged
public void pointerDragged(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerPressed
public void pointerPressed(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerDragged
public void pointerDragged(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
pointerTapped
protected void pointerTapped(int x, int y, int tapCount)pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
getCoordFromPosition
public Coord getCoordFromPosition(int x, int y)Parameters
xint- X-coordinate
yint- Y-coordinate
Returns
getPointFromCoord
public Point getPointFromCoord(Coord coord)Parameters
coordCoord- a lat,lon location
Returns
keyPressed
public void keyPressed(int keyCode)Parameters
keyCodeint- the key code value to indicate a physical key.
addLayer
public void addLayer(Layer layer)Parameters
layerLayer- to add
addLayer
public void addLayer(Layer layer, int minZoomLevel, int maxZoomLevel)Parameters
layerLayer- to add
minZoomLevelint- min zoom level of this Layer
maxZoomLevelint- max zoom level of this Layer
removeLayer
public void removeLayer(Layer layer)Parameters
layerLayer- to remove
removeAllLayers
public void removeAllLayers()getLayersConut
public int getLayersConut()Returns
getLayerAt
public Layer getLayerAt(int index)Parameters
indexint- the index of the layer
Returns
Throws
ArrayIndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())
getProvider
public MapProvider getProvider()Returns
repaint
public void repaint()See also
moveLeft
public void moveLeft()moveRight
public void moveRight()moveUp
public void moveUp()moveDown
public void moveDown()zoomIn
public void zoomIn()zoomOut
public void zoomOut()zoomTo
public void zoomTo(BoundingBox boundingBox)Parameters
boundingBoxBoundingBox- to zoom to
Throws
IllegalArgumentException- if the boundingBox is not wg84 format
zoomTo
public void zoomTo(Coord coord, int zoomLevel)Parameters
coordCoord- center map to this coordinate, coord should be in wg84 format
zoomLevelint- zoom map to this level;
Throws
IllegalArgumentException- if the coord is not wg84 format
zoomToLayers
public void zoomToLayers()getCenter
public Coord getCenter()Returns
getZoomLevel
public int getZoomLevel()Returns
setZoomLevel
public void setZoomLevel(int zoom)Parameters
zoomint- Zoom level
getMaxZoomLevel
public int getMaxZoomLevel()Returns
getMinZoomLevel
public int getMinZoomLevel()Returns
center
public Coord center()Returns
isLeftKey
protected boolean isLeftKey(int keyCode)Parameters
keyCodeint- The key-code to check.
Returns
isRightKey
protected boolean isRightKey(int keyCode)Parameters
keyCodeint- The key code to check
Returns
isDownKey
protected boolean isDownKey(int keyCode)Parameters
keyCodeint- The key code to check.
Returns
isUpKey
protected boolean isUpKey(int keyCode)Parameters
keyCodeint- The key code to check.
Returns
isZoomInKey
protected boolean isZoomInKey(int keyCode)Parameters
keyCodeint- The key code to check
Returns
isZoomOutKey
protected boolean isZoomOutKey(int keyCode)Parameters
keyCodeint- The key code to check.
Returns
isZoomToLayersKey
protected boolean isZoomToLayersKey(int keyCode)Parameters
keyCodeint- The key-code to check.
Returns
addMapListener
public void addMapListener(MapListener listener)Parameters
listenerMapListener- the listener callback
removeMapListener
public void removeMapListener(MapListener listener)Parameters
listenerMapListener- the listener
getPropertyNames
public String[] getPropertyNames()Returns
getPropertyTypes
public Class[] getPropertyTypes()Returns
getPropertyValue
public Object getPropertyValue(String name)Parameters
nameString- the name of the property
Returns
setPropertyValue
public String setPropertyValue(String name, Object value)Parameters
nameString- the name of the property
valueObject- new value for the property