예제 #1
0
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>Point</i>.
         * @param geom      the {@link SharpEarth.ogc.kml.KMLPoint} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLModelPlacemarkImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (placemark == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (geom == null)
            {
                String msg = Logging.getMessage("nullValue.GeometryIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.model  = (KMLModel)geom;
            this.parent = placemark;

            this.resourceMap = this.createResourceMap(this.model);
        }
        /**
         * Create a surface polygon from a KML GroundOverlay.
         *
         * @param tc      the current {@link KMLTraversalContext}.
         * @param overlay the {@link SharpEarth.ogc.kml.KMLGroundOverlay} to render as a polygon.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLSurfacePolygonImpl(KMLTraversalContext tc, KMLGroundOverlay overlay)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (overlay == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.parent = overlay;

            // Positions are specified either as a kml:LatLonBox or a gx:LatLonQuad
            Position.PositionList corners = overlay.getPositions();
            this.setOuterBoundary(corners.list);

            // Check to see if a rotation is provided. The rotation will be applied when the image is rendered, because
            // how the rotation is performed depends on the globe.
            KMLLatLonBox box = overlay.getLatLonBox();

            if (box != null && box.getRotation() != null)
            {
                this.mustApplyRotation = true;
            }

            if (overlay.getName() != null)
            {
                this.setValue(AVKey.DISPLAY_NAME, overlay.getName());
            }

            if (overlay.getDescription() != null)
            {
                this.setValue(AVKey.BALLOON_TEXT, overlay.getDescription());
            }

            if (overlay.getSnippetText() != null)
            {
                this.setValue(AVKey.SHORT_DESCRIPTION, overlay.getSnippetText());
            }

            String colorStr = overlay.getColor();

            if (!WWUtil.isEmpty(colorStr))
            {
                Color color = WWUtil.decodeColorABGR(colorStr);

                ShapeAttributes attributes = new BasicShapeAttributes();
                attributes.setDrawInterior(true);
                attributes.setInteriorMaterial(new Material(color));
                this.setAttributes(attributes);
            }
        }
예제 #3
0
        public void render(KMLTraversalContext tc, DrawContext dc)
        {
            // If the attributes are not inline or internal then they might not be resolved until the external KML
            // document is resolved. Therefore check to see if resolution has occurred.

            if (this.isHighlighted())
            {
                if (!this.highlightAttributesResolved)
                {
                    PointPlacemarkAttributes a = this.getHighlightAttributes();
                    if (a == null || a.isUnresolved())
                    {
                        a = this.makeAttributesCurrent(KMLConstants.HIGHLIGHT);
                        if (a != null)
                        {
                            this.setHighlightAttributes(a);
                            if (!a.isUnresolved())
                            {
                                this.highlightAttributesResolved = true;
                            }
                        }
                        else
                        {
                            // There are no highlight attributes, so we can stop looking for them. Note that this is
                            // different from having unresolved highlight attributes (handled above).
                            this.highlightAttributesResolved = true;
                        }
                    }
                }
            }
            else
            {
                if (!this.normalAttributesResolved)
                {
                    PointPlacemarkAttributes a = this.getAttributes();
                    if (a == null || a.isUnresolved())
                    {
                        a = this.makeAttributesCurrent(KMLConstants.NORMAL);
                        if (a != null)
                        {
                            this.setAttributes(a);
                            if (!a.isUnresolved())
                            {
                                this.normalAttributesResolved = true;
                            }
                        }
                        else
                        {
                            // There are no normal attributes, so we can stop looking for them.  Note that this is different
                            // from having unresolved attributes (handled above).
                            this.normalAttributesResolved = true;
                        }
                    }
                }
            }

            this.render(dc);
        }
예제 #4
0
        /**
         * Create an screen image.
         *
         * @param tc      the current {@link KMLTraversalContext}.
         * @param overlay the <i>Overlay</i> element containing.
         *
         * @throws NullPointerException     if the traversal context is null.
         * @throws ArgumentException if the parent overlay or the traversal context is null.
         */
        public KMLSurfaceImageImpl(KMLTraversalContext tc, KMLGroundOverlay overlay)
        {
            this.parent = overlay;

            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (overlay == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            // Positions are specified either as a kml:LatLonBox or a gx:LatLonQuad
            KMLLatLonBox box = overlay.getLatLonBox();

            if (box != null)
            {
                Sector sector = KMLUtil.createSectorFromLatLonBox(box);
                this.initializeGeometry(sector);

                // Check to see if a rotation is provided. The rotation will be applied when the image is rendered, because
                // how the rotation is performed depends on the globe.
                Double rotation = box.getRotation();
                if (rotation != null)
                {
                    this.mustApplyRotation = true;
                }
            }
            else
            {
                GXLatLongQuad latLonQuad = overlay.getLatLonQuad();
                if (latLonQuad != null && latLonQuad.getCoordinates() != null)
                {
                    this.initializeGeometry(latLonQuad.getCoordinates().list);
                }
            }

            // Apply opacity to the surface image
            String colorStr = overlay.getColor();

            if (!WWUtil.isEmpty(colorStr))
            {
                Color color = WWUtil.decodeColorABGR(colorStr);
                int   alpha = color.getAlpha();

                this.setOpacity((double)alpha / 255);
            }

            this.setPickEnabled(false);
        }
예제 #5
0
        /** {@inheritDoc} */
        public void render(KMLTraversalContext tc, DrawContext dc)
        {
            ColladaRoot root = this.getColladaRoot();

            if (root != null)
            {
                this.colladaTraversalContext.initialize();
                root.render(this.colladaTraversalContext, dc);
            }
        }
        public void preRender(KMLTraversalContext tc, DrawContext dc)
        {
            // If the attributes are not inline or internal then they might not be resolved until the external KML
            // document is resolved. Therefore check to see if resolution has occurred.

            if (this.isHighlighted())
            {
                if (!this.highlightAttributesResolved)
                {
                    ShapeAttributes a = this.getHighlightAttributes();
                    if (a == null || a.isUnresolved())
                    {
                        a = this.makeAttributesCurrent(KMLConstants.HIGHLIGHT);
                        if (a != null)
                        {
                            this.setHighlightAttributes(a);
                            if (!a.isUnresolved())
                            {
                                this.highlightAttributesResolved = true;
                            }
                        }
                    }
                }
            }
            else
            {
                if (!this.normalAttributesResolved)
                {
                    ShapeAttributes a = this.getAttributes();
                    if (a == null || a.isUnresolved())
                    {
                        a = this.makeAttributesCurrent(KMLConstants.NORMAL);
                        if (a != null)
                        {
                            this.setAttributes(a);
                            if (!a.isUnresolved())
                            {
                                this.normalAttributesResolved = true;
                            }
                        }
                    }
                }
            }

            // Apply rotation the first time the polygon is rendered. This feature only applies to ground overlays with
            // position specified using a rotated LatLon box.
            if (this.mustApplyRotation)
            {
                this.applyRotation(dc);
                this.mustApplyRotation = false;
            }

            this.preRender(dc);
        }
예제 #7
0
        /** {@inheritDoc} */
        public void render(KMLTraversalContext tc, DrawContext dc)
        {
            if (this.mustResolveHref()) // resolve the href to either a local file or a remote URL
            {
                String path = this.resolveHref();

                // Evict the resource from the file store if there is a cached resource older than the icon update time.
                // This prevents fetching a stale resource out of the cache when the Icon is updated.
                this.parent.getRoot().evictIfExpired(path, this.iconRetrievalTime);

                this.setImageSource(path);
            }

            this.render(dc);
        }
예제 #8
0
        /** {@inheritDoc} */
        public void preRender(KMLTraversalContext tc, DrawContext dc)
        {
            if (this.mustRetrieveResource())
            {
                this.requestResource(dc);
            }

            ColladaRoot root = this.getColladaRoot();

            if (root != null)
            {
                this.colladaTraversalContext.initialize();
                root.preRender(this.colladaTraversalContext, dc);
            }
        }
예제 #9
0
        public void render(KMLTraversalContext tc, DrawContext dc)
        {
            // If the attributes are not inline or internal then they might not be resolved until the external KML
            // document is resolved. Therefore check to see if resolution has occurred.

            if (this.isHighlighted())
            {
                if (!this.highlightAttributesResolved)
                {
                    ShapeAttributes a = this.getCapHighlightAttributes();
                    if (a == null || a.isUnresolved())
                    {
                        a = this.makeAttributesCurrent(KMLConstants.HIGHLIGHT);
                        if (a != null)
                        {
                            this.setCapHighlightAttributes(a);
                            this.setSideHighlightAttributes(a);
                            if (!a.isUnresolved())
                            {
                                this.highlightAttributesResolved = true;
                            }
                        }
                    }
                }
            }
            else
            {
                if (!this.normalAttributesResolved)
                {
                    ShapeAttributes a = this.getCapAttributes();
                    if (a == null || a.isUnresolved())
                    {
                        a = this.makeAttributesCurrent(KMLConstants.NORMAL);
                        if (a != null)
                        {
                            this.setCapAttributes(a);
                            this.setSideAttributes(a);
                            if (!a.isUnresolved())
                            {
                                this.normalAttributesResolved = true;
                            }
                        }
                    }
                }
            }

            this.render(dc);
        }
예제 #10
0
        public void preRender(KMLTraversalContext tc, DrawContext dc)
        {
            if (this.mustResolveHref()) // resolve the href to either a local file or a remote URL
            {
                String path = this.resolveHref();

                // Evict the resource from the file store if there is a cached resource older than the icon update time.
                // This prevents fetching a stale resource out of the cache when the Icon is updated.
                this.parent.getRoot().evictIfExpired(path, this.iconRetrievalTime);

                this.setImageSource(path, this.getCorners());
                this.iconRetrievalTime = System.currentTimeMillis();
                this.textureResolved   = false;
            }

            // Set the Icon's expiration time the first time that the image is rendered after the texture has been retrieved.
            // The expiration time comes from the HTTP headers, so we can't do this until the resource is available.
            bool mustSetExpiration = !this.textureResolved && this.sourceTexture != null &&
                                     this.sourceTexture.isTextureCurrent(dc);

            if (mustSetExpiration)
            {
                String path = this.resolveHref();

                // Query the KMLRoot for the expiration time.
                long expiration = this.parent.getRoot().getExpiration(path);

                // Set the Icon's expiration. This has no effect if the refreshMode is not onExpire.
                this.parent.getIcon().setExpirationTime(expiration);
                this.textureResolved = true;
            }

            // Apply rotation the first time the overlay is rendered
            if (this.mustApplyRotation)
            {
                this.applyRotation(dc);
                this.mustApplyRotation = false;
            }

            super.preRender(dc);
        }
        /** {@inheritDoc} */
        public void render(KMLTraversalContext tc, DrawContext dc)
        {
            if (this.mustResolveHref()) // resolve the href to either a local file or a remote URL
            {
                // 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 Polygon code resolve the reference.
                String href         = this.parent.getIcon().getHref();
                String localAddress = null;
                try
                {
                    localAddress = this.parent.getRoot().getSupportFilePath(href);
                }
                catch (IOException ignored)
                {
                }

                float[] texCoords = new float[] { 0, 0, 1, 0, 1, 1, 0, 1 };
                this.setTextureImageSource((localAddress != null ? localAddress : href), texCoords, 4);
            }

            this.render(dc);
        }
예제 #12
0
        /**
         * Create an screen image.
         *
         * @param tc      the current {@link KMLTraversalContext}.
         * @param overlay the <i>Overlay</i> element containing.
         *
         * @throws NullPointerException     if the traversal context is null.
         * @throws ArgumentException if the parent overlay or the traversal context is null.
         */
        public KMLScreenImageImpl(KMLTraversalContext tc, KMLScreenOverlay overlay)
        {
            this.parent = overlay;

            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (overlay == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            KMLVec2 xy = this.parent.getScreenXY();

            if (xy != null)
            {
                this.screenOffset = new Offset(xy.getX(), xy.getY(), KMLUtil.kmlUnitsToWWUnits(xy.getXunits()),
                                               KMLUtil.kmlUnitsToWWUnits(xy.getYunits()));
            }

            xy = this.parent.getOverlayXY();
            if (xy != null)
            {
                this.imageOffset = new Offset(xy.getX(), xy.getY(), KMLUtil.kmlUnitsToWWUnits(xy.getXunits()),
                                              KMLUtil.kmlUnitsToWWUnits(xy.getYunits()));
            }

            this.setRotation(overlay.getRotation());

            xy = this.parent.getRotationXY();
            if (xy != null)
            {
                setRotationOffset(new Offset(xy.getX(), xy.getY(), KMLUtil.kmlUnitsToWWUnits(xy.getXunits()),
                                             KMLUtil.kmlUnitsToWWUnits(xy.getYunits())));
            }

            String colorStr = overlay.getColor();

            if (colorStr != null)
            {
                Color color = WWUtil.decodeColorABGR(colorStr);
                this.setColor(color);
            }

            // Compute desired image size, and the scale factor that will make it that size
            KMLVec2 kmlSize = this.parent.getSize();

            if (kmlSize != null)
            {
                Size size = new Size();
                size.setWidth(getSizeMode(kmlSize.getX()), kmlSize.getX(), KMLUtil.kmlUnitsToWWUnits(kmlSize.getXunits()));
                size.setHeight(getSizeMode(kmlSize.getY()), kmlSize.getY(), KMLUtil.kmlUnitsToWWUnits(kmlSize.getYunits()));
                this.setSize(size);
            }
        }
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>LineString</i>.
         * @param geom      the {@link SharpEarth.ogc.kml.KMLPolygon} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLSurfacePolygonImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (placemark == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.parent = placemark;

            KMLPolygon polygon = (KMLPolygon)geom;

            // KMLPolygon's use linear interpolation between corners by definition. Configure the World Wind SurfacePolygon
            // to use the appropriate path type for linear interpolation in geographic coordinates.
            this.setPathType(AVKey.LINEAR);

            // Note: SurfacePolygon implies altitude mode "clampToGround", therefore KMLSurfacePolygonImpl ignores the
            // KMLPolygon's altitude mode property.

            KMLLinearRing outerBoundary = polygon.getOuterBoundary();

            if (outerBoundary != null)
            {
                Position.PositionList coords = outerBoundary.getCoordinates();
                if (coords != null && coords.list != null)
                {
                    this.setOuterBoundary(outerBoundary.getCoordinates().list);
                }
            }

            Iterable <? extends KMLLinearRing> innerBoundaries = polygon.getInnerBoundaries();

            if (innerBoundaries != null)
            {
                foreach (KMLLinearRing ring in innerBoundaries)
                {
                    Position.PositionList coords = ring.getCoordinates();
                    if (coords != null && coords.list != null)
                    {
                        this.addInnerBoundary(ring.getCoordinates().list);
                    }
                }
            }

            if (placemark.getName() != null)
            {
                this.setValue(AVKey.DISPLAY_NAME, placemark.getName());
            }

            if (placemark.getDescription() != null)
            {
                this.setValue(AVKey.DESCRIPTION, placemark.getDescription());
            }

            if (placemark.getSnippetText() != null)
            {
                this.setValue(AVKey.SHORT_DESCRIPTION, placemark.getSnippetText());
            }

            this.setValue(AVKey.CONTEXT, this.parent);
        }
 public void render(KMLTraversalContext tc, DrawContext dc)
 {
     // We've already resolved the SurfacePolygon's attributes during the preRender pass. During the render pass we
     // simply draw the SurfacePolygon.
     this.render(dc);
 }
예제 #15
0
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>LineString</i>.
         * @param geom      the {@link SharpEarth.ogc.kml.KMLPolygon} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLPolygonImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (placemark == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.parent = placemark;

            KMLPolygon polygon = (KMLPolygon)geom;

            this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); // KML default

            String altMode = polygon.getAltitudeMode();

            if (!WWUtil.isEmpty(altMode))
            {
                if ("relativeToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
                }
                else if ("absolute".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.ABSOLUTE);
                }
            }

            KMLLinearRing outerBoundary = polygon.getOuterBoundary();

            if (outerBoundary != null)
            {
                Position.PositionList coords = outerBoundary.getCoordinates();
                if (coords != null && coords.list != null)
                {
                    this.setOuterBoundary(outerBoundary.getCoordinates().list);
                }
            }

            Iterable <? extends KMLLinearRing> innerBoundaries = polygon.getInnerBoundaries();

            if (innerBoundaries != null)
            {
                foreach (KMLLinearRing ring in innerBoundaries)
                {
                    Position.PositionList coords = ring.getCoordinates();
                    if (coords != null && coords.list != null)
                    {
                        this.addInnerBoundary(ring.getCoordinates().list);
                    }
                }
            }

            if (placemark.getName() != null)
            {
                this.setValue(AVKey.DISPLAY_NAME, placemark.getName());
            }

            if (placemark.getDescription() != null)
            {
                this.setValue(AVKey.DESCRIPTION, placemark.getDescription());
            }

            if (placemark.getSnippetText() != null)
            {
                this.setValue(AVKey.SHORT_DESCRIPTION, placemark.getSnippetText());
            }

            this.setValue(AVKey.CONTEXT, this.parent);
        }
예제 #16
0
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>Point</i>.
         * @param geom      the {@link KMLPoint} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLPointPlacemarkImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            super(((KMLPoint)geom).getCoordinates());

            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (placemark == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.parent = placemark;

            KMLPoint point = (KMLPoint)geom;

            this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); // KML default

            if (point.isExtrude())
            {
                this.setLineEnabled(true);
            }

            String altMode = point.getAltitudeMode();

            if (!WWUtil.isEmpty(altMode))
            {
                if ("clampToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
                }
                else if ("relativeToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
                }
                else if ("absolute".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.ABSOLUTE);
                }
            }

            if (this.parent.getVisibility() != null)
            {
                this.setVisible(this.parent.getVisibility());
            }

            if (placemark.getName() != null)
            {
                this.setLabelText(placemark.getName());
                this.setValue(AVKey.DISPLAY_NAME, placemark.getName());
            }

            String description = placemark.getDescription();

            if (description != null)
            {
                this.setValue(AVKey.DESCRIPTION, description);
            }

            if (placemark.getSnippetText() != null)
            {
                this.setValue(AVKey.SHORT_DESCRIPTION, placemark.getSnippetText());
            }

            this.setValue(AVKey.CONTEXT, this.parent);
        }
예제 #17
0
 /** {@inheritDoc} */
 public void preRender(KMLTraversalContext tc, DrawContext dc)
 {
     // No pre-rendering
 }
 /** {@inheritDoc} */
 public void preRender(KMLTraversalContext tc, DrawContext dc)
 {
     // Intentionally left blank; KML polygon does nothing during the preRender phase.
 }
예제 #19
0
 public void preRender(KMLTraversalContext tc, DrawContext dc)
 {
     super.preRender(dc);
 }
        /**
         * Create an instance.
         *
         * @param tc      the current {@link KMLTraversalContext}.
         * @param overlay the {@link SharpEarth.ogc.kml.KMLGroundOverlay} to render as a polygon.
         *
         * @throws NullPointerException     if the geomtry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLGroundOverlayPolygonImpl(KMLTraversalContext tc, KMLGroundOverlay overlay)
        {
            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (overlay == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.parent = overlay;

            String altMode = overlay.getAltitudeMode();

            if (!WWUtil.isEmpty(altMode))
            {
                if ("relativeToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
                }
                else if ("absolute".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.ABSOLUTE);
                }
            }

            // Positions are specified either as a kml:LatLonBox or a gx:LatLonQuad
            Position.PositionList corners = overlay.getPositions();
            this.setOuterBoundary(corners.list);

            // Apply rotation if the overlay includes a LatLonBox
            KMLLatLonBox box = overlay.getLatLonBox();

            if (box != null)
            {
                this.setRotation(box.getRotation());
            }

            if (overlay.getName() != null)
            {
                this.setValue(AVKey.DISPLAY_NAME, overlay.getName());
            }

            if (overlay.getDescription() != null)
            {
                this.setValue(AVKey.BALLOON_TEXT, overlay.getDescription());
            }

            if (overlay.getSnippetText() != null)
            {
                this.setValue(AVKey.SHORT_DESCRIPTION, overlay.getSnippetText());
            }

            // If no image is specified, draw a filled rectangle
            if (this.parent.getIcon() == null || this.parent.getIcon().getHref() == null)
            {
                String colorStr = overlay.getColor();
                if (!WWUtil.isEmpty(colorStr))
                {
                    Color color = WWUtil.decodeColorABGR(colorStr);

                    ShapeAttributes attributes = new BasicShapeAttributes();
                    attributes.setDrawInterior(true);
                    attributes.setInteriorMaterial(new Material(color));
                    this.setAttributes(attributes);
                }
            }
        }
예제 #21
0
        /**
         * Create an instance.
         *
         * @param tc        the current {@link KMLTraversalContext}.
         * @param placemark the <i>Placemark</i> element containing the <i>LineString</i>.
         * @param geom      the {@link KMLLineString} geometry.
         *
         * @throws NullPointerException     if the geometry is null.
         * @throws ArgumentException if the parent placemark or the traversal context is null.
         */
        public KMLLineStringPlacemarkImpl(KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom)
        {
            super(((KMLLineString)geom).getCoordinates());

            if (tc == null)
            {
                String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (placemark == null)
            {
                String msg = Logging.getMessage("nullValue.ParentIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.parent = placemark;

            KMLLineString lineString = (KMLLineString)geom;

            if (lineString.isExtrude())
            {
                this.setExtrude(true);
            }

            if (lineString.getTessellate() != null && lineString.getTessellate())
            {
                this.setFollowTerrain(true);
            }

            this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); // KML default
            String altMode = lineString.getAltitudeMode();

            if (!WWUtil.isEmpty(altMode))
            {
                if ("clampToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
                }
                else if ("relativeToGround".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
                }
                else if ("absolute".Equals(altMode))
                {
                    this.setAltitudeMode(WorldWind.ABSOLUTE);
                }
            }

            // If the path is clamped to the ground and terrain conforming, draw as a great circle. Otherwise draw
            // as linear segments.
            if (this.getAltitudeMode() == WorldWind.CLAMP_TO_GROUND && this.isFollowTerrain())
            {
                this.setPathType(AVKey.GREAT_CIRCLE);
            }
            else
            {
                this.setPathType(AVKey.LINEAR);
            }

            if (placemark.getName() != null)
            {
                this.setValue(AVKey.DISPLAY_NAME, placemark.getName());
            }

            if (placemark.getDescription() != null)
            {
                this.setValue(AVKey.DESCRIPTION, placemark.getDescription());
            }

            if (placemark.getSnippetText() != null)
            {
                this.setValue(AVKey.SHORT_DESCRIPTION, placemark.getSnippetText());
            }

            this.setValue(AVKey.CONTEXT, this.parent);
        }