Class CombineContext

  • All Implemented Interfaces:
    Disposable

    public class CombineContext
    extends java.lang.Object
    implements Disposable
    CombineContext provides a suitcase of state used by Combinable shapes to generate a complex set of contours by applying boolean operations to one or more shapes. Instances of CombineContext are typically created and configured by a controller that operates on one or more combinable shapes and implements the boolean operation that is applied to those shapes, such as ShapeCombiner. The parameters used by shapes and by the controller are as follows: a globe, a minimum resolution in radians, a region of interest, and a GLU tessellator. The globe is used by shapes that define geometry relative to a globe. The resolution is used to filter shape detail and compute geometry for resolution independent shapes. Shape geometry outside of the region of interest may be ignored, clipped, or simplified at the discretion of the shape.

    CombineContext initializes its GLU tessellator according to the conventions for Combinable shapes. See the Combinable interface documentation for information on drawing Combinable contours. The complex set of contours computed as a result of drawing shapes into the tessellator are collected in the context's contour list. This list may be accessed by calling getContours().

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  CombineContext.TessCallbackAdapter
      Implementation of GLUtessellatorCallback that forwards GLU tessellator callbacks to protected methods on CombineContext.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.ArrayList<Sector> boundingSectors
      The shape bounding sectors associated with this context.
      protected ContourList contours
      The list of contours representing the result of a boolean operation on one or more Combinable shapes.
      protected java.util.ArrayList<LatLon> currentContour
      The vertices of the current contour currently being assembled.
      protected Globe globe
      The globe associated with the context.
      protected boolean isBoundingSectorMode
      Indicates whether this context is currently operating in bounding sector mode.
      protected double resolution
      A minimum resolution in radians used to filter shape detail and compute resolution independent geometry.
      protected Sector sector
      A geographic sector indicating the context's region of interest.
      protected com.jogamp.opengl.glu.GLUtessellator tess
      The GLU tessellator used to draw shape contours.
    • Constructor Summary

      Constructors 
      Constructor Description
      CombineContext​(Globe globe, double resolution)
      Creates a new combine context with the specified globe, resolution, and the default region of interest.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBoundingSector​(Sector sector)
      Adds the specified geographic sector to this context's list of shape bounding sectors.
      void addContour​(java.lang.Iterable<? extends LatLon> contour)
      Adds the specified iterable to this context's list of contours.
      void dispose()
      Releases the releases GLU tessellator resources associated with this context.
      java.util.List<Sector> getBoundingSectors()
      Returns the shape bounding sectors associated with this context.
      ContourList getContours()
      Returns the list of contours representing the result of a boolean operation on one or more Combinable shapes.
      Globe getGlobe()
      Returns the globe associated with this context.
      double getResolution()
      Returns the context's minimum resolution in radians.
      Sector getSector()
      Returns the context's region of interest as a geographic sector.
      com.jogamp.opengl.glu.GLUtessellator getTessellator()
      Returns the GLU tessellator used to draw shape contours.
      boolean isBoundingSectorMode()
      Indicates whether this context is currently operating in bounding sector mode.
      void removeAllBoundingSectors()
      Removes all entries from this context's list of shape bounding sectors.
      void removeAllContours()
      Removes all entries from this context's list of contours.
      void setBoundingSectorMode​(boolean tf)
      Specifies whether this context is currently operating in bounding sector mode.
      void setGlobe​(Globe globe)
      Specifies the globe associated with this context.
      void setResolution​(double resolution)
      Specifies the context's minimum resolution in radians.
      void setSector​(Sector sector)
      Specifies the context's region of interest as a geographic sector.
      protected void tessBegin​(int type)  
      protected void tessCombine​(double[] coords, java.lang.Object[] vertexData, float[] weight, java.lang.Object[] outData)  
      protected void tessEnd()  
      protected void tessError​(int errno)  
      protected void tessVertex​(java.lang.Object vertexData)  
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • globe

        protected Globe globe
        The globe associated with the context.
      • sector

        protected Sector sector
        A geographic sector indicating the context's region of interest.
      • resolution

        protected double resolution
        A minimum resolution in radians used to filter shape detail and compute resolution independent geometry.
      • tess

        protected com.jogamp.opengl.glu.GLUtessellator tess
        The GLU tessellator used to draw shape contours. Initalized during construction.
      • contours

        protected ContourList contours
        The list of contours representing the result of a boolean operation on one or more Combinable shapes.
      • currentContour

        protected java.util.ArrayList<LatLon> currentContour
        The vertices of the current contour currently being assembled. Used by the tess* methods.
      • isBoundingSectorMode

        protected boolean isBoundingSectorMode
        Indicates whether this context is currently operating in bounding sector mode.
      • boundingSectors

        protected java.util.ArrayList<Sector> boundingSectors
        The shape bounding sectors associated with this context.
    • Constructor Detail

      • CombineContext

        public CombineContext​(Globe globe,
                              double resolution)
        Creates a new combine context with the specified globe, resolution, and the default region of interest.
        Parameters:
        globe - the globe to associate with this context. Shape geometry defined relative to a globe must use this globe to compute that geometry.
        resolution - the minimum resolution, in radians. Used to filter shape detail and compute geometry for resolution independent shapes.
        Throws:
        java.lang.IllegalArgumentException - if the globe is null.
    • Method Detail

      • dispose

        public void dispose()
        Releases the releases GLU tessellator resources associated with this context.
        Specified by:
        dispose in interface Disposable
      • getGlobe

        public Globe getGlobe()
        Returns the globe associated with this context. Shape geometry defined relative to a globe must use this globe to compute that geometry.
        Returns:
        the globe associated with this context.
      • setGlobe

        public void setGlobe​(Globe globe)
        Specifies the globe associated with this context. Shape geometry defined relative to a globe must use this globe to compute that geometry.
        Parameters:
        globe - the globe to associate with this context.
        Throws:
        java.lang.IllegalArgumentException - if the globe is null.
      • getSector

        public Sector getSector()
        Returns the context's region of interest as a geographic sector. Shape geometry outside of this region may be ignored, clipped, or simplified at the discretion of the shape.
        Returns:
        the geographic sector indicating the context's region of interest.
      • setSector

        public void setSector​(Sector sector)
        Specifies the context's region of interest as a geographic sector. Shape geometry outside of this region may be ignored, clipped, or simplified at the discretion of the shape.
        Parameters:
        sector - a geographic sector indicating the context's region of interest.
        Throws:
        java.lang.IllegalArgumentException - if the sector is null.
      • getResolution

        public double getResolution()
        Returns the context's minimum resolution in radians. Used to filter shape detail and compute resolution independent geometry.
        Returns:
        the minimum resolution, in radians.
      • setResolution

        public void setResolution​(double resolution)
        Specifies the context's minimum resolution in radians. Used to filter shape detail and compute resolution independent geometry.
        Parameters:
        resolution - the minimum resolution, in radians.
      • getTessellator

        public com.jogamp.opengl.glu.GLUtessellator getTessellator()
        Returns the GLU tessellator used to draw shape contours. The GLU tessellator is configured according to the conventions for Combinable shapes. See the Combinable interface documentation for information on drawing Combinable contours. The complex set of contours computed as a result of drawing shapes into the tessellator are collected in the context's contour list. This list may be accessed by calling getContours().
        Returns:
        the GLU tessellator used to draw shape contours.
      • getContours

        public ContourList getContours()
        Returns the list of contours representing the result of a boolean operation on one or more Combinable shapes.
        Returns:
        the list of contours associated with this context.
      • addContour

        public void addContour​(java.lang.Iterable<? extends LatLon> contour)
        Adds the specified iterable to this context's list of contours.
        Parameters:
        contour - the contour to add.
        Throws:
        java.lang.IllegalArgumentException - if the contour is null.
      • removeAllContours

        public void removeAllContours()
        Removes all entries from this context's list of contours.
      • tessBegin

        protected void tessBegin​(int type)
      • tessVertex

        protected void tessVertex​(java.lang.Object vertexData)
      • tessEnd

        protected void tessEnd()
      • tessCombine

        protected void tessCombine​(double[] coords,
                                   java.lang.Object[] vertexData,
                                   float[] weight,
                                   java.lang.Object[] outData)
      • tessError

        protected void tessError​(int errno)
      • isBoundingSectorMode

        public boolean isBoundingSectorMode()
        Indicates whether this context is currently operating in bounding sector mode. When Combinable.combine(CombineContext) is called in this mode, a shape adds its geographic bounding sector to the context by calling addBoundingSector(Sector). See the Combinable interface documentation for more information.
        Returns:
        true if the context is currently in bounding sector mode, otherwise false.
      • setBoundingSectorMode

        public void setBoundingSectorMode​(boolean tf)
        Specifies whether this context is currently operating in bounding sector mode. When Combinable.combine(CombineContext) is called in this mode, a shape adds its geographic bounding sector to the context by calling addBoundingSector(Sector). See the Combinable interface documentation for more information.
        Parameters:
        tf - true to set the context is bounding sector mode, otherwise false.
      • getBoundingSectors

        public java.util.List<Sector> getBoundingSectors()
        Returns the shape bounding sectors associated with this context. This list is populated by Combinable shapes when the context is in bounding sector mode.
        Returns:
        the shape bounding sectors associated with this context.
        See Also:
        isBoundingSectorMode()
      • addBoundingSector

        public void addBoundingSector​(Sector sector)
        Adds the specified geographic sector to this context's list of shape bounding sectors.
        Parameters:
        sector - the sector to add.
        Throws:
        java.lang.IllegalArgumentException - if the sector is null.
      • removeAllBoundingSectors

        public void removeAllBoundingSectors()
        Removes all entries from this context's list of shape bounding sectors.