Skip to content

Commit

Permalink
Merge commit 'a1f7906273ca56273f389fa0aaf8de69bf002321' into gwt/2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Tino Desjardins committed May 24, 2021
2 parents a4352c5 + a1f7906 commit 2a3f26d
Show file tree
Hide file tree
Showing 26 changed files with 916 additions and 181 deletions.
13 changes: 12 additions & 1 deletion gwt-ol3-client/src/main/java/ol/interaction/ModifyOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ol.Feature;
import ol.GenericFunction;
import ol.Options;
import ol.source.Vector;
import ol.style.StyleFunction;

/**
Expand Down Expand Up @@ -62,6 +63,15 @@ public class ModifyOptions implements Options {
@JsProperty
public native void setPixelTolerance(int clickTolerance);

/**
* The vector source with features to modify. If a vector source is not provided,
* a feature collection must be provided with the features option.
*
* @param source source
*/
@JsProperty
public native void setSource(Vector source);

/**
* Style used for the features being modified. By default the default edit
* style is used (see ol.style).
Expand All @@ -72,7 +82,8 @@ public class ModifyOptions implements Options {
public native void setStyle(StyleFunction styleFunction);

/**
* The features the interaction works on. Required.
* The features the interaction works on. If a feature collection is not
* provided, a vector source must be provided with the source option.
*
* @param features
*/
Expand Down
128 changes: 128 additions & 0 deletions gwt-ol3-client/src/main/java/ol/layer/BaseVector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*******************************************************************************
* Copyright 2014, 2021 gwt-ol
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package ol.layer;

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsType;
import ol.style.Style;
import ol.style.StyleFunction;

/**
* Vector data that is rendered client-side. Note that any property set in the
* options is set as a {@link ol.Object} property on the layer object; for
* example, setting `title: 'My Title'` in the options means that `title` is
* observable, and has get/set accessors.
*
* @author Tino Desjardins
*
*/
@JsType(isNative = true)
public abstract class BaseVector extends Layer {

public BaseVector() {}

public BaseVector(BaseVectorLayerOptions vectorLayerOptions) {}

/**
* Get the style for features. This returns whatever was passed to the
* `style` option at construction or to the `setStyle` method.
*
* @return style for features.
*/
@JsMethod(name = "getStyle")
private native Object getNativeStyle();

/**
* @return The vector style.
*/
@JsOverlay
public final Style getStyle() {

java.lang.Object nativeStyle = this.getNativeStyle();

if (nativeStyle instanceof Style[]) {
Style[] styles = (Style[])nativeStyle;

if (styles.length > 0) {
return styles[0];
}

} else if (nativeStyle instanceof Style) {
return (Style)nativeStyle;
}

return null;
}

/**
* @return The vectors styles.
*/
@JsOverlay
public final Style[] getStyles() {

java.lang.Object nativeStyle = this.getNativeStyle();

if (nativeStyle instanceof Style[]) {
return (Style[])this.getNativeStyle();
} else if (nativeStyle instanceof Style) {
Style[] styles = new Style[1];
styles[0] = (Style)nativeStyle;
return styles;
}

return null;

}

/**
* @return The vector's style function.
*/
public native StyleFunction getStyleFunction();

@JsMethod(name = "setStyle")
private native void setNativeStyle(java.lang.Object style);

/**
* Set the style for features. This can be a single style object, an array
* of styles, or a function that takes a feature and resolution and returns
* an array of styles. If it is `undefined` the default style is used. If it
* is `null` the layer has no style (a `null` style), so only features that
* have their own styles will be rendered in the layer. See {@link ol.style}
* for information on the default style.
*
* @param style
* Layer style.
*/
public native void setStyle(ol.style.Style style);

@JsOverlay
public final void setStyles(Style[] styles) {
setNativeStyle(styles);
}

/**
* @deprecated Use {@link ol.layer.BaseVector#setStyleFunction(StyleFunction)} instead.
*/
@Deprecated
public native void setStyle(StyleFunction style);

@JsOverlay
public final void setStyleFunction(StyleFunction styleFunction) {
setNativeStyle(styleFunction);
}

}
128 changes: 128 additions & 0 deletions gwt-ol3-client/src/main/java/ol/layer/BaseVectorLayerOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*******************************************************************************
* Copyright 2014, 2021 gwt-ol
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package ol.layer;

import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;

import jsinterop.annotations.JsType;
import ol.PluggableMap;
import ol.style.OrderFunction;
import ol.style.OrderFunctionRender;
import ol.style.Style;
import ol.style.StyleFunction;

/**
* Base vector layer options.
*
* @author sbaumhekel
*
*/
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class BaseVectorLayerOptions extends LayerOptions {

/**
* Declutter images and text. Decluttering is applied to all image and text styles of
* all Vector and VectorTile layers that have set this to true. The priority is
* defined by the z-index of the layer, the zIndex of the style and the render
* order of features. Higher z-index means higher priority. Within the same z-index,
* a feature rendered before another has higher priority.
*
* @param declutter
*/
@JsProperty
public native void setDeclutter(boolean declutter);

/**
*
* Sets the layer as overlay on a map. The map will not manage this layer in
* its layers collection, and the layer will be rendered on top. This is
* useful for temporary layers. The standard way to add a layer to a map and
* have it managed by the map is to use {@link ol.PluggableMap#addLayer(Base)}.
*
* @param map {@link ol.PluggableMap}
*/
@JsProperty
public native void setMap(PluggableMap map);

/**
* The buffer around the viewport extent used by the renderer when getting
* features from the vector source for the rendering or hit-detection.
* Recommended value: the size of the largest symbol, line width or label.
* Default is 100 pixels.
*
* @param renderBuffer render buffer
*/
@JsProperty
public native void setRenderBuffer(double renderBuffer);

/**
* Render order. Function to be used when sorting features before rendering.
* By default features are drawn in the order that they are created. Use null
* to avoid the sort, but get an undefined draw order.
*
* @param orderFunction order function
*/
@JsProperty
public native void setRenderOrder(OrderFunction orderFunction);

/**
* Render order. Function to be used when sorting features before rendering.
* By default features are drawn in the order that they are created. Use null
* to avoid the sort, but get an undefined draw order.
*
* @param orderFunction order function
*/
@JsProperty
public native void setRenderOrder(OrderFunctionRender orderFunction);

@JsProperty
public native void setStyle(Style style);

/**
* Layer style. See ol.style for default style which will be used if this is
* not defined.
*
* @param style {@link Style}
*/
@JsProperty
public native void setStyle(Style[] style);

@JsProperty
public native void setStyle(StyleFunction style);

/**
* When set to true, feature batches will be recreated during animations.
* This means that no vectors will be shown clipped, but the setting will
* have a performance impact for large amounts of vector data. When set to
* false, batches will be recreated when no animation is active. Default is
* false.
*
* @param updateWhileAnimating update while animating?
*/
@JsProperty
public native void setUpdateWhileAnimating(boolean updateWhileAnimating);

/**
* When set to true, feature batches will be recreated during interactions.
* See also updateWhileAnimating. Default is false.
*
* @param updateWhileInteracting update while interacting?
*/
@JsProperty
public native void setUpdateWhileInteracting(boolean updateWhileInteracting);

}
69 changes: 69 additions & 0 deletions gwt-ol3-client/src/main/java/ol/layer/Heatmap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright 2014, 2021 gwt-ol
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package ol.layer;

import jsinterop.annotations.JsType;

/**
* Layer for rendering vector data as a heatmap. Note that any property set in the
* options is set as a {@link ol.Object} property on the layer object;
* for example, setting title: 'My Title' in the options means that title is
* observable, and has get/set accessors.
*
* @author Tino Desjardins
*
*/
@JsType(isNative = true)
public class Heatmap extends Vector {

public Heatmap() {}

public Heatmap(HeatmapOptions vectorLayerOptions) {}

/**
* @return blur size in pixels.
*/
public native double getBlur();

/**
* @param blur blur size in pixels.
*/
public native void setBlur(double blur);

/**
* @return gradient colors.
*/
public native String[] getGradient();

/**
* Default gradient: {"#00f", "#0ff", "#0f0", "#ff0", "#f00"}
*
* @param gradient gradient colors.
*/
public native void setGradient(String[] gradient);

/**
* @return radius size in pixels.
*/
public native double getRadius();


/**
* @param radius radius size in pixels.
*/
public native void setRadius(double radius);

}
Loading

0 comments on commit 2a3f26d

Please sign in to comment.