/** * Create a surface polygon from a KML GroundOverlay. * * @param tc the current {@link KMLTraversalContext}. * @param overlay the {@link gov.nasa.worldwind.ogc.kml.KMLGroundOverlay} to render as a polygon. * @throws NullPointerException if the geometry is null. * @throws IllegalArgumentException 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 IllegalArgumentException(msg); } if (overlay == null) { String msg = Logging.getMessage("nullValue.ParentIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(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); 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); } }
/** * 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 IllegalArgumentException 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 IllegalArgumentException(msg); } if (overlay == null) { String msg = Logging.getMessage("nullValue.ParentIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(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); } }