Top Description Inners Fields Constructors Methods
org.controlsfx.control

public Class WorldMapView

extends ControlsFXControl
Class Inheritance
Imports
impl.org.controlsfx.worldmap.WorldMapViewSkin, javafx.beans.property.*, javafx.collections.FXCollections, .ObservableList, javafx.scene.Node, javafx.scene.control.Skin, .Tooltip, javafx.scene.shape.Circle, .SVGPath, javafx.util.Callback, java.util.Locale, .Objects

A simple map view showing either the entire world or a list of countries. The view is not capable of displaying detailed map information. The view is based on simple SVG data found in a properties file of the ControlsFX distribution. A big advantage of this approach is the fact that the view can be run without a network connection. In addition to showing countries or the world the view can also show locations. The map can be customized by specifying custom factories for the country and location views.

Example: Country View Factory

The code snippet below shows how a custom country view factory can be used to assign individual styles to all countries. In this example the style is used to color the countries differently. worldMapView.setCountryViewFactory(country -> { CountryView view = new CountryView(country); if (showColorsProperty.get()) { view.getStyleClass().add("country" + ((country.ordinal() % 8) + 1)); } return view; });

Example: Location View Factory

Each location can be visualized with its own node. The default location view factory creates a simple circle shape.

worldMapView.setLocationViewFactory(location -> { Circle circle = new Circle(); circle.getStyleClass().add("location"); circle.setRadius(4); circle.setTranslateX(-4); // translate to center node on location circle.setTranslateY(-4); // translate to center node on location return circle; }); Shown below is a screenshot of the world map view:

Screenshot of WorldMapView

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
WorldMapView.Country

An enumerator listing all countries of the world.

public static class
WorldMapView.CountryView

A view used to visualize the bounds of a country via SVG.

public static class
WorldMapView.Location

An object using latitude and longitude information to specify a location in the real world.

public static enum
WorldMapView.SelectionMode

The selection modes supported by the view.

Field Summary

Modifier and TypeField and Description
private final ListProperty<WorldMapView.Country>
private final ObjectProperty<WorldMapView.SelectionMode>
private final ObjectProperty<Callback<WorldMapView.Country, WorldMapView.CountryView>>
private static final String
private final ListProperty<WorldMapView.Location>
private final ObjectProperty<WorldMapView.SelectionMode>
private final ObjectProperty<Callback<WorldMapView.Location, Node>>
private final ListProperty<WorldMapView.Country>
private final ListProperty<WorldMapView.Location>
private final BooleanProperty
private Tooltip
private final DoubleProperty

Constructor Summary

AccessConstructor and Description
public
WorldMapView()

Constructs a new map view with an initially empty list of countries which will result in the entire world to be shown.

Method Summary

Modifier and TypeMethod and Description
public final ListProperty<WorldMapView.Country>

Returns:

the list of countries shown by the map
countriesProperty
()

A property used to store the list of countries that should be shown by the map.

public final ObjectProperty<WorldMapView.SelectionMode>

Returns:

the country selection mode property
countrySelectionModeProperty
()

A property used to store the selection mode that will be applied for the selection of countries.

public final ObjectProperty<Callback<WorldMapView.Country, WorldMapView.CountryView>>

Returns:

the country view factory property
countryViewFactoryProperty
()

A property used to store a factory callback for creating new country views.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObservableList<WorldMapView.Country>

Returns:

the list of countries shown by the map
getCountries
()

Returns the list of countries that will be shown by the map.

public final WorldMapView.SelectionMode

Returns:

the country selection mode
getCountrySelectionMode
()

Returns the value of countrySelectionModeProperty()

public final Callback<WorldMapView.Country, WorldMapView.CountryView>

Returns:

the country view factory
getCountryViewFactory
()

Returns the value of countryViewFactoryProperty().

public final ObservableList<WorldMapView.Location>

Returns:

the list of locations
getLocations
()

Returns the list of locations shown by the map.

public final WorldMapView.SelectionMode

Returns:

the location selection mode
getLocationSelectionMode
()

Returns the value of locationSelectionModeProperty()

public final Callback<WorldMapView.Location, Node>

Returns:

the location view factory
getLocationViewFactory
()

Returns the value of locationViewFactoryProperty().

public final ObservableList<WorldMapView.Country>

Returns:

the list of selected countries
getSelectedCountries
()

Returns the list of currently selected countries.

public final ObservableList<WorldMapView.Location>

Returns:

the list of selected locations
getSelectedLocations
()

Returns the list of currently selected locations.

public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final double

Returns:

the zoom factor
getZoomFactor
()

Returns the value of zoomFactorProperty().

public final boolean

Returns:

true if locations are shown
isShowLocations
()

Returns the value of showLocationsProperty().

public final ObjectProperty<WorldMapView.SelectionMode>

Returns:

the location selection mode property
locationSelectionModeProperty
()

A property used to store the selection mode that will be applied for the selection of locations.

public final ListProperty<WorldMapView.Location>
locationsProperty()

A property used to store the list of locations shown by the map.

public final ObjectProperty<Callback<WorldMapView.Location, Node>>

Returns:

the location view factory property
locationViewFactoryProperty
()

A property used to store a factory callback for creating new location views (nodes).

public final ListProperty<WorldMapView.Country>

Returns:

the selected countries property
selectedCountriesProperty
()

A property used for storing the list of selected countries (aka "the selection model").

public final ListProperty<WorldMapView.Location>

Returns:

the selected locations property
selectedLocationsProperty
()

A property used for storing the list of selected locations (aka "the selection model").

public final void
setCountries(ObservableList<WorldMapView.Country>
the list of countries shown by the map
countries
)

Sets the list of countries that will be shown by the map.

public final void
setCountrySelectionMode(WorldMapView.SelectionMode
the country selection mode
mode
)

Sets the value of countrySelectionModeProperty().

public final void
public final void
setLocations(ObservableList<WorldMapView.Location>
the list of locations
locations
)

Sets the list of locations shown by the map.

public final void
setLocationSelectionMode(WorldMapView.SelectionMode
the location selection mode
mode
)

Sets the value of locationSelectionModeProperty().

public final void
setLocationViewFactory(Callback<WorldMapView.Location, Node>
the location view factory
factory
)

Sets the value of locationViewFactoryProperty().

public final void
setSelectedCountries(ObservableList<WorldMapView.Country>
the selected countries
countries
)

Sets the list of currently selected countries.

public final void
setSelectedLocations(ObservableList<WorldMapView.Location>
the selected locations
locations
)

Sets the list of currently selected locations.

public final void
setShowLocations(boolean
if true then locations are shown
show
)

Sets the value of showLocationsProperty().

public final void
setZoomFactor(double
the zoom factor
factor
)

Sets the value of zoomFactorProperty().

public final BooleanProperty

Returns:

a property to control the visibility of locations
showLocationsProperty
()

A property used to control whether locations will be shown by the map or not.

public final DoubleProperty

Returns:

the zoom factor
zoomFactorProperty
()

A property used to store the current zoom factor, a value between 1 and 10.

Inherited from org.controlsfx.control.ControlsFXControl:
getUserAgentStylesheet