public static ShapeAttributes assembleInteriorAttributes(ShapeAttributes attrs, KMLPolyStyle style) { // Assign the attributes defined in the KML Feature element. if (style.getColor() != null) { Color color = WWUtil.decodeColorABGR(style.getColor()); attrs.setInteriorMaterial(new Material(color)); attrs.setInteriorOpacity((double)color.getAlpha() / 255); } if (style.getColorMode() != null && "random".Equals(style.getColorMode())) { attrs.setInteriorMaterial(new Material(WWUtil.makeRandomColor(attrs.getOutlineMaterial().getDiffuse()))); } return(attrs); }
protected PointPlacemarkAttributes assembleLabelAttributes(PointPlacemarkAttributes attrs, KMLLabelStyle style) { // Assign the attributes defined in the KML Feature element. if (style.getScale() != null) { attrs.setLabelScale(style.getScale()); } if (style.getColor() != null) { attrs.setLabelColor(style.getColor()); } if (style.getColorMode() != null && "random".Equals(style.getColorMode())) { attrs.setLabelMaterial(new Material(WWUtil.makeRandomColor(attrs.getLabelColor()))); } return(attrs); }
public static ShapeAttributes assembleLineAttributes(ShapeAttributes attrs, KMLLineStyle style) { // Assign the attributes defined in the KML Feature element. if (style.getWidth() != null) { attrs.setOutlineWidth(style.getWidth()); } if (style.getColor() != null) { attrs.setOutlineMaterial(new Material(WWUtil.decodeColorABGR(style.getColor()))); } if (style.getColorMode() != null && "random".Equals(style.getColorMode())) { attrs.setOutlineMaterial(new Material(WWUtil.makeRandomColor(attrs.getOutlineMaterial().getDiffuse()))); } return(attrs); }
protected PointPlacemarkAttributes assemblePointAttributes(PointPlacemarkAttributes attrs, KMLIconStyle style) { KMLIcon icon = style.getIcon(); if (icon != null && icon.getHref() != null) { // The icon reference may be to a support file within a KMZ file, so check for that. If it's not, then just // let the normal PointPlacemark code resolve the reference. String href = icon.getHref(); String localAddress = null; try { localAddress = this.parent.getRoot().getSupportFilePath(href); } catch (IOException e) { String message = Logging.getMessage("generic.UnableToResolveReference", href); Logging.logger().warning(message); } attrs.setImageAddress((localAddress != null ? localAddress : href)); } // If the Icon element is present, but there is no href, draw a point instead of the default icon. else if (icon != null && WWUtil.isEmpty(icon.getHref())) { attrs.setUsePointAsDefaultImage(true); } // Assign the other attributes defined in the KML Feature element. if (style.getColor() != null) { attrs.setImageColor(WWUtil.decodeColorABGR(style.getColor())); } if (style.getColorMode() != null && "random".Equals(style.getColorMode())) { attrs.setImageColor(WWUtil.makeRandomColor(attrs.getImageColor())); } if (style.getScale() != null) { attrs.setScale(style.getScale()); } if (style.getHeading() != null) { attrs.setHeading(style.getHeading()); attrs.setHeadingReference(AVKey.RELATIVE_TO_GLOBE); // KML spec is not clear about this } if (style.getHotSpot() != null) { KMLVec2 hs = style.getHotSpot(); attrs.setImageOffset(new Offset(hs.getX(), hs.getY(), KMLUtil.kmlUnitsToWWUnits(hs.getXunits()), KMLUtil.kmlUnitsToWWUnits(hs.getYunits()))); } else { // By default, use the center of the image as the offset. attrs.setImageOffset(new Offset(0.5, 0.5, AVKey.FRACTION, AVKey.FRACTION)); } return(attrs); }