Пример #1
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);
        }
        /**
         * Apply a rotation to the corner points of the overlay. This method is called the first time the polygon is
         * rendered, if the position is specified using a rotated LatLon box.
         *
         * @param dc Current draw context.
         */
        protected void applyRotation(DrawContext dc)
        {
            // Rotation applies only to ground overlay position with a LatLon box.
            if (!(this.parent is KMLGroundOverlay))
            {
                return;
            }

            KMLLatLonBox box = ((KMLGroundOverlay)this.parent).getLatLonBox();

            if (box != null)
            {
                Double rotation = box.getRotation();
                if (rotation != null)
                {
                    Sector sector = KMLUtil.createSectorFromLatLonBox(box);
                    java.util.List <LatLon> corners = KMLUtil.rotateSector(dc.getGlobe(), sector,
                                                                           Angle.fromDegrees(rotation));
                    this.setOuterBoundary(corners);
                }
            }
        }