|
Cytoscape 2.6.2 (c) 2006,2007 ISB, MSKCC, UCSD | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cytoscape.layout.Tunable
public class Tunable
Tunables are typed objects that maintain properties and an easy way to generate a settings panel to allow user manipulation of them.
A Tunable is a utility that serves two important functions:
Tunables were originally written to support the needs of users
of Cytoscape's various layout algorithms (see CyLayoutAlgorithm
)
to access the various tunable parameters in the algorithms. In general,
Tunables are collected together by the ModuleProperties
system.
See LayoutProperties
as a good example.
INTEGER
, DOUBLE
, BOOLEAN
, STRING
,
NODEATTRIBUTE
, EDGEATTRIBUTE
, LIST
, GROUP
,
or BUTTON
.INTEGER
: Integer
DOUBLE
: Double
BOOLEAN
: Boolean
STRING
: String
NODEATTRIBUTE
: String
, or if MULTISELECT
, comma-separated list of Strings representing the selected attributesEDGEATTRIBUTE
: String
, or if MULTISELECT
, comma-separated list of Strings representing the selected attributesLIST
: Integer
, or if MULTISELECT
, comma-separated list of integers representing the selected attributesINTEGER
or DOUBLE
tunables,
the lowerBound is an optional Integer
or Double
value representing
the smallest integer or double that constitutes a legal
input. For LIST
tunables, the lowerBound is an array of Objects representing the list to choose from, and for
NODEATTRIBUTE
, and EDGEATTRIBUTE
tunables, lowerBound is an optional array of String
s that will
prefix the list of attributes. This allows users to provide their own overrides into the list. For GROUP
tunables,
that have the COLLAPSABLE
flag set, this is a Boolean value that indicates whether the group is collapsed or expanded.INTEGER
or DOUBLE
tunables,
the upperBound is an optional Integer
or Double
value representing
the larget integer or double that constitutes a legal
input. IMMUTABLE
, which prevents user entry; MULTISELECT
, which presents lists as a JList
rather
than JComboBox
; NOINPUT
, which indicates that this tunable should not be
presented to the user; NUMERICATTRIBUTE
, which indicates for attribute lists that only numeric attributes
should be used; and USESLIDER
, which suggests to the UI to use a slider to present this value.
The most common usage of Tunables is to provide a list of values that influences the presentation or calculation of
a layout, clustering algorithm, etc. When combined with LayoutProperties
, tunables provide a very quick way
to put together a user interface and get the results from it. A common approach would be for the algorithm to
include a section of code that creates all of the Tunables associated with the algorithm's parameters. For example
this section from csplugins.layout.algorithms.force#ForceDirectedLayout
:
layoutProperties = new LayoutProperties("my_module");
layoutProperties.add(new Tunable("standard", "Standard settings",
Tunable.GROUP, new Integer(2)));
layoutProperties.add(new Tunable("partition", "Partition graph before layout",
Tunable.BOOLEAN, new Boolean(true)));
layoutProperties.add(new Tunable("selected_only", "Only layout selected nodes",
Tunable.BOOLEAN, new Boolean(false)));
layoutProperties.add(new Tunable("force_alg_settings", "Algorithm settings",
Tunable.GROUP, new Integer(5), new Boolean(true), null, Tunable.COLLAPSABLE));
layoutProperties.add(new Tunable("defaultSpringCoefficient", "Default Spring Coefficient",
Tunable.DOUBLE, new Double(defaultSpringCoefficient)));
layoutProperties.add(new Tunable("defaultSpringLength", "Default Spring Length",
Tunable.DOUBLE, new Double(defaultSpringLength)));
layoutProperties.add(new Tunable("defaultNodeMass", "Default Node Mass",
Tunable.DOUBLE, new Double(defaultNodeMass)));
layoutProperties.add(new Tunable("numIterations", "Number of Iterations",
Tunable.INTEGER, new Integer(numIterations)));
layoutProperties.add(new Tunable("integrator", "Integration algorithm to use",
Tunable.LIST, new Integer(0),
(Object) integratorArray, (Object) null, 0));
The values are read in an update method:
Tunable t = layoutProperties.get("selected_only");
if ((t != null) && (t.valueChanged() || force))
selectedOnly = ((Boolean) t.getValue()).booleanValue();
t = layoutProperties.get("partition");
if ((t != null) && (t.valueChanged() || force))
setPartition(t.getValue().toString());
t = layoutProperties.get("defaultSpringCoefficient");
if ((t != null) && (t.valueChanged() || force))
defaultSpringCoefficient = ((Double) t.getValue()).doubleValue();
t = layoutProperties.get("defaultSpringLength");
if ((t != null) && (t.valueChanged() || force))
defaultSpringLength = ((Double) t.getValue()).doubleValue();
t = layoutProperties.get("defaultNodeMass");
if ((t != null) && (t.valueChanged() || force))
defaultNodeMass = ((Double) t.getValue()).doubleValue();
t = layoutProperties.get("numIterations");
if ((t != null) && (t.valueChanged() || force))
numIterations = ((Integer) t.getValue()).intValue();
t = layoutProperties.get("integrator");
if ((t != null) && (t.valueChanged() || force)) {
if (((Integer) t.getValue()).intValue() == 0)
integrator = new RungeKuttaIntegrator();
else if (((Integer) t.getValue()).intValue() == 1)
integrator = new EulerIntegrator();
else
return;
}
LayoutProperties
has a method LayoutProperties.getTunablePanel()
that can be called to
return a JPanel
that contains all of the Tunable panels. These are combined into
a dialog to allow users to set and update the values. By using addTunableValueListener(cytoscape.layout.TunableListener)
a
caller can be notified when a user changes a value.
Field Summary | |
---|---|
static int |
BOOLEAN
Tunables of type BOOLEAN allow data entry of a boolean value: this is presented to the user as a simple check box. |
static int |
BUTTON
The BUTTON Tunable provides a simple button to be presented to the user: the caller can provide an ActionListener to be called when the button is selected. |
static int |
COLLAPSABLE
If the COLLAPSABLE flag is set for a GROUP Tunable, then this Group of Tunables should be collapsable, and will be rendered with a button to allow collapse/expand. |
static int |
DOUBLE
Tunables of type DOUBLE allow data entry of double values, possibly bounded between lowerBound and upperBound: if the flag USESLIDER is set,
and the caller provides both lower and upper bounds,
the user is presented with a slider interface. |
static int |
EDGEATTRIBUTE
Tunables of type EDGEATTRIBUTE present a user with a list of the currently defined edge attributes for selection: if the flag NUMERICATTRIBUTE is set, only
integer or double attributes are shown, and if
the MULTISELECT flag is set, the user
is presented with a list from which multiple
values can be selected, otherwise, the user
is presented with a combo box. |
static int |
GROUP
The GROUP Tunable provides a mechanism to improve the asthetics of the interface: the value of the GROUP Tunable indicates the number of the subsequent tunables that should be grouped together. |
static int |
IMMUTABLE
If the IMMUTABLE flag is set, then the Tunable is presented as usual, with both label and user widget, but the user widget is disabled. |
static int |
INTEGER
Tunables of type INTEGER allow data entry of integer values, possibly bounded between lowerBound and upperBound: if the flag USESLIDER is set,
and the caller provides both lower and upper bounds,
the user is presented with a slider interface. |
static int |
LIST
Tunables of type LIST present a user with a list of values to select from: if the MULTISELECT flag is
set, the user is presented with a list
from which multiple values can be selected,
otherwise, the user is presented with a
combo box. |
static int |
MULTISELECT
For LIST, NODEATTRIBUTE, or EDGEATTRIBUTE types, use a list widget that supports multiselect rather than a combo box. |
static int |
NODEATTRIBUTE
Tunables of type NODEATTRIBUTE present a user with a list of the currently defined node attributes for selection: if the flag NUMERICATTRIBUTE is set, only
integer or double attributes are shown, and if
the MULTISELECT flag is set, the user
is presented with a list from which multiple
values can be selected, otherwise, the user
is presented with a combo box. |
static int |
NOINPUT
When the NOINPUT flag is set, this Tunable is not presented to the user, it is only used for property settings. |
static int |
NUMERICATTRIBUTE
For attributes, indicate that the list should be restricted to integer or float attributes. |
static int |
STRING
Tunables of type STRING allow data entry of text. |
static int |
USESLIDER
For INTEGER or DOUBLE tunables, preferentially use a slider widget -- this will *only* take effect if the upper and lower bounds are provided. |
Constructor Summary | |
---|---|
Tunable(String name,
String desc,
int type,
Object value)
Constructor to create a Tunable with no bounds information, and no flag. |
|
Tunable(String name,
String desc,
int type,
Object value,
int flag)
Constructor to create a Tunable with no bounds information, but with a flag. |
|
Tunable(String name,
String desc,
int type,
Object value,
Object lowerBound,
Object upperBound,
int flag)
Constructor to create a Tunable with bounds information as well as a flag. |
|
Tunable(String name,
String desc,
int type,
Object value,
Object lowerBound,
Object upperBound,
int flag,
boolean immutable)
Deprecated. Use the IMMUTABLE flag directly rather than this special constructor. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
This method is public as a byproduct of the implementation. |
void |
addTunableValueListener(TunableListener listener)
Method to add a value listener to this Tunable. |
boolean |
checkFlag(int flag)
This method is used to check the value of a flag. |
void |
clearFlag(int flag)
This method can be used to clear a flag for this Tunable |
void |
focusGained(FocusEvent ev)
This method is public as a byproduct of the implementation. |
void |
focusLost(FocusEvent ev)
Document listener routines to handle bounds checking |
String |
getDescription()
Method to return the description for this Tunable. |
Object |
getLowerBound()
Method to get the lowerBound for this Tunable. |
String |
getName()
Method to return a string representation of this Tunable, which is essentially its name. |
JPanel |
getPanel()
This method returns a JPanel suitable for inclusion in the LayoutSettingsDialog to represent this Tunable. |
int |
getType()
Method to return the type of this Tunable. |
Object |
getUpperBound()
Method to get the upperBound for this Tunable. |
Object |
getValue()
This method returns the current value. |
void |
itemStateChanged(ItemEvent e)
This method is public as a byproduct of the implementation. |
void |
removeTunableValueListener(TunableListener listener)
Method to remove a value listener from this Tunable. |
void |
setFlag(int flag)
This method can be used to set a flag for this Tunable |
void |
setImmutable(boolean immutable)
This method can be used to set the "immutable" boolean, which essentially get's mapped to the appropriate mechanism for allowing a value to be editted. |
void |
setLowerBound(Object lowerBound)
Method to set the lowerBound for this Tunable. |
void |
setUpperBound(Object upperBound)
Method to set the upperBound for this Tunable. |
void |
setValue(Object value)
This method is used to set the value for this Tunable. |
void |
stateChanged(ChangeEvent e)
This method is public as a byproduct of the implementation. |
String |
toString()
Method to return a string representation of this Tunable, which is essentially its name. |
void |
updateValue()
This method is called to extract the user-entered data from the JPanel and store it as our value. |
void |
updateValueListeners()
Method to call all of the value listeners. |
boolean |
valueChanged()
Returns the changed state of the value. |
void |
valueChanged(ListSelectionEvent e)
This method is public as a byproduct of the implementation. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int INTEGER
USESLIDER
is set,
and the caller provides both lower and upper bounds,
the user is presented with a slider interface.
public static final int DOUBLE
USESLIDER
is set,
and the caller provides both lower and upper bounds,
the user is presented with a slider interface.
public static final int BOOLEAN
public static final int STRING
public static final int NODEATTRIBUTE
NUMERICATTRIBUTE
is set, only
integer or double attributes are shown, and if
the MULTISELECT
flag is set, the user
is presented with a list from which multiple
values can be selected, otherwise, the user
is presented with a combo box.
public static final int EDGEATTRIBUTE
NUMERICATTRIBUTE
is set, only
integer or double attributes are shown, and if
the MULTISELECT
flag is set, the user
is presented with a list from which multiple
values can be selected, otherwise, the user
is presented with a combo box.
public static final int LIST
MULTISELECT
flag is
set, the user is presented with a list
from which multiple values can be selected,
otherwise, the user is presented with a
combo box.
public static final int GROUP
public static final int BUTTON
public static final int NOINPUT
public static final int NUMERICATTRIBUTE
public static final int MULTISELECT
public static final int USESLIDER
public static final int IMMUTABLE
public static final int COLLAPSABLE
Constructor Detail |
---|
public Tunable(String name, String desc, int type, Object value)
name
- The name of the Tunabledesc
- The description of the Tunabletype
- Integer value that represents the type of
the Tunable. The type not only impact the
way that the value is interpreted, but also
the component used for the LayoutSettingsDialogvalue
- The initial (default) value of the Tunablepublic Tunable(String name, String desc, int type, Object value, int flag)
name
- The name of the Tunabledesc
- The description of the Tunabletype
- Integer value that represents the type of
the Tunable. The type not only impact the
way that the value is interpreted, but also
the component used for the LayoutSettingsDialogvalue
- The initial (default) value of the Tunableflag
- The initial value of the flag. This can be
used to indicate that this tunable is not user
changeable (e.g. debug), or to indicate if there
is a specific type for the attributes.public Tunable(String name, String desc, int type, Object value, Object lowerBound, Object upperBound, int flag)
name
- The name of the Tunabledesc
- The description of the Tunabletype
- Integer value that represents the type of
the Tunable. The type not only impact the
way that the value is interpreted, but also
the component used for the LayoutSettingsDialogvalue
- The initial (default) value of the Tunable. This
is a String in the case of an EDGEATTRIBUTE or
NODEATTRIBUTE tunable, it is an Integer index
a LIST tunable.lowerBound
- An Object that either represents the lower
bounds of a numeric Tunable or an array of values
for an attribute (or other type of) list.upperBound
- An Object that represents the upper bounds
of a numeric Tunable.flag
- The initial value of the flag. This can be
used to indicate that this tunable is not user
changeable (e.g. debug), or to indicate if there
is a specific type for the attributes.public Tunable(String name, String desc, int type, Object value, Object lowerBound, Object upperBound, int flag, boolean immutable)
name
- The name of the Tunabledesc
- The description of the Tunabletype
- Integer value that represents the type of
the Tunable. The type not only impact the
way that the value is interpreted, but also
the component used for the LayoutSettingsDialogvalue
- The initial (default) value of the Tunable. This
is a String in the case of an EDGEATTRIBUTE or
NODEATTRIBUTE tunable, it is an Integer index
a LIST tunable.lowerBound
- An Object that either represents the lower
bounds of a numeric Tunable or an array of values
for an attribute (or other type of) list.upperBound
- An Object that represents the upper bounds
of a numeric Tunable.flag
- The initial value of the flag. This can be
used to indicate that this tunable is not user
changeable (e.g. debug), or to indicate if there
is a specific type for the attributes.immutable
- If 'true', this Tunable is immutableMethod Detail |
---|
public void setFlag(int flag)
flag
- integer value the contains the flag to set.public void clearFlag(int flag)
flag
- integer value the contains the flag to be cleared.public boolean checkFlag(int flag)
flag
- integer value the contains the flag to be checked.
public void setImmutable(boolean immutable)
immutable
- 'true' if this is an immutable valuepublic void setValue(Object value)
value
- Object (usually String) containing the value to be setpublic Object getValue()
public boolean valueChanged()
public void setLowerBound(Object lowerBound)
lowerBound
- the new lowerBound for the tunablepublic Object getLowerBound()
public void setUpperBound(Object upperBound)
upperBound
- the new upperBound for the tunablepublic Object getUpperBound()
public String toString()
toString
in class Object
public String getName()
public int getType()
public String getDescription()
public void addTunableValueListener(TunableListener listener)
listener
- the TunableListener to addpublic void removeTunableValueListener(TunableListener listener)
listener
- the TunableListener to removepublic void updateValueListeners()
public JPanel getPanel()
public void updateValue()
public void focusLost(FocusEvent ev)
focusLost
in interface FocusListener
public void focusGained(FocusEvent ev)
focusGained
in interface FocusListener
public void stateChanged(ChangeEvent e)
stateChanged
in interface ChangeListener
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void itemStateChanged(ItemEvent e)
itemStateChanged
in interface ItemListener
public void valueChanged(ListSelectionEvent e)
valueChanged
in interface ListSelectionListener
|
www.cytoscape.org | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |