Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
32 changes: 29 additions & 3 deletions sdk/sdk-api/src/main/java/mil/emp3/api/MilStdSymbol.java
Original file line number Diff line number Diff line change
Expand Up @@ -1377,11 +1377,14 @@ public SparseArray<String> 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<String> getAttributes(int iIconSize, boolean selected, IGeoColor selectedStrokeColor, IGeoColor selectedTextColor) {
public SparseArray<String> getAttributes(int iIconSize, boolean selected, IGeoColor selectedStrokeColor,
IGeoColor selectedTextColor, IGeoColor selectedTextBackgroundColor) {
IGeoColor strokeColor = null;
IGeoColor textColor = null;
IGeoColor textBackgroundColor = null;
SparseArray<String> oArray = new SparseArray<>();
IGeoFillStyle oFillStyle = getFillStyle();
IGeoStrokeStyle oStrokeStyle = getStrokeStyle();
Expand All @@ -1396,12 +1399,18 @@ public SparseArray<String> 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;
}
}

Expand All @@ -1420,7 +1429,10 @@ public SparseArray<String> 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()) {
Expand Down Expand Up @@ -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.
Expand All @@ -1693,5 +1720,4 @@ public void styleSymbol(final IGeoColor fillColor, final IGeoColor lineColor, fi
public SparseArray<String> getAttributes() {
return this.attributes;
}

}
4 changes: 4 additions & 0 deletions sdk/sdk-api/src/main/java/mil/emp3/api/utils/EmpGeoColor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ private void exportStylesToKML(final MilStdSymbol feature, final XmlSerializer x
final SparseArray<String> 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
Expand Down Expand Up @@ -1160,7 +1161,8 @@ public void serializeGeometry(final XmlSerializer xmlSerializer) throws IOExcept
final SparseArray<String> modifiers = feature.getTGModifiers(KMLExportThread.this.eLabelSetting);
final SparseArray<String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ private void appendDataURL(MilStdSymbol feature, StringBuffer buffer) {
SparseArray<String> 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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -166,6 +153,7 @@ public SparseArray<String> getAttributes(IMapInstance mapInstance, IFeature feat
int iIconSize = storageManager.getIconPixelSize(mapInstance);
IGeoColor strokeColor = null;
IGeoColor textColor = null;
IGeoColor textBackgroundColor = null;
SparseArray<String> oArray = new SparseArray<>();
IGeoFillStyle oFillStyle = feature.getFillStyle();
IGeoStrokeStyle oStrokeStyle = feature.getStrokeStyle();
Expand All @@ -182,12 +170,18 @@ public SparseArray<String> 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;
}
}

Expand All @@ -206,7 +200,10 @@ public SparseArray<String> 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()) {
Expand Down Expand Up @@ -393,7 +390,12 @@ private void renderShapeParser(List<IFeature> 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) {
Expand All @@ -419,9 +421,11 @@ private void renderShapeParser(List<IFeature> 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) {
Expand Down