Class DirectedPath

    • Field Detail

      • DEFAULT_ARROW_LENGTH

        public static final double DEFAULT_ARROW_LENGTH
        Default arrow length, in meters.
        See Also:
        Constant Field Values
      • DEFAULT_ARROW_ANGLE

        public static final Angle DEFAULT_ARROW_ANGLE
        Default arrow angle.
      • DEFAULT_MAX_SCREEN_SIZE

        public static final double DEFAULT_MAX_SCREEN_SIZE
        Default maximum screen size of the arrowheads, in pixels.
        See Also:
        Constant Field Values
      • arrowLength

        protected double arrowLength
        The length, in meters, of the arrowhead, from tip to base.
      • arrowAngle

        protected Angle arrowAngle
        The angle of the arrowhead tip.
      • maxScreenSize

        protected double maxScreenSize
        The maximum screen size, in pixels, of the direction arrowheads.
    • Constructor Detail

      • DirectedPath

        public DirectedPath()
        Creates a path with no positions.
      • DirectedPath

        public DirectedPath​(java.lang.Iterable<? extends Position> positions)
        Creates a path with specified positions.

        Note: If fewer than two positions is specified, no path is drawn.

        Parameters:
        positions - the path positions. This reference is retained by this shape; the positions are not copied. If any positions in the set change, Path.setPositions(Iterable) must be called to inform this shape of the change.
        Throws:
        java.lang.IllegalArgumentException - if positions is null.
      • DirectedPath

        public DirectedPath​(Position.PositionList positions)
        Creates a path with positions specified via a generic list.

        Note: If fewer than two positions is specified, the path is not drawn.

        Parameters:
        positions - the path positions. This reference is retained by this shape; the positions are not copied. If any positions in the set change, Path.setPositions(Iterable) must be called to inform this shape of the change.
        Throws:
        java.lang.IllegalArgumentException - if positions is null.
      • DirectedPath

        public DirectedPath​(Position posA,
                            Position posB)
        Creates a path between two positions.
        Parameters:
        posA - the first position.
        posB - the second position.
        Throws:
        java.lang.IllegalArgumentException - if either position is null.
    • Method Detail

      • getArrowLength

        public double getArrowLength()
        Indicates the length, in meters, of the direction arrowheads, from base to tip.
        Returns:
        The geographic length of the direction arrowheads.
      • setArrowLength

        public void setArrowLength​(double arrowLength)
        Specifies the length, in meters, of the direction arrowheads, from base to tip.
        Parameters:
        arrowLength - length, in meters, of the direction arrowheads. The length must be greater than zero.
      • getMaxScreenSize

        public double getMaxScreenSize()
        Indicates the maximum screen size, in pixels, of the direction arrowheads. The arrowheads are drawn a fixed geographic, but they are not allowed to get bigger than maxScreenSize pixels.
        Returns:
        The maximum screen size, in pixels, of the direction arrowheads, measured tip to base.
      • setMaxScreenSize

        public void setMaxScreenSize​(double maxScreenSize)
        Specifies the maximum screen size, in pixels, of the direction arrowheads. The arrowheads are drawn at a fixed geographic size, but they will not allowed to get bigger than maxScreenSize pixels.
        Parameters:
        maxScreenSize - the maximum screen size, in pixels, of the direction arrowheads, measured tip to base.
      • getArrowAngle

        public Angle getArrowAngle()
        Indicates the angle of the direction arrowheads. A larger angle draws a fat arrowhead, and a smaller angle draws a narrow arrow head.
        Returns:
        The angle of the direction arrowhead tip.
      • setArrowAngle

        public void setArrowAngle​(Angle arrowAngle)
        Specifies the angle of the direction arrowheads. A larger angle draws a fat arrowhead, and a smaller angle draws a narrow arrow.
        Parameters:
        arrowAngle - angle of the direction arrowhead tip. Valid values are between 0 degrees and 90 degrees.
      • intersectsFrustum

        protected boolean intersectsFrustum​(DrawContext dc)
        Description copied from class: AbstractShape
        Determines whether this shape intersects the view frustum.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Overrides:
        intersectsFrustum in class AbstractShape
        Parameters:
        dc - the current draw context.
        Returns:
        true if this shape intersects the frustum, otherwise false.
      • computePath

        protected void computePath​(DrawContext dc,
                                   java.util.List<Position> positions,
                                   Path.PathData pathData)
        Computes the shape's model-coordinate path from a list of positions. Applies the path's terrain-conformance settings. Adds extrusion points -- those on the ground -- when the path is extruded.

        Overridden to also compute the geometry of the direction arrows.

        Overrides:
        computePath in class Path
        Parameters:
        dc - the current draw context.
        positions - the positions to create a path for.
        pathData - the current globe-specific path data.
      • updateSurfaceShape

        protected void updateSurfaceShape()
        Sets surface shape parameters prior to picking and rendering the 2D shape used to represent this shape on 2D globes. Subclasses should override this method if they need to update more than the highlighted state, visibility state and delegate owner.

        Overridden to update the arrow properties of DirectedSurfacePolyline.

        Overrides:
        updateSurfaceShape in class Path
      • computeDirectionArrows

        protected void computeDirectionArrows​(DrawContext dc,
                                              Path.PathData pathData)
        Compute the geometry of the direction arrows.
        Parameters:
        dc - current draw context.
        pathData - the current globe-specific path data.
      • computeArrowheadGeometry

        protected void computeArrowheadGeometry​(DrawContext dc,
                                                int poleA,
                                                int poleB,
                                                Vec4 polePtA,
                                                Vec4 polePtB,
                                                java.nio.FloatBuffer buffer,
                                                Path.PathData pathData)
        Compute the geometry of a direction arrow between two points.
        Parameters:
        dc - current draw context
        poleA - The first pole.
        poleB - The second pole.
        polePtA - the first pole position. This is one of the application defined path positions.
        polePtB - second pole position
        buffer - buffer in which to place computed points
        pathData - the current globe-specific path data.
      • isArrowheadSmall

        protected boolean isArrowheadSmall​(DrawContext dc,
                                           Vec4 arrowPt,
                                           int numPixels)
        Determines if an direction arrow drawn a point will be less than a specified number of pixels.
        Parameters:
        dc - current draw context
        arrowPt - point at which to draw direction arrow
        numPixels - the number of pixels which is considered to be "small"
        Returns:
        true if an arrow drawn at arrowPt would occupy less than or equal to numPixels.
      • doDrawOutline

        protected void doDrawOutline​(DrawContext dc)
        Draws this shape's outline. Called immediately after calling AbstractShape.prepareToDrawOutline(DrawContext, ShapeAttributes, ShapeAttributes), which establishes OpenGL state for lighting, blending, pick color and line attributes. Subclasses should execute the drawing commands specific to the type of shape.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        If this Path is entirely located on the terrain, this applies an offset to the Path's depth values to to ensure it shows over the terrain. This does not apply a depth offset in any other case to avoid incorrectly drawing the path over objects it should be behind, including the terrain. In addition to applying a depth offset, this disables writing to the depth buffer to avoid causing subsequently drawn ordered renderables to incorrectly fail the depth test. Since this Path is located on the terrain, the terrain already provides the necessary depth values and we can be certain that other ordered renderables should appear on top of it.

        Overridden to also draw direction arrows.

        Overrides:
        doDrawOutline in class Path
        Parameters:
        dc - Current draw context.
      • drawDirectionArrows

        protected void drawDirectionArrows​(DrawContext dc,
                                           Path.PathData pathData)
        Draws this DirectedPath's direction arrows. Called from doDrawOutline(gov.nasa.worldwind.render.DrawContext) before drawing the Path's actual outline.

        If this Path is entirely located on the terrain, this applies an offset to the arrow's depth values to to ensure they shows over the terrain. This does not apply a depth offset in any other case to avoid incorrectly drawing the arrows over objects they should be behind, including the terrain. In addition to applying a depth offset, this disables writing to the depth buffer to avoid causing subsequently drawn ordered renderables to incorrectly fail the depth test. Since the arrows are located on the terrain, the terrain already provides the necessary depth values and we can be certain that other ordered renderables should appear on top of them.

        Parameters:
        dc - Current draw context.
        pathData - the current globe-specific path data.