Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
generate all classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed May 22, 2017
1 parent 00c6005 commit 02cbcf2
Show file tree
Hide file tree
Showing 10 changed files with 623 additions and 17 deletions.
Expand Up @@ -3,11 +3,13 @@
package com.mapbox.mapboxsdk.style;

import android.support.annotation.UiThread;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.style.layers.PropertyValue;

/**
*
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-">The online documentation</a>
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#light>">The online documentation</a>
*/
@UiThread
public class Light {
Expand All @@ -23,10 +25,104 @@ public Light(long nativePtr) {
this.nativePtr = nativePtr;
}

/**
* Set the Anchor property.
*
* @param String value of anchor
*/
public void setAnchor(String anchor) {
nativeSetAnchor(new PropertyValue<>("anchor", anchor));
}

/**
* Set the Position property.
*
* @param Float[] value of position
*/
public void setPosition(Float[] position) {
nativeSetPosition(new PropertyValue<>("position", position));
}

/**
* Get the Position property transition options.
*
* @return transition options for Float[]
*/
public TransitionOptions getPositionTransition() {
return nativeGetPositionTransition();
}

/**
* Set the Position property transition options.
*
* @param options transition options for Float[]
*/
public void setPositionTransition(TransitionOptions options) {
nativeSetPositionTransition(options.getDuration(), options.getDelay());
}

/**
* Set the Color property.
*
* @param String value of color
*/
public void setColor(String color) {
nativeSetColor(new PropertyValue<>("color", color));
}

public void setColor(int color){
nativeSetColor();
/**
* Get the Color property transition options.
*
* @return transition options for String
*/
public TransitionOptions getColorTransition() {
return nativeGetColorTransition();
}

/**
* Set the Color property transition options.
*
* @param options transition options for String
*/
public void setColorTransition(TransitionOptions options) {
nativeSetColorTransition(options.getDuration(), options.getDelay());
}

/**
* Set the Intensity property.
*
* @param Float value of intensity
*/
public void setIntensity(Float intensity) {
nativeSetIntensity(new PropertyValue<>("intensity", intensity));
}

/**
* Get the Intensity property transition options.
*
* @return transition options for Float
*/
public TransitionOptions getIntensityTransition() {
return nativeGetIntensityTransition();
}

/**
* Set the Intensity property transition options.
*
* @param options transition options for Float
*/
public void setIntensityTransition(TransitionOptions options) {
nativeSetIntensityTransition(options.getDuration(), options.getDelay());
}

protected native void nativeSetColor();
private native void nativeSetAnchor(PropertyValue<String> property);
private native void nativeSetPosition(PropertyValue<Float[]> property);
private native TransitionOptions nativeGetPositionTransition();
private native void nativeSetPositionTransition(long duration, long delay);
private native void nativeSetColor(PropertyValue<String> property);
private native TransitionOptions nativeGetColorTransition();
private native void nativeSetColorTransition(long duration, long delay);
private native void nativeSetIntensity(PropertyValue<Float> property);
private native TransitionOptions nativeGetIntensityTransition();
private native void nativeSetIntensityTransition(long duration, long delay);
}
@@ -1,5 +1,4 @@
<%
const type = locals.type;
const properties = locals.properties;
const doc = locals.doc;
-%>
Expand All @@ -8,11 +7,13 @@
package com.mapbox.mapboxsdk.style;

import android.support.annotation.UiThread;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.style.layers.PropertyValue;

/**
* <%- doc %>
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-<%- type %>">The online documentation</a>
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#light>">The online documentation</a>
*/
@UiThread
public class Light {
Expand All @@ -27,4 +28,43 @@ public class Light {
public Light(long nativePtr) {
this.nativePtr = nativePtr;
}
<% for (const property of properties) { -%>
/**
* Set the <%- camelize(property.name) %> property.
*
* @param <%- propertyType(property) %> value of <%- property.name %>
*/
public void set<%- camelize(property.name) %>(<%- propertyType(property) %> <%- property.name %>) {
nativeSet<%- camelize(property.name) %>(new PropertyValue<>("<%- property.name %>", <%- property.name %>));
}
<% if (property.transition) { -%>
/**
* Get the <%- camelize(property.name) %> property transition options.
*
* @return transition options for <%- propertyType(property) %>
*/
public TransitionOptions get<%- camelize(property.name) %>Transition() {
return nativeGet<%- camelize(property.name) %>Transition();
}
/**
* Set the <%- camelize(property.name) %> property transition options.
*
* @param options transition options for <%- propertyType(property) %>
*/
public void set<%- camelize(property.name) %>Transition(TransitionOptions options) {
nativeSet<%- camelize(property.name) %>Transition(options.getDuration(), options.getDelay());
}
<% } -%>
<% } -%>

<% for (const property of properties) { -%>
private native void nativeSet<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> property);
<% if (property.transition) { -%>
private native TransitionOptions nativeGet<%- camelize(property.name) %>Transition();
private native void nativeSet<%- camelize(property.name) %>Transition(long duration, long delay);
<% } -%>
<% } -%>
}
Expand Up @@ -10,12 +10,15 @@
import com.mapbox.mapboxsdk.style.functions.Function;
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;

import junit.framework.Assert;

import timber.log.Timber;

import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -29,6 +32,9 @@
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

@RunWith(AndroidJUnit4.class)
public class LightTest extends BaseActivityTest {

Expand All @@ -53,14 +59,95 @@ public String getDescription() {
@Override
public void perform(UiController uiController, View view) {
light = mapboxMap.getLight();
light.setColor(Color.YELLOW);
// light.setColor(Color.YELLOW);
uiController.loopMainThreadForAtLeast(5000);
}
});

Assert.assertNotNull(light);
}


@Test
public void testSetAnchor() {
validateTestSetup();
setupLayer();
Timber.i("anchor");
assertNotNull(light);

// Set and Get
light.setAnchor(ANCHOR_MAP);
}

@Test
public void testPositionTransition() {
validateTestSetup();
setupLayer();
Timber.i("positionTransitionOptions");
assertNotNull(light);

// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
light.setPositionTransition(options);
}

@Test
public void testSetPosition() {
validateTestSetup();
setupLayer();
Timber.i("position");
assertNotNull(light);

// Set and Get
light.setPosition(new Float[]{0f,0f,0f});
}

@Test
public void testColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("colorTransitionOptions");
assertNotNull(light);

// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
light.setColorTransition(options);
}

@Test
public void testSetColor() {
validateTestSetup();
setupLayer();
Timber.i("color");
assertNotNull(light);

// Set and Get
light.setColor("rgba(0, 0, 0, 1)");
}

@Test
public void testIntensityTransition() {
validateTestSetup();
setupLayer();
Timber.i("intensityTransitionOptions");
assertNotNull(light);

// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
light.setIntensityTransition(options);
}

@Test
public void testSetIntensity() {
validateTestSetup();
setupLayer();
Timber.i("intensity");
assertNotNull(light);

// Set and Get
light.setIntensity(0.3f);
}

private void setupLayer(){
onView(withId(R.id.mapView)).perform(new ViewAction() {
@Override
Expand Down

0 comments on commit 02cbcf2

Please sign in to comment.