Class CompassLayer

    • Field Detail

      • iconFilePath

        protected java.lang.String iconFilePath
      • compassToViewportScale

        protected double compassToViewportScale
      • iconScale

        protected double iconScale
      • borderWidth

        protected int borderWidth
      • position

        protected java.lang.String position
      • resizeBehavior

        protected java.lang.String resizeBehavior
      • iconWidth

        protected int iconWidth
      • iconHeight

        protected int iconHeight
      • locationCenter

        protected Vec4 locationCenter
      • locationOffset

        protected Vec4 locationOffset
      • showTilt

        protected boolean showTilt
      • frameStampForPicking

        protected long frameStampForPicking
      • frameStampForDrawing

        protected long frameStampForDrawing
    • Constructor Detail

      • CompassLayer

        public CompassLayer()
      • CompassLayer

        public CompassLayer​(java.lang.String iconFilePath)
    • Method Detail

      • getIconFilePath

        public java.lang.String getIconFilePath()
        Returns the layer's current icon file path.
        Returns:
        the icon file path
      • setIconFilePath

        public void setIconFilePath​(java.lang.String iconFilePath)
        Sets the compass icon's image location. The layer first searches for this location in the current Java classpath. If not found then the specified path is assumed to refer to the local file system. found there then the
        Parameters:
        iconFilePath - the path to the icon's image file
      • getCompassToViewportScale

        public double getCompassToViewportScale()
        Returns the layer's compass-to-viewport scale factor.
        Returns:
        the compass-to-viewport scale factor
      • setCompassToViewportScale

        public void setCompassToViewportScale​(double compassToViewportScale)
        Sets the scale factor applied to the viewport size to determine the displayed size of the compass icon. This scale factor is used only when the layer's resize behavior is AVKey.RESIZE_STRETCH or AVKey.RESIZE_SHRINK_ONLY. The icon's width is adjusted to occupy the proportion of the viewport's width indicated by this factor. The icon's height is adjusted to maintain the compass image's native aspect ratio.
        Parameters:
        compassToViewportScale - the compass to viewport scale factor
      • getIconScale

        public double getIconScale()
        Returns the icon scale factor. See setIconScale(double) for a description of the scale factor.
        Returns:
        the current icon scale
      • setIconScale

        public void setIconScale​(double iconScale)
        Sets the scale factor defining the displayed size of the compass icon relative to the icon's width and height in its image file. Values greater than 1 magify the image, values less than one minify it. If the layer's resize behavior is other than AVKey.RESIZE_KEEP_FIXED_SIZE, the icon's displayed sized is further affected by the value specified by setCompassToViewportScale(double) and the current viewport size.

        The default icon scale is 0.5.

        Parameters:
        iconScale - the icon scale factor
      • getResizeBehavior

        public java.lang.String getResizeBehavior()
        Returns the compass icon's resize behavior.
        Returns:
        the icon's resize behavior
      • setResizeBehavior

        public void setResizeBehavior​(java.lang.String resizeBehavior)
        Sets the behavior the layer uses to size the compass icon when the viewport size changes, typically when the WorldWind window is resized. If the value is AVKey.RESIZE_KEEP_FIXED_SIZE, the icon size is kept to the size specified in its image file scaled by the layer's current icon scale. If the value is AVKey.RESIZE_STRETCH, the icon is resized to have a constant size relative to the current viewport size. If the viewport shrinks the icon size decreases; if it expands then the icon file enlarges. The relative size is determined by the current compass-to-viewport scale and by the icon's image file size scaled by the current icon scale. If the value is AVKey.RESIZE_SHRINK_ONLY (the default), icon sizing behaves as for AVKey.RESIZE_STRETCH but the icon will not grow larger than the size specified in its image file scaled by the current icon scale.
        Parameters:
        resizeBehavior - the desired resize behavior
      • getBorderWidth

        public int getBorderWidth()
      • setBorderWidth

        public void setBorderWidth​(int borderWidth)
        Sets the compass icon offset from the viewport border.
        Parameters:
        borderWidth - the number of pixels to offset the compass icon from the borders indicated by setPosition(String).
      • getPosition

        public java.lang.String getPosition()
        Returns the current relative compass icon position.
        Returns:
        the current compass position
      • setPosition

        public void setPosition​(java.lang.String position)
        Sets the relative viewport location to display the compass icon. Can be one of AVKey.NORTHEAST (the default), AVKey.NORTHWEST, AVKey.SOUTHEAST, or AVKey.SOUTHWEST. These indicate the corner of the viewport to place the icon.
        Parameters:
        position - the desired compass position
      • getLocationCenter

        public Vec4 getLocationCenter()
        Returns the current compass image location.
        Returns:
        the current location center. May be null.
      • setLocationCenter

        public void setLocationCenter​(Vec4 locationCenter)
        Specifies the screen location of the compass image, relative to the image's center. May be null. If this value is non-null, it overrides the position specified by setPosition(String). The location is specified in pixels. The origin is the window's lower left corner. Positive X values are to the right of the origin, positive Y values are upwards from the origin. The final image location will be affected by the currently specified location offset if a non-null location offset has been specified (see setLocationOffset(gov.nasa.worldwind.geom.Vec4)).
        Parameters:
        locationCenter - the location center. May be null.
        See Also:
        setPosition(String), setLocationOffset(gov.nasa.worldwind.geom.Vec4)
      • getLocationOffset

        public Vec4 getLocationOffset()
        Returns the current location offset. See #setLocationOffset for a description of the offset and its values.
        Returns:
        the location offset. Will be null if no offset has been specified.
      • setLocationOffset

        public void setLocationOffset​(Vec4 locationOffset)
        Specifies a placement offset from the compass' position on the screen.
        Parameters:
        locationOffset - the number of pixels to shift the compass image from its specified screen position. A positive X value shifts the image to the right. A positive Y value shifts the image up. If null, no offset is applied. The default offset is null.
        See Also:
        setLocationCenter(gov.nasa.worldwind.geom.Vec4), setPosition(String)
      • isShowTilt

        public boolean isShowTilt()
      • setShowTilt

        public void setShowTilt​(boolean showTilt)
      • computeScale

        protected double computeScale​(java.awt.Rectangle viewport)
      • getScaledIconWidth

        protected double getScaledIconWidth()
      • getScaledIconHeight

        protected double getScaledIconHeight()
      • computeLocation

        protected Vec4 computeLocation​(java.awt.Rectangle viewport,
                                       double scale)
      • computeHeading

        protected double computeHeading​(View view)
      • computePitch

        protected double computePitch​(View view)
      • initializeTexture

        protected void initializeTexture​(DrawContext dc)