@Retention(value=RUNTIME) @Target(value={FIELD,METHOD}) public @interface Tunable
Task
object that allows the Task
to be configured
with user supplied information. Tunable
annotations allow Task
s to
be configured with specific, user supplied data, without needing to produce
a user interface. The TaskManager
is responsible for inferring a
user interface from the types of the fields or methods being annotated.
Tunable
annotations are suitable only for information that must be
supplied by the user. For instance, the name of a file to load can only
be known by the user, so is appropriate to be specified by the user. Other
information necessary for the Task
to execute should be provided
as constructor arguments to the Task
.
Tunable
annotations provide several parameters that can be used to control
the display of Tunable
s in the eventual user interface. These parameters
are documented below.
Tunable
annotation for a field annotation:
@Tunable(description="your last name", group={"Human","pupil"}, params="displayState=collapsed") public String lastName = "Smith";This tunable will be grouped in the user interface first within the "Human" group, then within the "pupil" group. How this grouping is displayed to users is a function of which
TaskManager
is used. Likewise, if supported by the TaskManager
, the display state of the Tunable
will initially be collapsed.
Tunable
annotation for method annotation.
Method annotations require both a getter and a setter method to get and set a
value. Only the getter method needs to be annotated. The getter method must take no arguments
and return a value and be named with the prefix "get". The setter method does not need a
Tunable
annotation, however the method must take a single argument of the same type as
the getter method, it must return void, it must be named with the prefix "set", and the
rest of the name must match that of the getter method. If the group name begins with underscore (_)
then the display of the group name will be suppressed.
@Tunable(description="your last name", group={"Human","pupil"}, params="displayState=collapsed") public String getLastName() { return lastName; } // NO Tunable annotation for the setter method. public void setLastName(String newLastName) { lastName = newLastName; }
Module: work-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>work-api</artifactId> </dependency>
Modifier and Type | Fields and Description |
---|---|
static String |
BOTH_CONTEXT |
static String |
GUI_CONTEXT |
static String |
NOGUI_CONTEXT |
Modifier and Type | Optional Element and Description |
---|---|
String |
context
Returns the context that this
Tunable is meant for. |
String |
dependsOn
To add a dependency between two or more
Tunables , where
the display of one Tunable depends on the
the state of another. |
String |
description
Mandatory, human-readable label identifying the Tunable as displayed to a user.
|
String |
exampleStringValue
Optional example string for use in scripting environments.
|
String |
format
Provides a decimal format string suitable for
DecimalFormat . |
double |
gravity
Returns the gravity used to place the tunable in the panel.
|
String[] |
groups
Used to define the presentation grouping of the Tunable.
|
String[] |
listenForChange
Returns a list of Tunable field/method names that will trigger this Tunable to be updated.
|
String |
longDescription
Optional human-readable description that can provide more complete description of
that the
Tunable does and the implication of various settings. |
String |
params
Returns a key1=value1;key2=value2;...;keyN=valueN type string.
|
boolean |
required
If this parameter is required, return true, otherwise it is assumed that a null (or empty) value
is properly handled by the Task.
|
String |
tooltip
Optional human-readable description that can provide more complete description of
that the
Tunable does and the implication of various settings. |
boolean |
xorChildren
Returns true if this field or method is used to control the display of other
Tunable s. |
String |
xorKey
Returns a value that matches one of the values found in a different Tunable
annotated field or method that returns
true for the xorChildren()
method. |
public static final String GUI_CONTEXT
public static final String NOGUI_CONTEXT
public static final String BOTH_CONTEXT
public abstract String description
public abstract String longDescription
Tunable
does and the implication of various settings. This
is intended for scripting use.public abstract String tooltip
Tunable
does and the implication of various settings. In
general, this might be implemented in a GUI as a tooltip, but might also be used
for other purposes.public abstract String exampleStringValue
Tunable
, and ideally should
represent a usable value at execution time, though the latter is not a requirement.public abstract String[] groups
@Tunable(description="write your last name", group={"Company","Department","Office"}) public String lastName = "Smith";The lastName
Tunable
will be nested within the "Company", "Department",
"Office", and "Identity" groups. The order of groups defines their nesting.
Example:
@Tunable(description="write your first name", groups={"Company","Department","Office","Identity"}) public String firstName = "John"; @Tunable(description="write the name of your office", groups={"Company","Department","Office"}) public String officeName = "Cytoscape Development";
Tunable
to "Office" group. The "Identity" group will
appear with officeName within the "Office" group.public abstract double gravity
Tunable
s
are sorted in ascending order based on their gravity values. The first Tunable
to show will be the one with lowest value.Tunable
public abstract boolean xorChildren
Tunable
s. The other Tunables in question are matched according
the groups()
value and the xorKey()
of the other
Tunables. See xorKey()
for a full example.Tunable
s.public abstract String xorKey
true
for the xorChildren()
method.
Example :
@Tunable(description="Distance measure", group={"Measure"}, xorChildren=true) public ListSingleSelectionBased on the selection made in the "chooser"chooser = new ListSingleSelection ("Metric","English"); @Tunable(description="Metric distances", group={"Measure","Metric"}, xorKey="Metric") public ListSingleSelection metric = new ListSingleSelection ("millimeter","meter","kilometer"); @Tunable(description="English distances", group={"Measure","English"}, xorKey="English") public ListSingleSelection english = new ListSingleSelection ("inch","yard","mile");
Tunable
, either the "metric" or
the "english" Tunable
will be displayed, not both.
The xorKey
value must match one of the
values specified in the xorChildren
Tunable
.public abstract String dependsOn
Tunables
, where
the display of one Tunable
depends on the
the state of another.
Here is an example of how to add dependencies between Tunables
:
@Tunable(description="Type") public boolean type = false; @Tunable(description="Host name",dependsOn="type=true") public String hostname="";So
hostname
will only be displayed if type
is set to "true"public abstract String params
BoundedDouble
,
BoundedFloat
, and similar classes.
Tunable
within a group, if nothing has
been specified, "vertical" will be the default. These values will be in a 1-to-1
correspondence with the strings in the "group" array. Excess values will be ignored.
Tunable
's group has to be
displayed or not in the titleBorder
of the JPanel
representing this group.
Tunable
's JPanel will be
collapsible. The value must be either "collapsed" or "uncollapsed" indicating the
initial display state.
public abstract String[] listenForChange
@Tunable(description="A") public String getA() { return a; } public void setA(String a) { this.a = a; } // listenForChange="A" means that the value of this // Tunable will be updated every time A is changed. @Tunable(description="B",listenForChange="A") public String getB() { if ( a.equals("somethingSpecial") ) return "hooray."; else return b; } public void setB(String b) { this.b = b; }
public abstract String context
Tunable
is meant for. Must be one of "gui", "nogui", or
"both". If no value is provided, "both" is assumed. If the context is set to "gui", then this
Tunable
will only be available through GUI implementations, and will not be made available
to command-line or headless implementations. If the context is set to "nogui", then this
Tunable
will not be available through the GUI.public abstract boolean required
public abstract String format
DecimalFormat
. This allows default
values and ranges to be rationally presented to users. Note that this is only for presentation
purposes and does not effect the underlying values. Also, not all Tunables will respect format.
At this point, only numeric and bounded numeric tunables respect format.Copyright 2011-2015 Cytoscape Consortium. All rights reserved.