Class BasicTunableHandlerFactory<T extends TunableHandler>

java.lang.Object
org.cytoscape.work.BasicTunableHandlerFactory<T>
Type Parameters:
T - The specific type of the TunableHandler.
All Implemented Interfaces:
TunableHandlerFactory<T>
Direct Known Subclasses:
SimpleGUITunableHandlerFactory

public class BasicTunableHandlerFactory<T extends TunableHandler> extends Object implements TunableHandlerFactory<T>
A convenience implementation of TunableHandlerFactory that will construct a TunableHandler of the specified type given the TunableHandler in question has at least two constructors, one with Field, Object, Tunable parameters and the other with Method, Method, Object, Tunable parameters. If you need additional parameters to construct your TunableHandler, then it is probably best to implement the TunableHandlerFactory interface directly!

Cytoscape Backwards Compatibility (Abstract Class): This class is abstract and meant to be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

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>
  • Constructor Details

    • BasicTunableHandlerFactory

      public BasicTunableHandlerFactory(Class<T> tunableHandlerClass, Class<?>... allowedTypes)
      Constructor.
      Parameters:
      tunableHandlerClass - The type of the TunableHandler to be created.
      allowedTypes - The object types that the TunableHandler is associated with. For instance, an IntegerTunableHandler might allow Integer.class and int.class.
  • Method Details

    • createTunableHandler

      public final T createTunableHandler(Field field, Object instance, Tunable tunable)
      Description copied from interface: TunableHandlerFactory
      This method returns a TunableHandler for a field annotated as a Tunable if this factory can produce an appropriate handler for this type of field. If the factory cannot produce an appropriate handler, it will return null.
      Specified by:
      createTunableHandler in interface TunableHandlerFactory<T extends TunableHandler>
      Parameters:
      field - Field that needs to be handled.
      instance - The object on which we want to read/write the Field.
      tunable - Tunable that contains all the information concerning the user interface.
      Returns:
      T The newly constructed TunableHandler or null if this factory can't handle a field of the specified type.
    • createTunableHandler

      public final T createTunableHandler(Method getter, Method setter, Object instance, Tunable tunable)
      Description copied from interface: TunableHandlerFactory
      This method returns a TunableHandler for a method annotated as a Tunable if this factory can produce an appropriate handler for this type of method. If the factory cannot produce an appropriate handler, it will return null.
      Note that 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. See Tunable for an example.
      Specified by:
      createTunableHandler in interface TunableHandlerFactory<T extends TunableHandler>
      Parameters:
      getter - A getter method that has been annotated with Tunable.
      setter - A setter method that matches the getter method.
      instance - The object on which we want to invoke the getter and setter methods.
      tunable - The Tunable that contains all the information concerning the user interface from the getter method.
      Returns:
      T The newly constructed TunableHandler or null if this factory can't handle the specified type.