-
-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathOptions.java
More file actions
396 lines (348 loc) · 13.2 KB
/
Copy pathOptions.java
File metadata and controls
396 lines (348 loc) · 13.2 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
package app.f3d.F3D;
import java.util.List;
public class Options {
/**
* Package-private constructor for creating an Options instance from a native pointer.
*
* @param nativeAddress the native memory address of the underlying f3d::options object
*/
Options(long nativeAddress) {
mNativeAddress = nativeAddress;
}
/** Thrown when the requested option name does not exist. */
public static class InexistentException extends F3DException {
public InexistentException(String message) { super(message); }
}
/** Thrown when an option's type is incompatible with the requested operation. */
public static class IncompatibleException extends F3DException {
public IncompatibleException(String message) { super(message); }
}
/** Thrown when a string representation cannot be parsed into the option's type. */
public static class ParsingException extends F3DException {
public ParsingException(String message) { super(message); }
}
/** Thrown when a get operation is called on an option with no value set. */
public static class NoValueException extends F3DException {
public NoValueException(String message) { super(message); }
}
/**
* Enumeration of supported domain style.
*/
public enum DomainStyle {
RANGE,
ENUM,
INDEX
}
/**
* Enumeration of the possible types of an option.
*/
public enum OptionType {
BOOL,
INT,
DOUBLE,
RATIO,
STRING,
PATH,
COLOR,
DIRECTION,
COLORMAP,
TRANSFORM2D,
DOUBLE_VECTOR,
INT_VECTOR
}
/**
* Sets a boolean option value.
*
* @param name the name of the option to set
* @param value the boolean value to set
* @throws IllegalArgumentException if the option name does not exist or is not a boolean type
*/
public native void setAsBool(String name, boolean value);
/**
* Sets an integer option value.
*
* @param name the name of the option to set
* @param value the integer value to set
* @throws IllegalArgumentException if the option name does not exist or is not an integer type
*/
public native void setAsInt(String name, int value);
/**
* Sets a double option value.
*
* @param name the name of the option to set
* @param value the double value to set
* @throws IllegalArgumentException if the option name does not exist or is not a double type
*/
public native void setAsDouble(String name, double value);
/**
* Sets a string option value.
*
* @param name the name of the option to set
* @param value the string value to set
* @throws IllegalArgumentException if the option name does not exist or is not a string type
*/
public native void setAsString(String name, String value);
/**
* Sets a double vector option value.
*
* @param name the name of the option to set
* @param values the array of double values to set
* @throws IllegalArgumentException if the option name does not exist or is not a double vector type
*/
public native void setAsDoubleVector(String name, double[] values);
/**
* Sets an integer vector option value.
*
* @param name the name of the option to set
* @param values the array of integer values to set
* @throws IllegalArgumentException if the option name does not exist or is not an integer vector type
*/
public native void setAsIntVector(String name, int[] values);
/**
* Gets a boolean option value.
*
* @param name the name of the option to retrieve
* @return the boolean value of the option
* @throws IllegalArgumentException if the option name does not exist or is not a boolean type
*/
public native boolean getAsBool(String name);
/**
* Gets an integer option value.
*
* @param name the name of the option to retrieve
* @return the integer value of the option
* @throws IllegalArgumentException if the option name does not exist or is not an integer type
*/
public native int getAsInt(String name);
/**
* Gets a double option value.
*
* @param name the name of the option to retrieve
* @return the double value of the option
* @throws IllegalArgumentException if the option name does not exist or is not a double type
*/
public native double getAsDouble(String name);
/**
* Gets a string option value.
*
* @param name the name of the option to retrieve
* @return the string value of the option
* @throws IllegalArgumentException if the option name does not exist or is not a string type
*/
public native String getAsString(String name);
/**
* Gets the string representation of an option value regardless of its underlying type.
*
* @param name the name of the option to retrieve
* @return the string representation of the option value
* @throws IllegalArgumentException if the option name does not exist
*/
public native String getAsStringRepresentation(String name);
/**
* Sets an option value from its string representation.
*
* @param name the name of the option to set
* @param str the string representation to parse and set
* @throws IllegalArgumentException if the option name does not exist or the string cannot be parsed
*/
public native void setAsStringRepresentation(String name, String str);
/**
* Gets a double vector option value.
*
* @param name the name of the option to retrieve
* @return the array of double values
* @throws IllegalArgumentException if the option name does not exist or is not a double vector type
*/
public native double[] getAsDoubleVector(String name);
/**
* Gets an integer vector option value.
*
* @param name the name of the option to retrieve
* @return the array of integer values
* @throws IllegalArgumentException if the option name does not exist or is not an integer vector type
*/
public native int[] getAsIntVector(String name);
/**
* Toggles a boolean option value.
*
* @param name the name of the boolean option to toggle
* @throws IllegalArgumentException if the option name does not exist or is not a boolean type
*/
public native void toggle(String name);
/**
* Checks if the specified option has the same value in this instance and another Options instance.
*
* @param other the other Options instance to compare with
* @param name the name of the option to compare
* @return true if both options have the same value, false otherwise
* @throws IllegalArgumentException if the option name does not exist
*/
public native boolean isSame(Options other, String name);
/**
* Checks if the specified option has a value set.
*
* @param name the name of the option to check
* @return true if the option has a value, false otherwise
* @throws IllegalArgumentException if the option name does not exist
*/
public native boolean hasValue(String name);
/**
* Copies the value of an option from another Options instance to this instance.
*
* @param other the Options instance to copy from
* @param name the name of the option to copy
* @throws IllegalArgumentException if the option name does not exist
*/
public native void copy(Options other, String name);
/**
* Gets a list of all available option names in F3D.
*
* @return a list containing all option names
*/
public static native List<String> getAllNames();
/**
* Gets a list of option names that have values set in this Options instance.
*
* @return a list containing names of options with values
*/
public native List<String> getNames();
/**
* Finds the closest matching option name to the provided string.
*
* @param option the option name to find a match for
* @return a ClosestOptionResult containing the closest match name and edit distance
*/
public native ClosestOptionResult getClosestOption(String option);
/**
* Checks if the specified option is optional.
*
* @param name the name of the option to check
* @return true if the option is optional, false if it is required
* @throws IllegalArgumentException if the option name does not exist
*/
public native boolean isOptional(String name);
/**
* Gets the type of the specified option.
*
* @param name the name of the option to check
* @return the type of the option
* @throws IllegalArgumentException if the option name does not exist
*/
public native OptionType getType(String name);
/**
* Resets the specified option to its default value.
*
* @param name the name of the option to reset
* @throws IllegalArgumentException if the option name does not exist
*/
public native void reset(String name);
/**
* Removes the value of the specified option, making it unset.
*
* @param name the name of the option to remove the value from
* @throws IllegalArgumentException if the option name does not exist
*/
public native void removeValue(String name);
/**
* Return true if an option as a domain, false otherwise.
*
* @param name the name of the option to remove the value from
* @throws IllegalArgumentException if the option name does not exist
*/
public native boolean hasDomain(String name);
/**
* Return the domain style of the provided option.
*
* @param name the name of the option to remove the value from
* @throws IllegalArgumentException if the option name does not exist or it doesn't have a domain
*/
public native DomainStyle getDomainStyle(String name);
/**
* Return a vector of string containing the enumeration for the option
*
* @param name the name of the option to remove the value from
* @return enumeration of values
* @throws IllegalArgumentException if the option name does not exist or doesn't have an enum domain
*/
public native List<String> getEnumDomain(String name);
/**
* Structure holding a range domain: min, max and increment.
*/
public static final class DomainRange<T extends Number> {
public final T min;
public final T max;
public final T increment;
DomainRange(T min, T max, T increment) {
this.min = min;
this.max = max;
this.increment = increment;
}
}
/**
* Return the range domain of the option as a DomainRange of Double.
* Matches double and ratio domains, as ratio does not exist in Java.
*
* @param name the name of the option to get the range domain from
* @return the range domain of the option
* @throws IllegalArgumentException if the option name does not exist, doesn't have a range
* domain, or if the domain is not a double or ratio domain
*/
public native DomainRange<Double> getRangeDomainAsDouble(String name);
/**
* Return the range domain of the option as a DomainRange of Integer.
*
* @param name the name of the option to get the range domain from
* @return the range domain of the option
* @throws IllegalArgumentException if the option name does not exist, doesn't have a range
* domain, or if the domain is not an int domain
*/
public native DomainRange<Integer> getRangeDomainAsInt(String name);
/**
* Increase the specified option if it has a range or index domain
*
* @param name the name of the option to increase
* @throws IllegalArgumentException if the option name does not exist or doesn't have the expected domain
*/
public native void increase(String name);
/**
* Decrease the specified option if it has a range or index domain
*
* @param name the name of the option to decrease
* @throws IllegalArgumentException if the option name does not exist or doesn't have the expected domain
*/
public native void decrease(String name);
/**
* Cycle the specified option if it has an enum or index domain
*
* @param name the name of the option to cycle
* @throws IllegalArgumentException if the option name does not exist or doesn't have the expected domain
*/
public native void cycle(String name);
/**
* Result class for the closest option search operation.
*/
public static class ClosestOptionResult {
/**
* The name of the closest matching option.
*/
public String name;
/**
* The edit distance to the match.
*/
public int distance;
/**
* Constructs a ClosestOptionResult.
*
* @param name the name of the closest matching option
* @param distance the edit distance to the match
*/
public ClosestOptionResult(String name, int distance) {
this.name = name;
this.distance = distance;
}
}
/**
* Native pointer to the underlying f3d::options object.
*/
private long mNativeAddress;
}