Class WorldMapView

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public class WorldMapView
    extends Control
    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