Package com.sothawo.mapjfx
Class Marker
- java.lang.Object
-
- com.sothawo.mapjfx.MapElement
-
- com.sothawo.mapjfx.MapCoordinateElement
-
- com.sothawo.mapjfx.Marker
-
public final class Marker extends MapCoordinateElement
A marker in the map. A marker has a position where it is displayed, an image URL for the image to be displayed and offset values for x and y. The image should be in a format supporting transparency that can be rendered by JavaFX8 WebView. The image is rendered with it's top left point at the coordinate. This can be adjusted by setting the pixel offset values, x positive to the right, y positive down.
The image URL and offset values can only be set at construction time, the coordinate is a JavaFX property. The Marker has a visibility property which must be set to true to make the marker visible. With this property it is possible to hide the marker without completely removing it from the map.
A marker has a unique (within class existence in the VM) id of the form "marker-NNN" where NNN is a consecutive number assigned on creation. A Marker may have an attached Label. If it has one, the Label is shown/hidden/moved/removed together with the Marker. Any attempt to do these operations directly on the Label are ignored.- Author:
- P.J. Meisch ([email protected]).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Marker.Provided
provided Markers.
-
Field Summary
-
Fields inherited from class com.sothawo.mapjfx.MapCoordinateElement
cssClass, offsetX, offsetY, position
-
Fields inherited from class com.sothawo.mapjfx.MapElement
visible
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Marker
attachLabel(MapLabel mapLabel)
attaches the MapLabel to this Markerstatic Marker
createProvided(Marker.Provided provided)
return a provided Marker with the given color.Marker
detachLabel()
detaches an attached Label.boolean
equals(java.lang.Object o)
java.lang.String
getId()
java.net.URL
getImageURL()
java.util.Optional<MapLabel>
getMapLabel()
int
hashCode()
Marker
setPosition(Coordinate position)
sets the marker's new positionMarker
setVisible(boolean visible)
sets the visibilty of the markerjava.lang.String
toString()
-
Methods inherited from class com.sothawo.mapjfx.MapCoordinateElement
cssClassProperty, getCssClass, getOffsetX, getOffsetY, getPosition, positionProperty, setCssClass
-
Methods inherited from class com.sothawo.mapjfx.MapElement
getVisible, visibleProperty
-
-
-
-
Constructor Detail
-
Marker
public Marker(java.net.URL imageURL)
constructs an object with the given URL and offset values set to 0.- Parameters:
imageURL
- the image URL
-
Marker
public Marker(java.net.URL imageURL, int offsetX, int offsetY)
constructs a Marker with the given values.- Parameters:
imageURL
- image URLoffsetX
- horizontal pixel offsetoffsetY
- vertical pixel offset- Throws:
java.lang.NullPointerException
- if imageURL is null
-
-
Method Detail
-
createProvided
public static Marker createProvided(Marker.Provided provided)
return a provided Marker with the given color.- Parameters:
provided
- desired color- Returns:
- Marker
- Throws:
java.lang.NullPointerException
- when provided is null
-
getId
public java.lang.String getId()
- Specified by:
getId
in classMapCoordinateElement
- Returns:
- the marker's id
-
getImageURL
public java.net.URL getImageURL()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classMapCoordinateElement
-
attachLabel
public Marker attachLabel(MapLabel mapLabel)
attaches the MapLabel to this Marker- Parameters:
mapLabel
- the MapLabel to attach- Returns:
- this object
- Throws:
java.lang.NullPointerException
- of mapLabel is null
-
detachLabel
public Marker detachLabel()
detaches an attached Label.- Returns:
- this object
-
getMapLabel
public java.util.Optional<MapLabel> getMapLabel()
-
setPosition
public Marker setPosition(Coordinate position)
Description copied from class:MapCoordinateElement
sets the marker's new position- Overrides:
setPosition
in classMapCoordinateElement
- Parameters:
position
- new position- Returns:
- this object
-
setVisible
public Marker setVisible(boolean visible)
Description copied from class:MapElement
sets the visibilty of the marker- Overrides:
setVisible
in classMapElement
- Parameters:
visible
- visibilty- Returns:
- this object
-
-