Cytoscape 3.0.1 API

org.cytoscape.work
Annotation Type Tunable


@Retention(value=RUNTIME)
@Target(value={FIELD,METHOD})
public @interface Tunable

An annotation type that can be applied to public fields or a methods in a Task object that allows the Task to be configured with user supplied information. Tunable annotations allow Tasks 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 Tunables in the eventual user interface. These parameters are documented below.
Here is an example of how to use a 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.
Here is an example of how to use a 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.
        @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;
  }
 


Cytoscape Backwards Compatibility (API Interface): We expect that this interface will be used but not implemented by developers using this interface. As such, we reserve the right to add methods to the interface as part of minor version upgrades. We will not remove methods for any changes other than major version upgrades.

Optional Element Summary
 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[] 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 params
          Returns a key1=value1;key2=value2;...;keyN=valueN type string.
 boolean xorChildren
          Returns true if this field or method is used to control the display of other Tunables.
 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.
 

description

public abstract String description
Mandatory, human-readable label identifying the Tunable as displayed to a user.

Default:
""

groups

public abstract String[] groups
Used to define the presentation grouping of the Tunable. By default a Tunable belongs to the top level group. Example:
        @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";
        

Here we add a second item (firstName) to the "Identity" group and then add the officeName Tunable to "Office" group. The "Identity" group will appear with officeName within the "Office" group.

Default:
{}

xorChildren

public abstract boolean xorChildren
Returns true if this field or method is used to control the display of other Tunables. The other Tunables in question are matched according the groups() value and the xorKey() of the other Tunables. See xorKey() for a full example.

Returns:
true if this field or method is used to control the display of other Tunables.
Default:
false

xorKey

public abstract 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. Example :
        @Tunable(description="Distance measure", group={"Measure"}, xorChildren=true)
        public ListSingleSelection 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");
 
Based on the selection made in the "chooser" 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.

Default:
""

dependsOn

public abstract String dependsOn
To add a dependency between two or more 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"

Default:
""

params

public abstract String params
Returns a key1=value1;key2=value2;...;keyN=valueN type string. To include commas, semicolons or backslashes in a value you must escape it with a leading backslash. Possible keys (which must consist of letters only) are
Note: Blanks/spaces in values are significant!

Default:
""

listenForChange

public abstract String[] listenForChange
Returns a list of Tunable field/method names that will trigger this Tunable to be updated. For instance if Tunable B wants to react to a change in Tunable A, then setting the listenForChange parameter is one mechanism for achieving this. The listenForChange parameter will trigger the update method on the TunableHandler to be called, which will cause B to be updated. Here is an example:
 @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;
 }
 

Returns:
a list of Tunable field/method names that will trigger this Tunable to be updated.
Default:
{}

Cytoscape 3.0.1 API

Copyright 2011 Cytoscape Consortium. All rights reserved.