|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectplugins.adufour.vars.gui.VarEditor<V>
V - the inner type of the variable controlled by this editorpublic abstract class VarEditor<V>
Class handling the graphical component used to view or modify the value of a Variable.
This class provides an abstraction layer between a Variable object (i.e. the model in the
MVC sense) and its associated graphical user interface. This abstraction has a number of
purposes:
Variables are detached from their graphical interface counterpart
(allowing any scenario from headless manipulation to multiple synchronized editors handling the
same Variable).Variable types (see links
below). However, these editors can be extended or replaced by more advanced ones to support
custom Variable types.
| Field Summary | |
|---|---|
protected Var<V> |
variable
The Variable handled by this editor. |
| Constructor Summary | |
|---|---|
VarEditor(Var<V> variable)
Constructs a new editor for the specified Variable. |
|
| Method Summary | |
|---|---|
protected abstract void |
activateListeners()
Activates listeners on the editor component. |
protected abstract java.lang.Object |
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 activateListeners() and 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 editorComponent field to avoid
unnecessary re-creations (e.g. |
protected abstract void |
deactivateListeners()
Deactivates listeners on the editor component. |
void |
dispose()
Dispose of resources (e.g. |
double |
getComponentHorizontalResizeFactor()
Indicates whether and how this component should resize horizontally if the container panel allows resizing. |
double |
getComponentVerticalResizeFactor()
Indicates whether and how this component should resize vertically if the container panel allows resizing. |
java.lang.Object |
getEditorComponent()
|
abstract java.awt.Dimension |
getPreferredSize()
|
Var<V> |
getVariable()
|
abstract boolean |
isComponentEnabled()
|
boolean |
isComponentFocusable()
|
abstract boolean |
isComponentOpaque()
|
boolean |
isComponentResizeable()
|
boolean |
isNameVisible()
|
void |
referenceChanged(Var<V> source,
Var<? extends V> oldReference,
Var<? extends V> newReference)
Called when the variable reference changes |
void |
setComponentFocusable(boolean componentFocusable)
|
void |
setComponentResizeable(boolean componentResizeable)
|
abstract void |
setComponentToolTipText(java.lang.String s)
|
protected abstract void |
setEditorEnabled(boolean enabled)
|
void |
setEnabled(boolean enabled)
Enables (or disables) the graphical component associated with the Variable object. |
void |
setNameVisible(boolean nameVisible)
|
protected abstract void |
updateInterfaceValue()
Updates the graphical interface component to reflect the new value of the underlying variable (accessible via the Var.getValue() method). |
void |
valueChanged(Var<V> source,
V oldValue,
V newValue)
Called when the value of the source variable changes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Var<V> variable
Variable handled by this editor. Note that multiple editors can handle the same
variable simultaneously.
| Constructor Detail |
|---|
public VarEditor(Var<V> variable)
Variable.
variable - | Method Detail |
|---|
protected abstract java.lang.Object createEditorComponent()
activateListeners() and deactivateListeners() methods).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
getEditorComponent() method. VarEditor(Var) constructor,
therefore all instance fields besides the final variable field will be
null until this method returns.
public java.lang.Object getEditorComponent()
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)public abstract java.awt.Dimension getPreferredSize()
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 contentpublic double getComponentHorizontalResizeFactor()
public double getComponentVerticalResizeFactor()
public abstract void setComponentToolTipText(java.lang.String s)
public Var<V> getVariable()
Variable controlled by this editorpublic abstract boolean isComponentEnabled()
public abstract boolean isComponentOpaque()
public boolean isComponentFocusable()
public boolean isComponentResizeable()
true if the container panel should allow this component to be resized,
false otherwisepublic boolean isNameVisible()
true if the name should appear alongside the editor component, false
otherwiseprotected abstract void activateListeners()
createEditorComponent() method, in order to allow the target containers to
optimize the scheduling and load of events to fire, and to ensure proper garbage collection
when the interface is destroyed.
protected abstract void deactivateListeners()
createEditorComponent() method, in order to allow the target containers
to optimize the scheduling and load of events to fire, and to ensure proper garbage
collection when the interface is destroyed.
public void setComponentFocusable(boolean componentFocusable)
componentFocusable - true if the editor is focusable (i.e. the component may capture a
mouse event and become active), false otherwisepublic void setComponentResizeable(boolean componentResizeable)
componentResizeable - true if the container panel should allow this component to be
resized, false otherwisepublic void setEnabled(boolean enabled)
Variable object.
This method should be used by the enclosing graphical interface instead of the traditional
JComponent.setEnabled(boolean), since listeners are automatically activated (or
deactivated) to avoid excessive event firing and ensure proper garbage collection.
protected abstract void setEditorEnabled(boolean enabled)
public void setNameVisible(boolean nameVisible)
nameVisible - true if the name should appear alongside the editor component,
false otherwiseprotected abstract void updateInterfaceValue()
Var.getValue() method).
public void dispose()
public void valueChanged(Var<V> source,
V oldValue,
V newValue)
VarListener
valueChanged in interface VarListener<V>source - the variable firing the listeneroldValue - the old variable valuenewValue - the new variable value
public void referenceChanged(Var<V> source,
Var<? extends V> oldReference,
Var<? extends V> newReference)
VarListener
referenceChanged in interface VarListener<V>source - the variable firing the listeneroldReference - the old variable referencenewReference - the new variable reference
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||