/** * Determine and set the {@link PointPlacemark} 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, or null if there are no attributes defined. Returns a partially empty attributes * bundle marked unresolved if any of placemark KML styles are unresolved. */ protected PointPlacemarkAttributes makeAttributesCurrent(String attrType) { bool hasLineStyle = false; bool hasIconStyle = false; bool hasLabelStyle = false; PointPlacemarkAttributes attrs = this.getInitialAttributes( this.isHighlighted() ? KMLConstants.HIGHLIGHT : KMLConstants.NORMAL); // Get the KML sub-style for Line attributes. Map them to Shape attributes. KMLAbstractSubStyle subStyle = this.parent.getSubStyle(new KMLLineStyle(null), attrType); if (subStyle.hasFields() && (!this.isHighlighted() || KMLUtil.isHighlightStyleState(subStyle))) { hasLineStyle = true; this.assembleLineAttributes(attrs, (KMLLineStyle)subStyle); if (subStyle.hasField(AVKey.UNRESOLVED)) { attrs.setUnresolved(true); } } subStyle = this.parent.getSubStyle(new KMLIconStyle(null), attrType); if (subStyle.hasFields() && (!this.isHighlighted() || KMLUtil.isHighlightStyleState(subStyle))) { hasIconStyle = true; this.assemblePointAttributes(attrs, (KMLIconStyle)subStyle); if (subStyle.hasField(AVKey.UNRESOLVED)) { attrs.setUnresolved(true); } } subStyle = this.parent.getSubStyle(new KMLLabelStyle(null), attrType); if (subStyle.hasFields() && (!this.isHighlighted() || KMLUtil.isHighlightStyleState(subStyle))) { hasLabelStyle = true; this.assembleLabelAttributes(attrs, (KMLLabelStyle)subStyle); if (subStyle.hasField(AVKey.UNRESOLVED)) { attrs.setUnresolved(true); } } // Return the attributes only if we actually found a KML style. If no style was found, return null instead of an // empty attributes bundle. If a style was found, but could not be resolved, we will return a partially empty // attributes bundle that is marked unresolved. if (hasLineStyle || hasIconStyle || hasLabelStyle) { return(attrs); } else { return(null); } }
/** * Indicate whether a specified sub-style has the "highlight" style-state field. * * @param subStyle the sub-style to test. May be null, in which case this method returns false. * * @return true if the sub-style has the "highlight" field, otherwise false. */ public static bool isHighlightStyleState(KMLAbstractSubStyle subStyle) { if (subStyle == null) { return(false); } String styleState = (String)subStyle.getField(KMLConstants.STYLE_STATE); return(styleState != null && styleState.Equals(KMLConstants.HIGHLIGHT)); }
/** * 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()); if (this.isExtrude()) { attrs.setDrawOutline(((KMLPolyStyle)fillSubStyle).isOutline()); } } return(attrs); }