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

The following examples show how to use org.gwtopenmaps.openlayers.client.util.JSObject#setProperty() . 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 applyColorStyle(Style style) {
	style.setFillColor(getFill().getNormalColor());
	style.setFillOpacity(getFill().getOpacity());
	style.setStrokeColor(getLine().getNormalColor());
	style.setStrokeWidth(getLine().getThickness());
	
	/**
	 * Se almacena el mismo color de relleno y linea en las propiedades
	 * userFillColor y userStrokeColor para tenerlo siempre disponible
	 * y asi poder aplicar los efectos de select y hover mediante eventos
	 * (ver VectorLayer.addFeatureSelectListeners())
	 */
	JSObject jsStyle = style.getJSObject();
	jsStyle.setProperty("userFillColor", getFill().getNormalColor());
	jsStyle.setProperty("userStrokeColor", getLine().getNormalColor());
}
 
Example 2
Source File: LeafletStyle.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
public static JSObject getStyle(VectorStyleDef def) {

		String fillColor = def.getFill().getNormalColor();
		Double fillOpacity = def.getFill().getOpacity();
		String strokeColor = def.getLine().getNormalColor();
		Double strokeWidth = new Double(def.getLine().getThickness());
		
		JSObject styleObject = JSObject.createJSObject();
		styleObject.setProperty(FILL_NAME, true);
		styleObject.setProperty(FILL_COLOR_NAME, fillColor);
		styleObject.setProperty(FILL_OPACITY_NAME, fillOpacity);
		styleObject.setProperty(STROKE_COLOR_NAME, strokeColor);
		styleObject.setProperty(STROKE_WIDTH_NAME, strokeWidth);
		styleObject.setProperty(RADIUS_NAME, RADIUS_VALUE);
		
		
		//icon
		String iconUrl = def.getPoint().getExternalGraphic();
		if (iconUrl != null) {
			JSObject iconObject = JSObject.createJSObject();
			iconObject.setProperty(ICON_URL_NAME, iconUrl);
			JsArrayInteger iconSize = JSObject.createArray().cast();
			
			iconSize.push(def.getPoint().getGraphicWidth());
			iconSize.push(def.getPoint().getGraphicHeight());
			
			JSObject iconSizeObject = iconSize.cast();
			
			iconObject.setProperty(ICON_SIZE_NAME, iconSizeObject);	
			
			styleObject.setProperty(ICON_NAME, iconObject);
		}
						
		return styleObject;
	}
 
Example 3
Source File: VectorFeatureStyleDef.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void applyLabelStyle(Style style, VectorFeature feature) {				
	JSObject jsStyle = style.getJSObject();
	
	if(getLabel().isEnabled()) {								
		style.setLabel(feature.getAttributes().getAttributeAsString(
				getLabel().getAttribute().getName()));
		style.setFontSize(getLabel().getFontSize() + "px");
			
		/**
		 * Se almacena el atributo de etiquetado en la propiedad
		 * userAttributeLabel para tenerlo disponible a la hora de
		 * recargar el dialogo de estilos
		 */
		jsStyle.setProperty("userAttributeLabel", 
				getLabel().getAttribute().getName());
		
		style.setFontWeight(getLabel().isBoldStyle() ? "bold" : "regular");					
		
		final boolean labelBackgroung = !getLabel()
				.getBackgroundColor().isEmpty();	
		
		jsStyle.setProperty("labelOutlineWidth", (labelBackgroung ? 10 : 0));
		jsStyle.setProperty("labelOutlineColor", (labelBackgroung ?
				getLabel().getBackgroundColor() : ""));			
	} else {
		style.setLabel(null);
		jsStyle.unsetProperty("userAttributeLabel");
	}
}
 
Example 4
Source File: VectorStyleDef.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
public StyleMap toStyleMap() {
	String labelAttribute = getLabel().isEnabled() ? getLabel().getAttribute().getName() : null;
	String colorThemingAttribute = isColorThemingEnabled() ? getColorThemingAttribute().getName() : null;
	
	Style normalStyle = StyleFactory.createStyle(
			getLine().getNormalColor(), getLine().getThickness(),
			getFill().getNormalColor(), getFill().getOpacity(), 
			labelAttribute, colorThemingAttribute);

	Style selectedStyle = StyleFactory.createStyle(
			getLine().getSelectedColor(), getLine().getThickness(),
			getFill().getSelectedColor(), getFill().getOpacity(), 
			labelAttribute, null);

	Style hoverStyle = StyleFactory.createStyle(
			getLine().getHoverColor(), getLine().getThickness(),
			getFill().getHoverColor(), getFill().getOpacity(), 
			labelAttribute, null);			
			
	JSObject jsStyle = normalStyle.getJSObject().getProperty("defaultStyle");						
	
	if (getLabel().isEnabled()) {
		jsStyle.setProperty("fontSize", getLabel().getFontSize() + "px");
		jsStyle.setProperty("fontWeight", getLabel().isBoldStyle() ? "bold" : "regular");
		
		final boolean labelBackgroung = getLabel().getBackgroundColor() != null;				
		jsStyle.setProperty("labelOutlineWidth", (labelBackgroung ? 10 : 0));
		jsStyle.setProperty("labelOutlineColor", labelBackgroung ?
				getLabel().getBackgroundColor() : "");				
	} 
	
	jsStyle.setProperty("graphicName", getPoint().getVertexStyle().getStyleName());
	jsStyle.setProperty("externalGraphic", getPoint().getExternalGraphic());
	jsStyle.setProperty("graphicWidth", getPoint().getGraphicWidth());
	jsStyle.setProperty("graphicHeight", getPoint().getGraphicHeight());
				
	return new StyleMap(normalStyle, selectedStyle, hoverStyle);
}