org.gwtopenmaps.openlayers.client.util.JSObject Java Examples
The following examples show how to use
org.gwtopenmaps.openlayers.client.util.JSObject.
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: TmsLayerDef.java From geowe-core with GNU General Public License v3.0 | 6 votes |
private static native JSObject getMyUrl() /*-{ function get_my_url(bounds) { var res = this.map.getResolution(); var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); var z = this.map.getZoom(); var limit = Math.pow(2, z); if (y < 0 || y >= limit) { return null; } else { x = ((x % limit) + limit) % limit; url = this.url; path = z + "/" + x + "/" + y + "." + this.type; if (url instanceof Array) { url = this.selectUrl(path, url); } return url + path; } } return get_my_url; }-*/;
Example #2
Source File: VectorFeatureStyleDef.java From geowe-core with GNU General Public License v3.0 | 6 votes |
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 #3
Source File: VectorFeatureStyleDef.java From geowe-core with GNU General Public License v3.0 | 6 votes |
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 #4
Source File: GeoJSONCSS.java From geowe-core with GNU General Public License v3.0 | 6 votes |
public VectorFeature[] read(String vectorFormatString) { JSObject out = FormatImpl.read(getJSObject(), vectorFormatString); JObjectArray jObjectArray = JObjectArray.narrowToJObjectArray(out.ensureOpaqueArray()); int nr = jObjectArray.length(); VectorFeature[] vfs = new VectorFeature[nr]; for (int i = 0; i < nr; i++) { VectorFeature vf = VectorFeature.narrowToVectorFeature(jObjectArray.get(i)); JSObject styleObject = jObjectArray.get(i).getProperty(STYLE_NAME); if (styleObject != null) { VectorFeatureStyleDef def = getStyleDef(styleObject); vf.setStyle(def.toStyle(vf)); } vfs[i] = vf; } return vfs; }
Example #5
Source File: VectorFeatureStyleDef.java From geowe-core with GNU General Public License v3.0 | 6 votes |
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 #6
Source File: VectorFeatureStyleDef.java From geowe-core with GNU General Public License v3.0 | 5 votes |
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 #7
Source File: VectorLayer.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public VectorLayer(JSObject vector) { super(vector); this.featureSchema = new FeatureSchema(); setVectorStyle(new VectorStyleDef()); addFeatureAddedListener(); addFeatureSelectListeners(); }
Example #8
Source File: GeoJSONCSS.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public VectorStyleDef getLayerStyle(String vectorFormatString) { VectorFeatureStyleDef def = null; final JSONValue jsonValue = JSONParser.parseLenient(vectorFormatString); final JSONObject geoJSONCssObject = jsonValue.isObject(); if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) { JSONObject styleObject = geoJSONCssObject.get(GeoJSONCSS.STYLE_NAME).isObject(); JSObject styleJSObject = styleObject.getJavaScriptObject().cast(); def = getStyleDef(styleJSObject); } return def; }
Example #9
Source File: VectorStyleDef.java From geowe-core with GNU General Public License v3.0 | 5 votes |
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); }
Example #10
Source File: VectorFeatureStyleDef.java From geowe-core with GNU General Public License v3.0 | 5 votes |
private boolean isBoldFont(JSObject style) { String fontWeight = style.getPropertyAsString("fontWeight"); if(fontWeight == null || fontWeight.isEmpty()) { fontWeight = "regular"; } return fontWeight.equalsIgnoreCase("bold"); }
Example #11
Source File: VectorFeatureStyleDef.java From geowe-core with GNU General Public License v3.0 | 5 votes |
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 #12
Source File: LeafletStyle.java From geowe-core with GNU General Public License v3.0 | 5 votes |
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 #13
Source File: BBoxControlImpl.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
/** * Creates the. * * @return the jS object */ public static native JSObject create()/*-{ var control = new $wnd.OpenLayers.Control.ZoomIn(); $wnd.OpenLayers.Util.extend(control, { draw: function () { this.box = new $wnd.OpenLayers.Handler.Box( control, {"done": this.notice}, {keyMask: $wnd.OpenLayers.Handler.MOD_SHIFT}); this.box.activate(); } }); return control; }-*/;
Example #14
Source File: PolygonHandlerOptions.java From geowe-core with GNU General Public License v3.0 | 4 votes |
protected PolygonHandlerOptions(JSObject jsObject) { super(jsObject); }
Example #15
Source File: GeoMapInitializer.java From geowe-core with GNU General Public License v3.0 | 4 votes |
private LonLat getLonLat(final EventObject eventObject) { final JSObject xy = eventObject.getJSObject().getProperty("xy"); final Pixel px = Pixel.narrowToPixel(xy); return geoMap.getMap().getLonLatFromPixel(px); }
Example #16
Source File: StyleFactory.java From geowe-core with GNU General Public License v3.0 | 4 votes |
private static native JSObject createOpenLayersStyle( String strokeColor, int strokeWidth, String fillColor, double fillOpacity, String attributeLabel, String colorThemingAttribute) /*-{ var style = new $wnd.OpenLayers.Style( { strokeColor : (colorThemingAttribute != null ? "${getColor}" : strokeColor), strokeWidth : strokeWidth, fillColor : (colorThemingAttribute != null ? "${getColor}" : fillColor), fillOpacity : fillOpacity, pointRadius : 5, strokeOpacity : 1.0, graphicName : "circle", fontWeight : "bold", labelAlign : "center", fontFamily : "Courier New, monospace", fontColor : "#FFFFFF", fontSize : "12px", label : "${getLabel}" }, { context : { getLabel : function(feature) { if (attributeLabel == null) { return ""; } if (feature.attributes[attributeLabel]) { return feature.attributes[attributeLabel]; } else { return ""; } }, getColor : function(feature) { if (colorThemingAttribute == null) { return fillColor; } var themingValue = "" + feature.attributes[colorThemingAttribute]; return @org.geowe.client.local.style.StyleFactory::stringToColour(Ljava/lang/String;)(themingValue); } } }); return style; }-*/;
Example #17
Source File: TopoJSON.java From geowe-core with GNU General Public License v3.0 | 4 votes |
protected TopoJSON(JSObject topoJSONFormat) { super(topoJSONFormat); }
Example #18
Source File: TopoJSONImpl.java From geowe-core with GNU General Public License v3.0 | 4 votes |
public static native JSObject create() /*-{ return new $wnd.OpenLayers.Format.TopoJSON(); }-*/;
Example #19
Source File: GPXImpl.java From geowe-core with GNU General Public License v3.0 | 4 votes |
public static native JSObject create() /*-{ return new $wnd.OpenLayers.Format.GPX(); }-*/;
Example #20
Source File: GPX.java From geowe-core with GNU General Public License v3.0 | 4 votes |
protected GPX(JSObject gpxFormat) { super(gpxFormat); }
Example #21
Source File: GeoJSONCSS.java From geowe-core with GNU General Public License v3.0 | 4 votes |
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; }
Example #22
Source File: GeoJSONCSS.java From geowe-core with GNU General Public License v3.0 | 4 votes |
protected GeoJSONCSS(JSObject geoJSONFormat) { super(geoJSONFormat); }
Example #23
Source File: GeoJSONCSSImpl.java From geowe-core with GNU General Public License v3.0 | 4 votes |
public static native JSObject create() /*-{ return new $wnd.OpenLayers.Format.GeoJSONCSS(); }-*/;
Example #24
Source File: PolygonHandlerOptions.java From geowe-core with GNU General Public License v3.0 | 4 votes |
public PolygonHandlerOptions() { this(JSObject.createJSObject()); }
Example #25
Source File: BBoxControl.java From SensorWebClient with GNU General Public License v2.0 | 2 votes |
/** * Instantiates a new b box control. * * @param element * the element */ protected BBoxControl(JSObject element) { super(element); }
Example #26
Source File: BBoxControlImpl.java From SensorWebClient with GNU General Public License v2.0 | 2 votes |
/** * Creates the. * * @param options * the options * @return the jS object */ public static native JSObject create(JSObject options)/*-{ return new $wnd.OpenLayers.Control.ZoomBox(options); }-*/;