|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.ejs.control.GroupControl
public class GroupControl
A base class to group several ControlElements, connect them to one or more target objects in a unified form, and build a graphic interface with all of them.
Field Summary | |
---|---|
static int |
DEBUG_ALL
|
static int |
DEBUG_CONTROL
|
static int |
DEBUG_CONTROL_VERBOSE
|
static int |
DEBUG_DRAWING
|
static int |
DEBUG_DRAWING_VERBOSE
|
static int |
DEBUG_ELEMENTS
|
static int |
DEBUG_NONE
|
static int |
DEBUG_SET_AND_GET
|
static int |
DEBUG_SYSTEM
|
static int |
DEBUG_SYSTEM_VERBOSE
|
protected java.awt.Frame |
replaceOwnerFrame
|
protected java.lang.String |
replaceOwnerName
|
Constructor Summary | |
---|---|
GroupControl()
The default constructor. |
|
GroupControl(java.lang.Object _target)
The constructor. |
|
GroupControl(java.lang.Object _simulation,
java.lang.String _replaceName,
java.awt.Frame _replaceOwnerFrame)
A specialized constructor for Ejs use. |
Method Summary | |
---|---|
ControlElement |
add(java.lang.String _type)
Creates a new ControlElement |
ControlElement |
add(java.lang.String _type,
java.lang.String _propertyList)
Creates a new ControlElement and gives it a name |
void |
addListener(java.lang.String _name,
java.lang.String _method)
|
void |
addListener(java.lang.String _name,
java.lang.String _method,
java.lang.Object _anObject)
Instructs the group to invoke a method (with an optional parameter) when a variable changes. |
ControlElement |
addNamed(java.lang.String _type,
java.lang.String _name)
Creates a new ControlElement with a given name This is a special feature that is used by LauncherApplet, so that if the name coincides with a given one, a Frame becomes a Panel, so that it can be captured! |
ControlElement |
addObject(java.lang.Object _object,
java.lang.String _type)
Creates a new ControlElement that wrapps an existing object If the object is not of the right class it will print a warning and ignore the object provided. |
ControlElement |
addObject(java.lang.Object _object,
java.lang.String _type,
java.lang.String _propertyList)
Creates a new ControlElement that wrapps an existing object If the object is not of the right class it will print a warning and ignore the object provided. |
void |
addTarget(java.lang.String _name,
java.lang.Object _target)
Adds an object to be controlled. |
void |
appendPrefixPath(java.lang.String _prefix)
Adds a prefix 'path' for unqualified elements. |
void |
clear()
Destroy all elements |
void |
clearPrefixPath()
Clears the list of default package name for unqualified elements |
void |
clearVariables()
Clears all variables |
void |
destroy(ControlElement _element)
Completely destroy a ControlElement |
void |
destroy(java.lang.String _name)
Completely destroy a ControlElement by name |
boolean |
getBoolean(java.lang.String _name)
A convenience method to get a value as a boolean |
java.awt.Component |
getComponent(java.lang.String _name)
Returns the component of a control element by name |
java.awt.Container |
getContainer(java.lang.String _name)
Returns the container of a control element by name |
ControlElement |
getControl(java.lang.String _name)
|
int |
getDebugLevel()
Returns the current debug level |
java.util.Vector<java.lang.String> |
getDefaultPrefixList()
Returns the list (actually, a vector) of prefix |
double |
getDouble(java.lang.String _name)
A convenience method to get a value as a double |
ControlElement |
getElement(java.lang.String _name)
Returns a control element by name |
int |
getInt(java.lang.String _name)
A convenience method to get a value as an int |
static XML.ObjectLoader |
getLoader()
Returns an XML.ObjectLoader to save and load data for this object. |
java.lang.Object |
getObject(java.lang.String _name)
A convenience method to get a value as an Object |
java.awt.Frame |
getOwnerFrame()
Returns the owner frame for all subsequent Dialogs |
java.awt.Frame |
getReplaceOwnerFrame()
Returns the replacement for the owner frame for all subsequent Dialogs |
java.lang.String |
getReplaceOwnerName()
Returns the name of the replacement for the owner frame for all subsequent Dialogs |
Simulation |
getSimulation()
Returns the simulation under which the control is running This is used to up date the simulation whenever an Element changes a variable (See variableChanged in ControlElement |
java.lang.String |
getString(java.lang.String _name)
A convenience method to get a value as a String |
java.lang.Object |
getTarget(java.lang.String _name)
Returns one of the registered target objects |
java.awt.Container |
getTopLevelAncestor(java.lang.String _name)
Returns the top-level ancestor of an element (either the containing Window or Applet), or null if the element has not been added to any container. |
Value |
getValue(java.lang.String _name)
Returns the group value of a variable. |
java.awt.Component |
getVisual(java.lang.String _name)
Returns the visual of a control element by name |
void |
initialize()
Initialize all elements |
boolean |
isVariableRegistered(java.lang.String _name)
Tells whether a variable is associated to any element. |
GroupVariable |
registerVariable(java.lang.String _name,
ControlElement _element,
int _index,
Value _value)
Associates an element internal value with a variable name. |
void |
removeTarget(java.lang.String _name)
Removes a target object |
void |
rename(ControlElement _element,
java.lang.String _name)
Renaming a ControlElement |
void |
replaceOwnerFrame(java.lang.String _replaceName,
java.awt.Frame _replaceOwnerFrame)
|
void |
reset()
Reset all elements |
void |
setActive(boolean _active)
Set the active state of all elements |
void |
setDebugLevel(int _level)
Sets the debug level |
void |
setOwnerFrame(java.awt.Frame _frame)
Sets the owner frame for all subsequent Dialogs |
void |
setSimulation(Simulation _sim)
Sets the simulation under which the control is running This is used to up date the simulation whenever an Element changes a variable (See variableChanged in ControlElement) |
void |
setValue(java.lang.String _name,
boolean _value)
A convenience method to set a value to a boolean |
void |
setValue(java.lang.String _name,
double _value)
A convenience method to set a value to a double |
void |
setValue(java.lang.String _name,
int _value)
A convenience method to set a value to an int |
void |
setValue(java.lang.String _name,
java.lang.Object _value)
A convenience method to set a value to any Object |
void |
setValue(java.lang.String _name,
java.lang.String _value)
A convenience method to set a value to a String |
void |
setValue(java.lang.String _name,
Value _value)
Sets the group value for a variable. |
void |
update()
Refresh all elements |
void |
variableChanged(GroupVariable _variable,
ControlElement _element,
Value _value)
Invoked by ControlElements when their internal variables change. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEBUG_NONE
public static final int DEBUG_SET_AND_GET
public static final int DEBUG_ELEMENTS
public static final int DEBUG_CONTROL
public static final int DEBUG_CONTROL_VERBOSE
public static final int DEBUG_DRAWING
public static final int DEBUG_DRAWING_VERBOSE
public static final int DEBUG_SYSTEM
public static final int DEBUG_SYSTEM_VERBOSE
public static final int DEBUG_ALL
protected java.lang.String replaceOwnerName
protected java.awt.Frame replaceOwnerFrame
Constructor Detail |
---|
public GroupControl()
public GroupControl(java.lang.Object _target)
_target
- public GroupControl(java.lang.Object _simulation, java.lang.String _replaceName, java.awt.Frame _replaceOwnerFrame)
_simulation
- _replaceName
- _replaceOwnerFrame
- Method Detail |
---|
public void setOwnerFrame(java.awt.Frame _frame)
Frame
- _frame The frame that should own next Dialogs
(if there are Dialogs in this group)public java.awt.Frame getOwnerFrame()
public void replaceOwnerFrame(java.lang.String _replaceName, java.awt.Frame _replaceOwnerFrame)
public java.lang.String getReplaceOwnerName()
public java.awt.Frame getReplaceOwnerFrame()
public void clearPrefixPath()
public void appendPrefixPath(java.lang.String _prefix)
String
- _prefix The prefix to be added to listpublic java.util.Vector<java.lang.String> getDefaultPrefixList()
public void setSimulation(Simulation _sim)
Simulation
- _sim The simulationpublic Simulation getSimulation()
public void setDebugLevel(int _level)
int
- _level The minimim level that should
produce debug mesagges. Must be one of
DEBUG_NONE, DEBUG_SET_AND_GET, DEBUG_ELEMENTS,
DEBUG_ALL=255public int getDebugLevel()
public java.lang.Object getTarget(java.lang.String _name)
String
- _name The name given to the target when it was addedpublic void addTarget(java.lang.String _name, java.lang.Object _target)
String
- _name A name to refer to the targetObject
- _target A target objectpublic void removeTarget(java.lang.String _name)
public void setValue(java.lang.String _name, Value _value)
String
- _name The variable nameValue
- _value The value as a Value
objectpublic Value getValue(java.lang.String _name)
String
- _name The variable name
Value
object of the variable. If the
variable has never been set, it returns null.public GroupVariable registerVariable(java.lang.String _name, ControlElement _element, int _index, Value _value)
String
- _name The name of the variableControlElement
- _element The element to be registeredint
- _index An indentifier for the element internal valueValue
- _value The initial value if the variable doesn't already existpublic boolean isVariableRegistered(java.lang.String _name)
ControlElement
- _element The element to be includedString
- _variable The variable namepublic void variableChanged(GroupVariable _variable, ControlElement _element, Value _value)
public void addListener(java.lang.String _name, java.lang.String _method)
public void addListener(java.lang.String _name, java.lang.String _method, java.lang.Object _anObject)
String
- _name The name of the variable that may changeString
- _method The method that should be called in the controlledObject
- _anObject the object to pass in the special case the method is method(#CONTROL#)
object.public void rename(ControlElement _element, java.lang.String _name)
String
- _name The new name for the element.public final ControlElement addNamed(java.lang.String _type, java.lang.String _name)
String
- _type The class name of the new element.String
- _name The name of the new element.public final ControlElement add(java.lang.String _type)
String
- _type The class name of the new element.
If it is not qualified, then it is given the prefix (see above)public final ControlElement add(java.lang.String _type, java.lang.String _propertyList)
String
- _type The class name of the new element.
If it is not qualified, then it is given the default prefix (see above)String
- _propertyList A list of properties and Values
to be set (see ControlElement.setProperties())public final ControlElement addObject(java.lang.Object _object, java.lang.String _type)
Object
- _object The element to be wrappedString
- _type The class name of the new element.
If it is not qualified, then it is given the prefix (see above)public ControlElement addObject(java.lang.Object _object, java.lang.String _type, java.lang.String _propertyList)
Object
- _object The element to be wrappedString
- _type The class name of the new element.
If it is not qualified, then it is given the prefix (see above)String
- _propertyList A list of properties and Values
to be set (see ControlElement.setProperties())public ControlElement getElement(java.lang.String _name)
String
- _name The name of the control element
public ControlElement getControl(java.lang.String _name)
public java.awt.Component getVisual(java.lang.String _name)
String
- _name The name of the control element
public java.awt.Component getComponent(java.lang.String _name)
String
- _name The name of the control element
public java.awt.Container getContainer(java.lang.String _name)
String
- _name The name of the control element
public void destroy(java.lang.String _name)
String
- _name The name of the ControlElement to be destroyedpublic void destroy(ControlElement _element)
ControlElement
- _element The ControlElement to be destroyedpublic void reset()
public void initialize()
public void update()
public void setActive(boolean _active)
public void clearVariables()
public void clear()
public java.awt.Container getTopLevelAncestor(java.lang.String _name)
String
- _name The name of the control element
public void setValue(java.lang.String _name, boolean _value)
_name
- _value
- public void setValue(java.lang.String _name, int _value)
_name
- _value
- public void setValue(java.lang.String _name, double _value)
_name
- _value
- public void setValue(java.lang.String _name, java.lang.String _value)
_name
- _value
- public void setValue(java.lang.String _name, java.lang.Object _value)
_name
- _value
- public boolean getBoolean(java.lang.String _name)
_name
- public int getInt(java.lang.String _name)
_name
- public double getDouble(java.lang.String _name)
_name
- public java.lang.String getString(java.lang.String _name)
_name
- public java.lang.Object getObject(java.lang.String _name)
_name
- public static XML.ObjectLoader getLoader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |