plugins.adufour.vars.gui.swing
Class SwingVarEditor<V>

java.lang.Object
  extended by plugins.adufour.vars.gui.VarEditor<V>
      extended by plugins.adufour.vars.gui.swing.SwingVarEditor<V>
Type Parameters:
V - the type of variable to edit, see Var
All Implemented Interfaces:
VarListener<V>
Direct Known Subclasses:
Button, ChannelSelector, CheckBox, ComboBox, FileChooser, FilesChooser, Label, MutableVarEditor, PluginChooser, SequenceChooser, SequenceList, SequenceViewer, Slider, Spinner, SwimmingObjectChooser, TextArea, TextField

public abstract class SwingVarEditor<V>
extends VarEditor<V>

Swing implementation of the VarEditor

Author:
Alexandre Dufour

Field Summary
 
Fields inherited from class plugins.adufour.vars.gui.VarEditor
variable
 
Constructor Summary
SwingVarEditor(Var<V> variable)
           
 
Method Summary
protected abstract  javax.swing.JComponent createEditorComponent()
          Creates the component to display on the graphical user interface, allowing the user to modify the variable's value via appropriate listeners (listeners should be added or removed via the VarEditor.activateListeners() and VarEditor.deactivateListeners() methods).
In order to allow multiple editors to modify the same variable, this method should always return a newly constructed component (by Swing design, a same component can only be used once per interface).
Once created, the component is stored in the final VarEditor.editorComponent field to avoid unnecessary re-creations (e.g.
 javax.swing.JComponent getEditorComponent()
           
 java.awt.Dimension getPreferredSize()
           
 boolean isComponentEnabled()
           
 boolean isComponentOpaque()
           
 void setComponentToolTipText(java.lang.String s)
           
protected  void setEditorEnabled(boolean enabled)
           
 
Methods inherited from class plugins.adufour.vars.gui.VarEditor
activateListeners, deactivateListeners, dispose, getComponentHorizontalResizeFactor, getComponentVerticalResizeFactor, getVariable, isComponentFocusable, isComponentResizeable, isNameVisible, referenceChanged, setComponentFocusable, setComponentResizeable, setEnabled, setNameVisible, updateInterfaceValue, valueChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingVarEditor

public SwingVarEditor(Var<V> variable)
Method Detail

createEditorComponent

protected abstract javax.swing.JComponent createEditorComponent()
Description copied from class: VarEditor
Creates the component to display on the graphical user interface, allowing the user to modify the variable's value via appropriate listeners (listeners should be added or removed via the VarEditor.activateListeners() and VarEditor.deactivateListeners() methods).
In order to allow multiple editors to modify the same variable, this method should always return a newly constructed component (by Swing design, a same component can only be used once per interface).
Once created, the component is stored in the final VarEditor.editorComponent field to avoid unnecessary re-creations (e.g. during interface refresh). To bypass this optimization and force the creation of a new component for every interface refresh, consider overriding the VarEditor.getEditorComponent() method.

WARNING: this method is called within the VarEditor.VarEditor(Var) constructor, therefore all instance fields besides the final VarEditor.variable field will be null until this method returns.

Specified by:
createEditorComponent in class VarEditor<V>
Returns:
a graphical input component that is linked to the variable and can be used to view or adjust the variable value

getEditorComponent

public javax.swing.JComponent getEditorComponent()
Overrides:
getEditorComponent in class VarEditor<V>
Returns:
the graphical component used to view or modify the variable's value. By default, the returned component is the one created by the VarEditor.createEditorComponent() method during object construction. This method can be overridden to return a new component for each call (note however that this method may be called many times, e.g. during interface refresh)

getPreferredSize

public java.awt.Dimension getPreferredSize()
Specified by:
getPreferredSize in class VarEditor<V>
Returns:
The preferred dimension of the local VarEditor.editorComponent. By default, this method calls the component's JComponent.getPreferredSize() method. However, this method can be overridden to provide a custom dimension, e.g. to fix the size of the component regardless of its content

isComponentEnabled

public boolean isComponentEnabled()
Specified by:
isComponentEnabled in class VarEditor<V>
Returns:
true if the editor is enabled, i.e. whether the graphical component is active and may receive user input. This method can be overridden to force the editor status to a given state

isComponentOpaque

public boolean isComponentOpaque()
Specified by:
isComponentOpaque in class VarEditor<V>
Returns:
true if the editor is opaque, or false if the component is transparent. This method can be overridden to force the opacity to a given state

setEditorEnabled

protected void setEditorEnabled(boolean enabled)
Specified by:
setEditorEnabled in class VarEditor<V>

setComponentToolTipText

public void setComponentToolTipText(java.lang.String s)
Specified by:
setComponentToolTipText in class VarEditor<V>