summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs
blob: ed138e557a032c827578e434336c7a8d454c47d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<%
  const paintProperties = locals.paintProperties;
  const layoutProperties = locals.layoutProperties;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.

package com.mapbox.mapboxsdk.style.layers;

import android.annotation.SuppressLint;
import android.support.annotation.ColorInt;

import com.mapbox.mapboxsdk.style.functions.Function;
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
import com.mapbox.mapboxsdk.style.expressions.Expression;

/**
 * Constructs paint/layout properties for Layers
 *
 * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers">Layer style documentation</a>
 */
public class PropertyFactory {

  /**
   * Set the property visibility.
   *
   * @param value the visibility value
   * @return property wrapper around visibility
   */
  public static PropertyValue<String> visibility(@Property.VISIBILITY String value) {
    return new LayoutPropertyValue<>("visibility", value);
  }

  /**
   * Set the property visibility.
   *
   * @param <T> the function input type
   * @param function the visibility function
   * @return property wrapper around a String function
   */
  @Deprecated
  public static <T> PropertyValue<Function<T, String>> visibility(Function<T, String> function) {
    return new LayoutPropertyValue<>("visibility", function);
  }

<% for (const property of paintProperties) { -%>
<% if (property.type == 'color') { -%>
  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param value a int color value
   * @return property wrapper around String color
   */
  public static PropertyValue<String> <%- camelizeWithLeadingLowercase(property.name) %>(@ColorInt int value) {
    return new PaintPropertyValue<>("<%-  property.name %>", colorToRgbaString(value));
  }

<% } -%>
  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param value a <%- propertyType(property) %> value
   * @return property wrapper around <%- propertyType(property) %>
   */
  public static PropertyValue<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
    return new PaintPropertyValue<>("<%-  property.name %>", value);
  }

  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param expression an expression statement
   * @return property wrapper around an expression statement
   */
  public static PropertyValue<Expression> <%- camelizeWithLeadingLowercase(property.name) %>(Expression expression) {
    return new PaintPropertyValue<>("<%-  property.name %>", expression);
  }

<% if (supportsPropertyFunction(property)) { -%>

  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param <T> the function input type
   * @param function a wrapper function for <%- propertyType(property) %>
   * @return property wrapper around a <%- propertyType(property) %> function
   */
  @Deprecated
  public static <T> PropertyValue<Function<T, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<T, <%- propertyType(property) %>> function) {
    return new PaintPropertyValue<>("<%-  property.name %>", function);
  }

<% } else if (supportsZoomFunction(property)) { -%>

  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param <Z> the zoom parameter type
   * @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
   * @return property wrapper around a <%- propertyType(property) %> function
   */
  @Deprecated
  public static <Z extends Number> PropertyValue<CameraFunction<Z, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction<Z, <%- propertyType(property) %>> function) {
    return new PaintPropertyValue<>("<%-  property.name %>", function);
  }

<% } -%>
<% } -%>
<% for (const property of layoutProperties) { -%>
  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param value a <%- propertyType(property) %> value
   * @return property wrapper around <%- propertyType(property) %>
   */
  public static PropertyValue<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
    return new LayoutPropertyValue<>("<%-  property.name %>", value);
  }

  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param value a <%- propertyType(property) %> value
   * @return property wrapper around <%- propertyType(property) %>
   */
  public static PropertyValue<Expression> <%- camelizeWithLeadingLowercase(property.name) %>(Expression value) {
    return new LayoutPropertyValue<>("<%-  property.name %>", value);
  }

<% if (supportsPropertyFunction(property)) { -%>

  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param <T> the function input type
   * @param function a wrapper function for <%- propertyType(property) %>
   * @return property wrapper around a <%- propertyType(property) %> function
   */
  public static <T> PropertyValue<Function<T, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<T, <%- propertyType(property) %>> function) {
    return new LayoutPropertyValue<>("<%-  property.name %>", function);
  }

<% } else if (supportsZoomFunction(property)) { -%>

  /**
   * <%- propertyFactoryMethodDoc(property) %>
   *
   * @param <Z> the zoom parameter type
   * @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
   * @return property wrapper around a <%- propertyType(property) %> function
   */
  public static <Z extends Number> PropertyValue<CameraFunction<Z, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction<Z, <%- propertyType(property) %>> function) {
    return new LayoutPropertyValue<>("<%-  property.name %>", function);
  }

<% } -%>
<% } -%>
  @SuppressLint("DefaultLocale")
  public static String colorToRgbaString(@ColorInt int value) {
    return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF);
  }

}