/** * 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; }
protected ShapeAttributes getInitialAttributes(String attrType) { ShapeAttributes attrs = new BasicShapeAttributes(); if (KMLConstants.HIGHLIGHT.equals(attrType)) { attrs.setOutlineMaterial(Material.RED); attrs.setInteriorMaterial(Material.PINK); } else { attrs.setOutlineMaterial(Material.WHITE); attrs.setInteriorMaterial(Material.LIGHT_GRAY); } return attrs; }
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; } } } } this.preRender(dc); }
/** * 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); } }
/** {@inheritDoc} */ public void copy(ShapeAttributes attributes) { if (attributes != null) { this.drawInterior = attributes.isDrawInterior(); this.drawOutline = attributes.isDrawOutline(); this.enableAntialiasing = attributes.isEnableAntialiasing(); this.enableLighting = attributes.isEnableLighting(); this.interiorMaterial = attributes.getInteriorMaterial(); this.outlineMaterial = attributes.getOutlineMaterial(); this.interiorOpacity = attributes.getInteriorOpacity(); this.outlineOpacity = attributes.getOutlineOpacity(); this.outlineWidth = attributes.getOutlineWidth(); this.outlineStippleFactor = attributes.getOutlineStippleFactor(); this.outlineStipplePattern = attributes.getOutlineStipplePattern(); this.interiorImageSource = attributes.getInteriorImageSource(); this.interiorImageScale = attributes.getInteriorImageScale(); this.updateModifiedTime(); } }
public BasicShapeAttributes(ShapeAttributes attributes) { if (attributes == null) { String message = Logging.getMessage("nullValue.AttributesIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.drawInterior = attributes.isDrawInterior(); this.drawOutline = attributes.isDrawOutline(); this.enableAntialiasing = attributes.isEnableAntialiasing(); this.enableLighting = attributes.isEnableLighting(); this.interiorMaterial = attributes.getInteriorMaterial(); this.outlineMaterial = attributes.getOutlineMaterial(); this.interiorOpacity = attributes.getInteriorOpacity(); this.outlineOpacity = attributes.getOutlineOpacity(); this.outlineWidth = attributes.getOutlineWidth(); this.outlineStippleFactor = attributes.getOutlineStippleFactor(); this.outlineStipplePattern = attributes.getOutlineStipplePattern(); this.interiorImageSource = attributes.getInteriorImageSource(); this.interiorImageScale = attributes.getInteriorImageScale(); this.updateModifiedTime(); }