org.opensourcephysics.ejs.control.swing
Class ControlSwingElement

java.lang.Object
  extended by org.opensourcephysics.ejs.control.ControlElement
      extended by org.opensourcephysics.ejs.control.swing.ControlSwingElement
Direct Known Subclasses:
ControlBar, ControlButton, ControlCheckBox, ControlComboBox, ControlContainer, ControlDrawablesParent, ControlInputArea, ControlLabel, ControlNumberField, ControlRadioButton, ControlSlider, ControlTextArea, ControlTextField

public abstract class ControlSwingElement
extends ControlElement

ControlSwingElement is a base class for an object that displays a visual java.awt.Component.

See Also:
Component, ControlElement

Field Summary
static int ACTION_OFF
           
static int ACTION_ON
           
static int ACTION_PRESS
           
static int BACKGROUND
           
static int ENABLED
           
static int FONT
           
static int FOREGROUND
           
protected  java.awt.Component myVisual
           
static int NAME
           
static int PARENT
           
static int POSITION
           
static int SIZE
           
static int TOOLTIP
           
static int VISIBLE
           
 
Fields inherited from class org.opensourcephysics.ejs.control.ControlElement
ACTION, isUnderEjs, METHOD_FOR_VARIABLE, METHOD_TRIGGER, myGroup, myObject, myPropertiesTable, VARIABLE_CHANGED
 
Constructor Summary
ControlSwingElement(java.lang.Object _visual)
          Instantiates an object that wrapps a Swing JComponent of this type.
 
Method Summary
protected abstract  java.awt.Component createVisual(java.lang.Object _visual)
          Creates the visual component of this ControlElement, the one you can configure graphically.
 java.awt.Component getComponent()
          Returns the component of this ControlElement, the one that is added to a container.
protected  javax.swing.ImageIcon getIcon(java.lang.String _iconFile)
           
 java.lang.String getPropertyInfo(java.lang.String _property)
          Returns information about a given property.
 java.util.ArrayList<java.lang.String> getPropertyList()
          Returns the list of all properties that can be set for this ControlElement.
 Value getValue(int _index)
          Gets the value of any internal variable.
 java.awt.Component getVisual()
          Returns the visual component of this ControlElement, the one you can configure graphically.
 Value parseConstant(java.lang.String _propertyType, java.lang.String _value)
          Checks if a value can be considered a valid constant value for a property If not, it returns null, meaning the value can be considered to be a GroupVariable or a primitive constant.
 void setDefaultValue(int _index)
           
 void setValue(int _index, Value _value)
          Sets the value of the registered variables.
 
Methods inherited from class org.opensourcephysics.ejs.control.ControlElement
addAction, addAction, addAction, destroy, getGroup, getObject, getProperty, getSimulation, implementsProperty, initialize, invokeActions, invokeActions, isActive, propertyIsTypeOf, propertyType, removeAction, removeAction, reset, setActive, setGroup, setProperties, setProperty, toString, variableChanged, variableChangedDoNotUpdate, variablePropertiesClear, variablesChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME

public static final int NAME
See Also:
Constant Field Values

POSITION

public static final int POSITION
See Also:
Constant Field Values

PARENT

public static final int PARENT
See Also:
Constant Field Values

ENABLED

public static final int ENABLED
See Also:
Constant Field Values

VISIBLE

public static final int VISIBLE
See Also:
Constant Field Values

SIZE

public static final int SIZE
See Also:
Constant Field Values

FOREGROUND

public static final int FOREGROUND
See Also:
Constant Field Values

BACKGROUND

public static final int BACKGROUND
See Also:
Constant Field Values

FONT

public static final int FONT
See Also:
Constant Field Values

TOOLTIP

public static final int TOOLTIP
See Also:
Constant Field Values

ACTION_PRESS

public static final int ACTION_PRESS
See Also:
Constant Field Values

ACTION_ON

public static final int ACTION_ON
See Also:
Constant Field Values

ACTION_OFF

public static final int ACTION_OFF
See Also:
Constant Field Values

myVisual

protected java.awt.Component myVisual
Constructor Detail

ControlSwingElement

public ControlSwingElement(java.lang.Object _visual)
Instantiates an object that wrapps a Swing JComponent of this type. If an object of an appropriate class is provided, it is used as the visual.

Parameters:
_visual - The javax.swing.JComponent to be wrapped
Method Detail

createVisual

protected abstract java.awt.Component createVisual(java.lang.Object _visual)
Creates the visual component of this ControlElement, the one you can configure graphically. If an object of an appropriate class is provided, it is used as the visual.

Parameters:
_visual - The javax.swing.JComponent to be wrapped

getVisual

public final java.awt.Component getVisual()
Returns the visual component of this ControlElement, the one you can configure graphically.

Overrides:
getVisual in class ControlElement

getComponent

public java.awt.Component getComponent()
Returns the component of this ControlElement, the one that is added to a container.

Overrides:
getComponent in class ControlElement

getPropertyList

public java.util.ArrayList<java.lang.String> getPropertyList()
Returns the list of all properties that can be set for this ControlElement. Subclasses that add properties should extend this table. Order is crucial here: Both for the presentation in an editor (f.i. ViewElement) and for the setValue() method.

Specified by:
getPropertyList in class ControlElement

getPropertyInfo

public java.lang.String getPropertyInfo(java.lang.String _property)
Returns information about a given property. Subclasses that add properties should extend this table.
  • The first keyword is ALWAYS the type.
  • The keyword CONSTANT applies to properties that can not be changed using the setValue() methods
  • The keyword BASIC is used by Ejs to group properties to the left hand side of the property editor
  • The keyword HIDDEN is used by Ejs so that it does not display an entry in the editor field

    Specified by:
    getPropertyInfo in class ControlElement

  • parseConstant

    public Value parseConstant(java.lang.String _propertyType,
                               java.lang.String _value)
    Checks if a value can be considered a valid constant value for a property If not, it returns null, meaning the value can be considered to be a GroupVariable or a primitive constant. This method implements more cases than really needed for the base class. This is in order to save repetitions in swing subclasses.

    Overrides:
    parseConstant in class ControlElement
    Parameters:
    String - _property The property name
    String - _value The proposed value for the property

    setValue

    public void setValue(int _index,
                         Value _value)
    Sets the value of the registered variables. Subclasses with internal values should extend this

    Overrides:
    setValue in class ControlElement
    Parameters:
    _index - A keyword index that distinguishes among variables
    _value - The object holding the value for the variable.

    setDefaultValue

    public void setDefaultValue(int _index)
    Overrides:
    setDefaultValue in class ControlElement

    getValue

    public Value getValue(int _index)
    Gets the value of any internal variable. Subclasses with internal values should extend this

    Overrides:
    getValue in class ControlElement
    Parameters:
    _index - A keyword index that distinguishes among variables
    Returns:
    Value _value The object holding the value for the variable.

    getIcon

    protected javax.swing.ImageIcon getIcon(java.lang.String _iconFile)