Java Code Examples for org.gwtopenmaps.openlayers.client.util.JSObject#getPropertyAsString()

The following examples show how to use org.gwtopenmaps.openlayers.client.util.JSObject#getPropertyAsString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VectorFeatureStyleDef.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private void getColorStyleData(Style style) {
	if(style != null) {
		JSObject jsStyle = style.getJSObject();
		String fillColor = jsStyle.getPropertyAsString("userFillColor");			
		String strokeColor = jsStyle.getPropertyAsString("userStrokeColor");
		int thickness = (int) Math.floor(style.getStrokeWidth());
					
		/**
		 * Si estamos en modo de estilo por feature, hay que coger el color 
		 * de referencia de las propiedades userFillColor y userStrokeColor, 
		 * puesto que los features afectados están seleccionados y por tanto
		 * tienen asignado el color de relleno y linea del modo selección 
		 */
		getFill().setNormalColor(fillColor != null ? fillColor : style.getFillColor());
		getFill().setOpacity(style.getFillOpacity());
		getLine().setNormalColor(strokeColor != null ? strokeColor : style.getStrokeColor());
		getLine().setThickness(thickness);	
	}
}
 
Example 2
Source File: VectorFeatureStyleDef.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private void getLabelStyleData(Style style, VectorLayer layer) {
	if(style != null) {
		JSObject jsStyle = style.getJSObject();
		
		boolean enabled = jsStyle.getPropertyAsString("userAttributeLabel") != null 
				&& !jsStyle.getPropertyAsString("userAttributeLabel").isEmpty();			
				
		if(enabled) {
			getLabel().setAttribute(layer.getAttribute(
					jsStyle.getPropertyAsString("userAttributeLabel")));
										
			getLabel().setFontSize(getFontSize(jsStyle));
			getLabel().setBoldStyle(isBoldFont(jsStyle));
			getLabel().setBackgroundColor(jsStyle.getPropertyAsString("labelOutlineColor"));
		} 
	} 
}
 
Example 3
Source File: VectorFeatureStyleDef.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private Integer getFontSize(JSObject style) {		
	String fontSize = style.getPropertyAsString("fontSize");
	
	if(fontSize != null && !fontSize.isEmpty()) {
		fontSize = fontSize.substring(0, fontSize.lastIndexOf("px"));
		return Integer.parseInt(fontSize);					
	}
	return LabelStyle.DEFAULT_FONT_SIZE;
}
 
Example 4
Source File: VectorFeatureStyleDef.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private boolean isBoldFont(JSObject style) {
	String fontWeight = style.getPropertyAsString("fontWeight");
	
	if(fontWeight == null || fontWeight.isEmpty()) {
		fontWeight = "regular";
	}
	return fontWeight.equalsIgnoreCase("bold");
}
 
Example 5
Source File: GeoJSONCSS.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
public VectorFeatureStyleDef getStyleDef(JSObject styleObject) {
	VectorFeatureStyleDef def = new VectorFeatureStyleDef();

	if (styleObject.hasProperty(LeafletStyle.FILL_COLOR_NAME)) {
		String fillColor = styleObject.getPropertyAsString(LeafletStyle.FILL_COLOR_NAME);
		def.getFill().setNormalColor(fillColor);
	}

	if (styleObject.hasProperty(LeafletStyle.FILL_OPACITY_NAME)) {
		Double fillOpacity = styleObject.getPropertyAsDouble(LeafletStyle.FILL_OPACITY_NAME);
		def.getFill().setOpacity(fillOpacity);
	}

	if (styleObject.hasProperty(LeafletStyle.STROKE_COLOR_NAME)) {
		String strokeColor = styleObject.getPropertyAsString(LeafletStyle.STROKE_COLOR_NAME);
		def.getLine().setNormalColor(strokeColor);
	}

	if (styleObject.hasProperty(LeafletStyle.STROKE_WIDTH_NAME)) {
		Double strokeWidth = styleObject.getPropertyAsDouble(LeafletStyle.STROKE_WIDTH_NAME);
		def.getLine().setThickness(strokeWidth.intValue());
	}

	JSObject iconObject = styleObject.getProperty(LeafletStyle.ICON_NAME);
	if (iconObject != null) {

		if (iconObject.hasProperty(LeafletStyle.ICON_URL_NAME)) {
			String iconUrl = iconObject.getPropertyAsString(LeafletStyle.ICON_URL_NAME);
			def.getPoint().setExternalGraphic(iconUrl);
		}

		if (iconObject.hasProperty(LeafletStyle.ICON_SIZE_NAME)) {
			JsArrayInteger iconSize = iconObject.getProperty(LeafletStyle.ICON_SIZE_NAME).cast();

			int iconWidth = iconSize.get(0);
			int iconHeight = iconSize.get(1);

			def.getPoint().setGraphicWidth(iconWidth);
			def.getPoint().setGraphicHeight(iconHeight);
		}
	}

	return def;
}