Skip to content

Commit

Permalink
Add render order function support
Browse files Browse the repository at this point in the history
  • Loading branch information
TDesjardins committed May 24, 2021
1 parent 944ca92 commit a1f7906
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
22 changes: 22 additions & 0 deletions gwt-ol3-client/src/main/java/ol/layer/BaseVectorLayerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
33 changes: 33 additions & 0 deletions gwt-ol3-client/src/main/java/ol/style/OrderFunction.java
Original file line number Diff line number Diff line change
@@ -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);

}
33 changes: 33 additions & 0 deletions gwt-ol3-client/src/main/java/ol/style/OrderFunctionRender.java
Original file line number Diff line number Diff line change
@@ -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);

}

0 comments on commit a1f7906

Please sign in to comment.