Class MapRendererFactory


  • public final class MapRendererFactory
    extends java.lang.Object

    MapRendererFactory manages a list of map renderer classes and associated meta data (display name, description).

    Plugins can implement and supply their own map renderers.

    Sample code in a plugin
     public class MyMapRenderer extends AbstractMapRenderer {
        // ....
     }
    
     // to be called when the plugin is created
     MapRendererFactory factory = MapRendererFactory.getInstance();
     factory.register(MyMapRenderer.class, "My map renderer", "This is is a fast map renderer");
     factory.activate(MyMapRenderer.class);
    
     
    Since:
    4087
    • Method Detail

      • loadRendererClass

        private static java.lang.Class<?> loadRendererClass​(java.lang.String className)
      • activateMapRenderer

        private void activateMapRenderer​(java.lang.String rendererClassName)
      • isRegistered

        public boolean isRegistered​(java.lang.Class<? extends AbstractMapRenderer> renderer)

        Replies true, if Renderer is already a registered map renderer class.

        Parameters:
        renderer - the map renderer class. Must not be null.
        Returns:
        true, if Renderer is already a registered map renderer class
        Throws:
        java.lang.IllegalArgumentException - if renderer is null
      • register

        public void register​(java.lang.Class<? extends AbstractMapRenderer> renderer,
                             java.lang.String displayName,
                             java.lang.String description)

        Registers a map renderer class.

        Parameters:
        renderer - the map renderer class. Must not be null.
        displayName - the display name to be displayed in UIs (i.e. in the preference dialog)
        description - the description
        Throws:
        java.lang.IllegalArgumentException - if renderer is null
        java.lang.IllegalStateException - if renderer is already registered
      • unregister

        public void unregister​(java.lang.Class<? extends AbstractMapRenderer> renderer)

        Unregisters a map renderer class.

        If the respective class is also the active renderer, the renderer is reset to the default renderer.

        Parameters:
        renderer - the map renderer class. Must not be null.
      • activate

        public void activate​(java.lang.Class<? extends AbstractMapRenderer> renderer)

        Activates a map renderer class.

        The renderer class must already be registered.

        Parameters:
        renderer - the map renderer class. Must not be null.
        Throws:
        java.lang.IllegalArgumentException - if renderer is null
        java.lang.IllegalStateException - if renderer isn't registered yet
      • activateDefault

        public void activateDefault()

        Activates the default map renderer.

        Throws:
        java.lang.IllegalStateException - if the default renderer StyledMapRenderer isn't registered
      • isWireframeMapRendererActive

        public boolean isWireframeMapRendererActive()

        Replies true, if currently the wireframe map renderer is active. Otherwise, false.

        There is a specific method for WireframeMapRenderer for legacy support. Until 03/2011 there were only two possible map renderers in JOSM: the wireframe renderer and the styled renderer. For the time being there are still UI elements (menu entries, etc.) which toggle between these two renderers only.

        Returns:
        true, if currently the wireframe map renderer is active. Otherwise, false
      • isMapRendererActive

        public boolean isMapRendererActive​(java.lang.Class<? extends AbstractMapRenderer> clazz)

        Replies true, if currently the specified map renderer is active. Otherwise, false.

        Parameters:
        clazz - The class that we are checking to see if it is the current renderer
        Returns:
        true, if currently the wireframe map renderer is active. Otherwise, false
        Since:
        19176