/** * Determine and set the {@link Path} highlight attributes from the KML <i>Feature</i> fields. * * @param attrType the type of attributes, either {@link KMLConstants#NORMAL} or {@link * KMLConstants#HIGHLIGHT}. * @return the new attributes. */ protected ShapeAttributes makeAttributesCurrent(String attrType) { ShapeAttributes attrs = this.getInitialAttributes( this.isHighlighted() ? KMLConstants.HIGHLIGHT : KMLConstants.NORMAL); // Get the KML sub-style for Line attributes. Map them to Shape attributes. KMLAbstractSubStyle lineSubStyle = this.parent.getSubStyle(new KMLLineStyle(null), attrType); if (!this.isHighlighted() || KMLUtil.isHighlightStyleState(lineSubStyle)) { KMLUtil.assembleLineAttributes(attrs, (KMLLineStyle) lineSubStyle); if (lineSubStyle.hasField(AVKey.UNRESOLVED)) attrs.setUnresolved(true); } // Get the KML sub-style for interior attributes. Map them to Shape attributes. KMLAbstractSubStyle fillSubStyle = this.parent.getSubStyle(new KMLPolyStyle(null), attrType); if (!this.isHighlighted() || KMLUtil.isHighlightStyleState(lineSubStyle)) { KMLUtil.assembleInteriorAttributes(attrs, (KMLPolyStyle) fillSubStyle); if (fillSubStyle.hasField(AVKey.UNRESOLVED)) attrs.setUnresolved(true); } attrs.setDrawInterior(((KMLPolyStyle) fillSubStyle).isFill()); attrs.setDrawOutline(((KMLPolyStyle) fillSubStyle).isOutline()); return attrs; }
/** * 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); } }