From a1f7906273ca56273f389fa0aaf8de69bf002321 Mon Sep 17 00:00:00 2001 From: Tino Desjardins Date: Mon, 24 May 2021 09:54:55 +0200 Subject: [PATCH] Add render order function support --- .../java/ol/layer/BaseVectorLayerOptions.java | 22 +++++++++++++ .../src/main/java/ol/style/OrderFunction.java | 33 +++++++++++++++++++ .../java/ol/style/OrderFunctionRender.java | 33 +++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 gwt-ol3-client/src/main/java/ol/style/OrderFunction.java create mode 100644 gwt-ol3-client/src/main/java/ol/style/OrderFunctionRender.java diff --git a/gwt-ol3-client/src/main/java/ol/layer/BaseVectorLayerOptions.java b/gwt-ol3-client/src/main/java/ol/layer/BaseVectorLayerOptions.java index 90aaba9a..65758d14 100644 --- a/gwt-ol3-client/src/main/java/ol/layer/BaseVectorLayerOptions.java +++ b/gwt-ol3-client/src/main/java/ol/layer/BaseVectorLayerOptions.java @@ -20,6 +20,8 @@ import jsinterop.annotations.JsType; import ol.PluggableMap; +import ol.style.OrderFunction; +import ol.style.OrderFunctionRender; import ol.style.Style; import ol.style.StyleFunction; @@ -67,6 +69,26 @@ public class BaseVectorLayerOptions extends LayerOptions { @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); diff --git a/gwt-ol3-client/src/main/java/ol/style/OrderFunction.java b/gwt-ol3-client/src/main/java/ol/style/OrderFunction.java new file mode 100644 index 00000000..f38f18aa --- /dev/null +++ b/gwt-ol3-client/src/main/java/ol/style/OrderFunction.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.style; + +import jsinterop.annotations.JsFunction; +import ol.Feature; + +/** + * A function to be used when sorting features before rendering. + * + * @author TDesjardins + * + */ +@FunctionalInterface +@JsFunction +public interface OrderFunction { + + double sort(Feature feature1, Feature feature2); + +} \ No newline at end of file diff --git a/gwt-ol3-client/src/main/java/ol/style/OrderFunctionRender.java b/gwt-ol3-client/src/main/java/ol/style/OrderFunctionRender.java new file mode 100644 index 00000000..01ebdd0d --- /dev/null +++ b/gwt-ol3-client/src/main/java/ol/style/OrderFunctionRender.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.style; + +import jsinterop.annotations.JsFunction; +import ol.render.Feature; + +/** + * A function to be used when sorting features before rendering. + * + * @author TDesjardins + * + */ +@FunctionalInterface +@JsFunction +public interface OrderFunctionRender { + + double sort(Feature feature1, Feature feature2); + +} \ No newline at end of file