Ejemplo n.º 1
0
        /**
         * {@inheritDoc} Overridden to set the expiration time of the placemark's icon based on the HTTP headers of the
         * linked resource.
         */
        protected WWTexture initializeTexture(String address)
        {
            WWTexture texture = super.initializeTexture(address);

            if (texture != null)
            {
                // Query the KMLRoot for the expiration time.
                long expiration = this.parent.getRoot().getExpiration(address);

                // Set the Icon's expiration. This has no effect if the refreshMode is not onExpire.
                String       mode      = this.isHighlighted() ? KMLConstants.HIGHLIGHT : KMLConstants.NORMAL;
                KMLIconStyle iconStyle = (KMLIconStyle)this.parent.getSubStyle(new KMLIconStyle(null), mode);
                KMLIcon      icon      = iconStyle.getIcon();
                if (icon != null)
                {
                    icon.setExpirationTime(expiration);
                }

                if (this.isHighlighted())
                {
                    this.highlightIconRetrievalTime = System.currentTimeMillis();
                }
                else
                {
                    this.iconRetrievalTime = System.currentTimeMillis();
                }
            }

            return(texture);
        }
Ejemplo n.º 2
0
        /**
         * Indicates whether or not the icon resource has expired.
         *
         * @return True if the icon has expired and must be refreshed.
         */
        protected bool mustRefreshIcon()
        {
            String mode;
            long   retrievalTime;

            if (this.isHighlighted())
            {
                mode          = KMLConstants.HIGHLIGHT;
                retrievalTime = this.highlightIconRetrievalTime;
            }
            else
            {
                mode          = KMLConstants.NORMAL;
                retrievalTime = this.iconRetrievalTime;
            }

            KMLIconStyle iconStyle = (KMLIconStyle)this.parent.getSubStyle(new KMLIconStyle(null), mode);
            KMLIcon      icon      = iconStyle.getIcon();

            return(icon != null && icon.getUpdateTime() > retrievalTime);
        }
Ejemplo n.º 3
0
        protected PointPlacemarkAttributes assemblePointAttributes(PointPlacemarkAttributes attrs, KMLIconStyle style)
        {
            KMLIcon icon = style.getIcon();

            if (icon != null && icon.getHref() != null)
            {
                // The icon reference may be to a support file within a KMZ file, so check for that. If it's not, then just
                // let the normal PointPlacemark code resolve the reference.
                String href         = icon.getHref();
                String localAddress = null;
                try
                {
                    localAddress = this.parent.getRoot().getSupportFilePath(href);
                }
                catch (IOException e)
                {
                    String message = Logging.getMessage("generic.UnableToResolveReference", href);
                    Logging.logger().warning(message);
                }
                attrs.setImageAddress((localAddress != null ? localAddress : href));
            }
            // If the Icon element is present, but there is no href, draw a point instead of the default icon.
            else if (icon != null && WWUtil.isEmpty(icon.getHref()))
            {
                attrs.setUsePointAsDefaultImage(true);
            }

            // Assign the other attributes defined in the KML Feature element.

            if (style.getColor() != null)
            {
                attrs.setImageColor(WWUtil.decodeColorABGR(style.getColor()));
            }

            if (style.getColorMode() != null && "random".Equals(style.getColorMode()))
            {
                attrs.setImageColor(WWUtil.makeRandomColor(attrs.getImageColor()));
            }

            if (style.getScale() != null)
            {
                attrs.setScale(style.getScale());
            }

            if (style.getHeading() != null)
            {
                attrs.setHeading(style.getHeading());
                attrs.setHeadingReference(AVKey.RELATIVE_TO_GLOBE); // KML spec is not clear about this
            }

            if (style.getHotSpot() != null)
            {
                KMLVec2 hs = style.getHotSpot();
                attrs.setImageOffset(new Offset(hs.getX(), hs.getY(), KMLUtil.kmlUnitsToWWUnits(hs.getXunits()),
                                                KMLUtil.kmlUnitsToWWUnits(hs.getYunits())));
            }
            else
            {
                // By default, use the center of the image as the offset.
                attrs.setImageOffset(new Offset(0.5, 0.5, AVKey.FRACTION, AVKey.FRACTION));
            }

            return(attrs);
        }