/** * Convenience method to get the positions defined by either {@code LatLonBox} or {@code gx:LatLonQuad}. If the * overlay includes a {@code LatLonBox} element, this method returns the corners of the sector defined by the {@code * LatLonBox}. Otherwise, if the overlay contains a {@code gx:LatLonQuad}, this method returns the positions defined * by the quad. * * @return A list of the positions that define the corner points of the overlay. */ public Position.PositionList getPositions() { double altitude = this.getAltitude() != null?this.getAltitude() : 0.0; // Positions are specified either as a kml:LatLonBox or a gx:LatLonQuad List <Position> corners = new ArrayList <Position>(4); KMLLatLonBox box = this.getLatLonBox(); if (box != null) { Sector sector = KMLUtil.createSectorFromLatLonBox(box); foreach (LatLon ll in sector.getCorners()) { corners.add(new Position(ll, altitude)); } } else { GXLatLongQuad latLonQuad = this.getLatLonQuad(); if (latLonQuad != null && latLonQuad.getCoordinates() != null) { foreach (Position position in latLonQuad.getCoordinates().list) { corners.add(new Position(position, altitude)); } } } return(new Position.PositionList(corners)); }
/** * 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); }