Interface GTRenderer

  • All Known Implementing Classes:
    StreamingRenderer

    public interface GTRenderer
    GeoTools renderer for rendering spatial content into a Graphics2D. Typical usage:
              Rectangle paintArea = new Rectangle(width, height);
              ReferencedEnvelope mapArea = map.getBounds();
    
              renderer = new StreamingRenderer();
              renderer.setContext(map);
    
              RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
              renderer.setJava2DHints(hints);
    
              Map rendererParams = new HashMap();
              rendererParams.put("optimizedDataLoadingEnabled",Boolean.valueOf(true) );
    
              renderer.setRendererHints( renderParams );
    
              renderer.paint(graphic, paintArea, mapArea);
     
    Author:
    David Blasby, Simone Giannecchini
    • Method Detail

      • stopRendering

        void stopRendering()
        If you call this method from another thread than the one that called paint or render the rendering will be forcefully stopped before termination.
      • addRenderListener

        void addRenderListener​(RenderListener listener)
        adds a listener that responds to error events of feature rendered events.
        Parameters:
        listener - the listener to add.
        See Also:
        RenderListener
      • removeRenderListener

        void removeRenderListener​(RenderListener listener)
        Removes a render listener.
        Parameters:
        listener - the listener to remove.
        See Also:
        RenderListener
      • setJava2DHints

        void setJava2DHints​(RenderingHints hints)
        Hints used to configure Java2D Graphics prior to rendering.
      • getJava2DHints

        RenderingHints getJava2DHints()
        Hints used to configure Java2D Graphics prior to rendering.
        Returns:
        Hints
      • setRendererHints

        void setRendererHints​(Map<?,​?> hints)
        Hints used to configure rendering process.
      • getRendererHints

        Map<Object,​Object> getRendererHints()
        Hints used to configure rendering process
        Returns:
        Hints used to configure rendering process
      • setMapContent

        void setMapContent​(MapContent mapContent)
        Sets the MapContent which contains the data to be rendered.
        Parameters:
        mapContent - the map content
      • getMapContent

        MapContent getMapContent()
        Gets the MapContent instance which contains the data being rendered.
        Returns:
        the MapContent instance
      • paint

        void paint​(Graphics2D graphics,
                   Rectangle paintArea,
                   AffineTransform worldToScreen)
        Renders features based on the map layers and their styles as specified in the map content using setContext.

        This version of the method assumes that the size of the output area and the transformation from coordinates to pixels are known. The latter determines the map scale. The viewport (the visible part of the map) will be calculated internally.

        Parameters:
        graphics - The graphics object to draw to.
        paintArea - The size of the output area in output units (eg: pixels).
        worldToScreen - A transform which converts World coordinates to Screen coordinates.
      • paint

        void paint​(Graphics2D graphics,
                   Rectangle paintArea,
                   Envelope mapArea)
        Renders features based on the map layers and their styles as specified in the map context using setContext.

        This version of the method assumes that the area of the visible part of the map and the size of the output area are known. The transform between the two is calculated internally.

        Parameters:
        graphics - The graphics object to draw to.
        paintArea - The size of the output area in output units (eg: pixels).
        mapArea - the map's visible area (viewport) in map coordinates.
      • paint

        void paint​(Graphics2D graphics,
                   Rectangle paintArea,
                   ReferencedEnvelope mapArea)
        Renders features based on the map layers and their styles as specified in the map context using setContext.

        This version of the method assumes that the area of the visible part of the map and the size of the output area are known. The transform between the two is calculated internally.

        Parameters:
        graphics - The graphics object to draw to.
        paintArea - The size of the output area in output units (eg: pixels).
        mapArea - the map's visible area (viewport) in map coordinates.
      • paint

        void paint​(Graphics2D graphics,
                   Rectangle paintArea,
                   Envelope mapArea,
                   AffineTransform worldToScreen)
        Renders features based on the map layers and their styles as specified in the map context using setContext.

        This version of the method assumes that paint area, enelope and worldToScreen transform are already computed and in sync. Use this method to avoid recomputation. Note however that no check is performed that they are really synchronized!

        Parameters:
        graphics - The graphics object to draw to.
        paintArea - The size of the output area in output units (eg: pixels).
        mapArea - the map's visible area (viewport) in map coordinates.
        worldToScreen - A transform which converts World coordinates to Screen coordinates.
      • paint

        void paint​(Graphics2D graphics,
                   Rectangle paintArea,
                   ReferencedEnvelope mapArea,
                   AffineTransform worldToScreen)
        Renders features based on the map layers and their styles as specified in the map context using setContext.

        This version of the method assumes that paint area, enelope and worldToScreen transform are already computed and in sync. Use this method to avoid recomputation. Note however that no check is performed that they are really synchronized!

        Parameters:
        graphics - The graphics object to draw to.
        paintArea - The size of the output area in output units (eg: pixels).
        mapArea - the map's visible area (viewport) in map coordinates.
        worldToScreen - A transform which converts World coordinates to Screen coordinates.