In this tutorial you will learn what type representations are and how to
Intermediate
If you are not interested in the explanation of type representations, you may skip the introduction and continue with Choosing Type Representations.
As already explained in What Is VRL-Studio? VRL provides three types of visual components (see Figure Component Types) . This introduction is about parameter visualizations, i.e., type representations.
Type representations are the most individual part of the VRL GUI generation. Method representations and Object representations are mainly containers and the possibilities to customize their appearance are rather limited. Type representations however are individual representations of parameters and return values.
For each parameter type several type representations can be registered. In the case of Integer
VRL provides
VRL provides type representations for a variety of types, such as
In addition many plugins provide their own type representations.
NOTE: Check the API doc for a complete list of supported types.
In the following example we will change the default type representation of a method parameter.
The code below defines a simple Groovy class that provides a method which adds two integer values.
@ComponentInfo(name=AddIntegers, category="Custom")
class AddIntegers {
public Integer add( Integer a , Integer b) {
return a+b;
}
}
The default visualization is shown in Figure Add Integers.
To request a different type representation one can annotate the parameter with a so called @ParamInfo
:
@ComponentInfo(name=AddIntegers, category="Custom")
class AddIntegers {
public Integer add(
@ParamInfo(style="slider") Integer a, Integer b) {
return a+b;
}
}
Figure Choosing a Slider shows the difference between the default visualization and the new example with the slider.
NOTE: for an introduction to Java annotations consult the official documentation: Annotation Tutorial (Oracle)
In addition to selecting the type representation @ParamInfo
can be used to specify
1.) Changing the parameter name:
@ComponentInfo(name=AddIntegers, category="Custom")
class AddIntegers {
public Integer add(
@ParamInfo(name="My Name", style="slider") Integer a, Integer b) {
return a+b;
}
}
2.) Defining min=3 & max=10
:
@ComponentInfo(name=AddIntegers, category="Custom")
class AddIntegers {
public Integer add(
@ParamInfo(name="My Name", style="slider", options="min=3; max=10;") Integer a,
Integer b) {
return a+b;
}
}
–