diff --git a/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/EMPtoWWFeatureConverter.java b/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/EMPtoWWFeatureConverter.java index 7baef2cd..96c2f000 100644 --- a/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/EMPtoWWFeatureConverter.java +++ b/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/EMPtoWWFeatureConverter.java @@ -229,6 +229,7 @@ public gov.nasa.worldwind.shape.Label createWWLabel(Text feature, boolean isSele selectedLabelStyle = getMapInstance().getEmpResources().getSelectedLabelStyle(getMapInstance()); if (null != selectedLabelStyle) { textAttribute.setTextColor(Conversion.convertColor(selectedLabelStyle.getColor())); + textAttribute.setOutlineColor(Conversion.convertColor(selectedLabelStyle.getOutlineColor())); } textAttribute.setEnableOutline(true); textAttribute.setOutlineWidth(TEXT_OUTLINE_WIDTH); @@ -237,6 +238,7 @@ public gov.nasa.worldwind.shape.Label createWWLabel(Text feature, boolean isSele if (null != labelStyle) { if (!isSelected && (null != labelStyle.getColor())) { textAttribute.setTextColor(Conversion.convertColor(labelStyle.getColor())); + textAttribute.setOutlineColor(Conversion.convertColor(labelStyle.getOutlineColor())); } switch (labelStyle.getJustification()) { diff --git a/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/MilStd2525SinglePoint.java b/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/MilStd2525SinglePoint.java index edaad89a..271d9339 100644 --- a/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/MilStd2525SinglePoint.java +++ b/mapengine/worldwind/apk/src/main/java/mil/emp3/worldwind/feature/MilStd2525SinglePoint.java @@ -1,15 +1,12 @@ package mil.emp3.worldwind.feature; -import android.util.Log; import android.util.SparseArray; -import org.cmapi.primitives.IGeoColor; import org.cmapi.primitives.IGeoPosition; import gov.nasa.worldwind.WorldWind; import gov.nasa.worldwind.geom.Position; import gov.nasa.worldwind.render.RenderContext; -import gov.nasa.worldwind.render.Renderable; import gov.nasa.worldwind.shape.Placemark; import mil.emp3.api.MilStdSymbol; import mil.emp3.mapengine.interfaces.IMilStdRenderer; @@ -39,6 +36,7 @@ protected EMPPlacemark(MilStd2525SinglePoint mapper, Position position) { public MilStd2525SinglePoint(MapInstance mapInstance, IMilStdRenderer iconRenderer, Position position, MilStdSymbol symbol) { super(symbol, mapInstance); + this.placemark = new EMPPlacemark(this, position); this.sSymbolCode = symbol.getSymbolCode(); this.oRenderer = iconRenderer; @@ -157,46 +155,7 @@ public double getIconScale() { @Override public void setSelected(boolean selected) { super.setSelected(selected); + setSymbolAttributes(); setSymbolModifiers(); } - - /** - * Sets icon color of underlying symbol and causes a re-render. - * @param iconColor {@link IGeoColor} color to render icon in. - */ - public void setIconColor(final IGeoColor iconColor) { - this.oFeature.setIconColor(iconColor); - this.setDirty(true); - } - - /** - * Sets fill color of the underlying symbol and causes a re-render. - * @param fillColor {@link IGeoColor} color to render fill in. - */ - public void setFillColor(final IGeoColor fillColor) { - this.oFeature.setFillColor(fillColor); - this.setDirty(true); - } - - /** - * Sets the line color of the underlying symbol and causes a re-render. - * @param lineColor {@link IGeoColor} color to render line in. - */ - public void setLineColor(final IGeoColor lineColor) { - this.oFeature.setLineColor(lineColor); - this.setDirty(true); - } - - /** - * Convenience method to color fill, line and icon in one call. - * @param fillColor - Color of the fill. - * @param lineColor - Color of the line. - * @param iconColor - Color of the icon. - */ - public void styleSymbol(final IGeoColor fillColor, final IGeoColor lineColor, final IGeoColor iconColor) { - this.setFillColor(fillColor); - this.setLineColor(lineColor); - this.setIconColor(iconColor); - this.setDirty(true); - } } diff --git a/sdk/sdk-api/src/main/java/mil/emp3/api/MilStdSymbol.java b/sdk/sdk-api/src/main/java/mil/emp3/api/MilStdSymbol.java index 47c11ffe..c8ff412a 100644 --- a/sdk/sdk-api/src/main/java/mil/emp3/api/MilStdSymbol.java +++ b/sdk/sdk-api/src/main/java/mil/emp3/api/MilStdSymbol.java @@ -1377,11 +1377,14 @@ public SparseArray getTGModifiers(MilStdLabelSettingEnum eLabelSetting) * @param selected True if the feature is currenlt selected. * @param selectedStrokeColor The stroke color for selected features. * @param selectedTextColor The text color for selected features. + * @param selectedTextBackgroundColor The text color for selected features. * @return SparseArray of attributes. */ - public SparseArray getAttributes(int iIconSize, boolean selected, IGeoColor selectedStrokeColor, IGeoColor selectedTextColor) { + public SparseArray getAttributes(int iIconSize, boolean selected, IGeoColor selectedStrokeColor, + IGeoColor selectedTextColor, IGeoColor selectedTextBackgroundColor) { IGeoColor strokeColor = null; IGeoColor textColor = null; + IGeoColor textBackgroundColor = null; SparseArray oArray = new SparseArray<>(); IGeoFillStyle oFillStyle = getFillStyle(); IGeoStrokeStyle oStrokeStyle = getStrokeStyle(); @@ -1396,12 +1399,18 @@ public SparseArray getAttributes(int iIconSize, boolean selected, IGeoCo if (selected) { strokeColor = selectedStrokeColor; textColor = selectedTextColor; + textBackgroundColor = selectedTextBackgroundColor; } else { if (oStrokeStyle != null) { strokeColor = oStrokeStyle.getStrokeColor(); } if (labelStyle != null) { textColor = labelStyle.getColor(); + textBackgroundColor = labelStyle.getOutlineColor(); + } else { + // set EMP default colors which are different from renderer default colors + textColor = EmpGeoColor.BLACK; + textBackgroundColor = EmpGeoColor.WHITE; } } @@ -1420,7 +1429,10 @@ public SparseArray getAttributes(int iIconSize, boolean selected, IGeoCo if (textColor != null) { oArray.put(MilStdAttributes.TextColor, "#" + ColorUtils.colorToString(textColor)); - // There is currently no way to change the font. + } + + if (textBackgroundColor != null) { + oArray.put(MilStdAttributes.TextBackgroundColor, "#" + ColorUtils.colorToString(textBackgroundColor)); } if (isSinglePoint()) { @@ -1673,6 +1685,21 @@ public void setLineColor(final IGeoColor color) { this.attributes.put(MilStdAttributes.LineColor, ColorUtils.colorToString(color)); } + /** + * Sets text color of label. + * @param color {@link IGeoColor} Color to render label text in. + */ + public void setTextColor(final IGeoColor color) { + this.attributes.put(MilStdAttributes.TextColor, ColorUtils.colorToString(color)); + } + + /** + * Sets text background color of label. + * @param color {@link IGeoColor} Color to render background text of label in. + */ + public void setTextBackgroundColor(final IGeoColor color) { + this.attributes.put(MilStdAttributes.TextBackgroundColor, ColorUtils.colorToString(color)); + } /** * Convenience method to color fill, line and icon in one call. @@ -1693,5 +1720,4 @@ public void styleSymbol(final IGeoColor fillColor, final IGeoColor lineColor, fi public SparseArray getAttributes() { return this.attributes; } - } diff --git a/sdk/sdk-api/src/main/java/mil/emp3/api/utils/EmpGeoColor.java b/sdk/sdk-api/src/main/java/mil/emp3/api/utils/EmpGeoColor.java index 460ec699..17c27815 100644 --- a/sdk/sdk-api/src/main/java/mil/emp3/api/utils/EmpGeoColor.java +++ b/sdk/sdk-api/src/main/java/mil/emp3/api/utils/EmpGeoColor.java @@ -32,4 +32,8 @@ public EmpGeoColor(int red, int green, int blue) { super.setGreen(green); super.setBlue(blue); } + + final public static EmpGeoColor YELLOW = new EmpGeoColor(1.0, 255, 255, 0); + final public static EmpGeoColor BLACK = new EmpGeoColor(1, 0, 0, 0); + final public static EmpGeoColor WHITE = new EmpGeoColor(1, 255, 255, 255); } diff --git a/sdk/sdk-api/src/main/java/mil/emp3/api/utils/kml/KMLExportThread.java b/sdk/sdk-api/src/main/java/mil/emp3/api/utils/kml/KMLExportThread.java index b41a7718..7f9de8ad 100644 --- a/sdk/sdk-api/src/main/java/mil/emp3/api/utils/kml/KMLExportThread.java +++ b/sdk/sdk-api/src/main/java/mil/emp3/api/utils/kml/KMLExportThread.java @@ -391,7 +391,8 @@ private void exportStylesToKML(final MilStdSymbol feature, final XmlSerializer x final SparseArray saAttr = feature.getAttributes(iconSize, this.map.isSelected(feature), this.map.getSelectedStrokeStyle().getStrokeColor(), - this.map.getSelectedLabelStyle().getColor()); + this.map.getSelectedLabelStyle().getColor(), + this.map.getSelectedLabelStyle().getOutlineColor()); saAttr.put(MilStdAttributes.UseDashArray, "false"); saAttr.delete(MilStdAttributes.FontSize); //.put(MilStdAttributes.FontSize, "13"); // 10 pts * 1/72 inch / pts * 96 pixel / inch @@ -1160,7 +1161,8 @@ public void serializeGeometry(final XmlSerializer xmlSerializer) throws IOExcept final SparseArray modifiers = feature.getTGModifiers(KMLExportThread.this.eLabelSetting); final SparseArray attributes = feature.getAttributes(KMLExportThread.this.map.getIconPixelSize(), KMLExportThread.this.map.isSelected(feature), KMLExportThread.this.map.getSelectedStrokeStyle().getStrokeColor(), - KMLExportThread.this.map.getSelectedLabelStyle().getColor()); + KMLExportThread.this.map.getSelectedLabelStyle().getColor(), + KMLExportThread.this.map.getSelectedLabelStyle().getOutlineColor()); final String altitudeModeStr = MilStdUtilities.geoAltitudeModeToString(feature.getAltitudeMode()); attributes.put(MilStdAttributes.UseDashArray, "false"); diff --git a/sdk/sdk-api/src/main/java/mil/emp3/json/geoJson/GeoJsonExporter.java b/sdk/sdk-api/src/main/java/mil/emp3/json/geoJson/GeoJsonExporter.java index 8cc284b3..c775d657 100644 --- a/sdk/sdk-api/src/main/java/mil/emp3/json/geoJson/GeoJsonExporter.java +++ b/sdk/sdk-api/src/main/java/mil/emp3/json/geoJson/GeoJsonExporter.java @@ -336,7 +336,8 @@ private void appendDataURL(MilStdSymbol feature, StringBuffer buffer) { SparseArray saAttr = feature.getAttributes(iconSize, this.map.isSelected(feature), this.map.getSelectedStrokeStyle().getStrokeColor(), - this.map.getSelectedLabelStyle().getColor()); + this.map.getSelectedLabelStyle().getColor(), + this.map.getSelectedLabelStyle().getOutlineColor()); saAttr.put(MilStdAttributes.UseDashArray, "false"); diff --git a/sdk/sdk-core/aar/src/main/java/mil/emp3/core/storage/MapStatus.java b/sdk/sdk-core/aar/src/main/java/mil/emp3/core/storage/MapStatus.java index 877c4c3e..58bf8306 100644 --- a/sdk/sdk-core/aar/src/main/java/mil/emp3/core/storage/MapStatus.java +++ b/sdk/sdk-core/aar/src/main/java/mil/emp3/core/storage/MapStatus.java @@ -118,10 +118,10 @@ public abstract class MapStatus implements IMapStatus { protected MapStatus() { this.mapServiceHash = new HashMap<>(); this.setIconSize(IconSizeEnum.SMALL); - IGeoColor color = new EmpGeoColor(1.0, 255, 255, 0); - this.selectedStrokeStyle.setStrokeColor(color); + this.selectedStrokeStyle.setStrokeColor(EmpGeoColor.YELLOW); this.selectedStrokeStyle.setStrokeWidth(3.0); - this.selectedLabelStyle.setColor(color); + this.selectedLabelStyle.setColor(EmpGeoColor.YELLOW); + this.selectedLabelStyle.setOutlineColor(EmpGeoColor.BLACK); this.bufferFillStyle.setFillColor(new EmpGeoColor(0.5, 255, 255, 0)); } diff --git a/sdk/sdk-core/aar/src/main/java/mil/emp3/core/utils/MilStdRenderer.java b/sdk/sdk-core/aar/src/main/java/mil/emp3/core/utils/MilStdRenderer.java index cb875d03..5246b325 100644 --- a/sdk/sdk-core/aar/src/main/java/mil/emp3/core/utils/MilStdRenderer.java +++ b/sdk/sdk-core/aar/src/main/java/mil/emp3/core/utils/MilStdRenderer.java @@ -73,19 +73,6 @@ public class MilStdRenderer implements IMilStdRenderer { private boolean initialized; - private static IGeoColor black = new GeoColor(); - private static IGeoColor white = new GeoColor(); - static { - black.setAlpha(1.0); - black.setBlue(0); - black.setGreen(0); - black.setRed(0); - white.setAlpha(1.0); - white.setBlue(255); - white.setGreen(255); - white.setRed(255); - } - private void initCheck() { if (!initialized) { init(); @@ -166,6 +153,7 @@ public SparseArray getAttributes(IMapInstance mapInstance, IFeature feat int iIconSize = storageManager.getIconPixelSize(mapInstance); IGeoColor strokeColor = null; IGeoColor textColor = null; + IGeoColor textBackgroundColor = null; SparseArray oArray = new SparseArray<>(); IGeoFillStyle oFillStyle = feature.getFillStyle(); IGeoStrokeStyle oStrokeStyle = feature.getStrokeStyle(); @@ -182,12 +170,18 @@ public SparseArray getAttributes(IMapInstance mapInstance, IFeature feat if (selected) { strokeColor = storageManager.getSelectedStrokeStyle(mapInstance).getStrokeColor(); textColor = storageManager.getSelectedLabelStyle(mapInstance).getColor(); + textBackgroundColor = storageManager.getSelectedLabelStyle(mapInstance).getOutlineColor(); } else { if (oStrokeStyle != null) { strokeColor = oStrokeStyle.getStrokeColor(); } if (labelStyle != null) { textColor = labelStyle.getColor(); + textBackgroundColor = labelStyle.getOutlineColor(); + } else { + // set EMP default colors which are different from renderer default colors + textColor = EmpGeoColor.BLACK; + textBackgroundColor = EmpGeoColor.WHITE; } } @@ -206,7 +200,10 @@ public SparseArray getAttributes(IMapInstance mapInstance, IFeature feat if (textColor != null) { oArray.put(MilStdAttributes.TextColor, "#" + ColorUtils.colorToString(textColor)); - // There is currently no way to change the font. + } + + if (textBackgroundColor != null) { + oArray.put(MilStdAttributes.TextBackgroundColor, "#" + ColorUtils.colorToString(textBackgroundColor)); } if (isMilStd && !((MilStdSymbol) feature).isSinglePoint()) { @@ -393,7 +390,12 @@ private void renderShapeParser(List featureList, // All modifier text are the same color. armyc2.c2sd.renderer.utilities.Color renderTextColor = renderSymbol.getTextColor(); - IGeoColor textColor = new EmpGeoColor(renderTextColor.getAlpha(), renderTextColor.getRed(), renderTextColor.getGreen(), renderTextColor.getBlue()); + IGeoColor textColor = new EmpGeoColor((double)renderTextColor.getAlpha()/255.0, + renderTextColor.getRed(), renderTextColor.getGreen(), renderTextColor.getBlue()); + armyc2.c2sd.renderer.utilities.Color renderTextBackgroundColor = renderSymbol.getTextBackgroundColor(); + IGeoColor textBackgroundColor = new EmpGeoColor((double)renderTextBackgroundColor.getAlpha()/255.0, + renderTextBackgroundColor.getRed(), renderTextBackgroundColor.getGreen(), + renderTextBackgroundColor.getBlue()); // Process the list of shapes. for(ShapeInfo shapeInfo: modifierShapeInfoList) { @@ -419,9 +421,11 @@ private void renderShapeParser(List featureList, currentTextStyle = new GeoLabelStyle(); if ((null == symbolTextStyle) || (null == symbolTextStyle.getColor())) { currentTextStyle.setColor(textColor); + currentTextStyle.setOutlineColor(textBackgroundColor); currentTextStyle.setSize(FontUtilities.DEFAULT_FONT_POINT_SIZE); } else { currentTextStyle.setColor(symbolTextStyle.getColor()); + currentTextStyle.setOutlineColor(symbolTextStyle.getOutlineColor()); currentTextStyle.setSize(symbolTextStyle.getSize()); } if (selected) {