Interface GraphicsContainer<G extends Graphic>


  • public interface GraphicsContainer<G extends Graphic>
    Holds a collection of graphics to be drawn in a canvas. The GraphicsContainer implementation typically depends on the canvas implementation. For example an AWT canvas may be associated to a GraphicsContainer using a Graphics2D handler for drawing, while a SWT canvas may be associated to an other GraphicsContainer implementation using a different drawing toolkit.

    Graphics can be added or removed with method invocations on the collection returned by graphics(), which is a "live" collection. Note that a GraphicsContainer instance may restrict the acceptable graphic implementations.

    Since:
    GeoAPI 2.2
    • Method Detail

      • getCanvas

        Canvas getCanvas()
        Returns the canvas where this GraphicsContainer will drawn the graphics.
        Returns:
        the canvas where to drawn.
      • getGraphicsEnvelope

        Envelope getGraphicsEnvelope()
      • graphics

        Collection<G> graphics()
        Returns the collection of all graphics. Changes to this collection (addition, removal) are reflected into the set of graphics to be rendered. Note that the returned collection must notifies the GraphicsContainer listener about any addition or removal.

        When new graphics are added, implementations shall respect the z-order. When two added graphics have the same z-order, the most recently added one should be on top.

        Returns:
        Collection of all graphics, as a live collection.
      • addContainerListener

        void addContainerListener​(ContainerListener listener)
        Adds a listener to be notified when a graphic is added or removed.
        Parameters:
        listener - The listener to add.
      • removeContainerListener

        void removeContainerListener​(ContainerListener listener)
        Removes a listener.
        Parameters:
        listener - The listener to remove.
      • dispose

        void dispose()
        Provides a hint that a GraphicsContainer is no longer needed. Implementations may use this method to release resources, if needed. Implementations may also implement this method to return the GraphicsContainer to a GraphicsContainer pool.

        It is an error to reference a GraphicsContainer in any way after its dispose method has been called.