plugins.adufour.vars.gui.swing
Class SequenceViewer

java.lang.Object
  extended by plugins.adufour.vars.gui.VarEditor<V>
      extended by plugins.adufour.vars.gui.swing.SwingVarEditor<icy.sequence.Sequence>
          extended by plugins.adufour.vars.gui.swing.SequenceViewer
All Implemented Interfaces:
icy.sequence.SequenceListener, java.util.EventListener, VarListener<icy.sequence.Sequence>

public class SequenceViewer
extends SwingVarEditor<icy.sequence.Sequence>
implements icy.sequence.SequenceListener


Field Summary
 
Fields inherited from class plugins.adufour.vars.gui.VarEditor
variable
 
Constructor Summary
SequenceViewer(Var<icy.sequence.Sequence> variable)
           
SequenceViewer(VarMutable variable)
          Constructs a new SequenceViewer using a mutable variable of type sequence.
 
Method Summary
protected  void activateListeners()
          Activates listeners on the editor component.
protected  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.
protected  void deactivateListeners()
          Deactivates listeners on the editor component.
 double getComponentVerticalResizeFactor()
          Indicates whether and how this component should resize vertically if the container panel allows resizing.
 icy.gui.component.sequence.SequencePreviewPanel getEditorComponent()
           
 boolean isComponentResizeable()
           
 void referenceChanged(Var<icy.sequence.Sequence> source, Var<? extends icy.sequence.Sequence> oldReference, Var<? extends icy.sequence.Sequence> newReference)
          Called when the variable reference changes
 void sequenceChanged(icy.sequence.SequenceEvent sequenceEvent)
           
 void sequenceClosed(icy.sequence.Sequence sequence)
           
protected  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<icy.sequence.Sequence> source, icy.sequence.Sequence oldValue, icy.sequence.Sequence newValue)
          Called when the value of the source variable changes
 
Methods inherited from class plugins.adufour.vars.gui.swing.SwingVarEditor
getPreferredSize, isComponentEnabled, isComponentOpaque, setComponentToolTipText, setEditorEnabled
 
Methods inherited from class plugins.adufour.vars.gui.VarEditor
dispose, getComponentHorizontalResizeFactor, getVariable, isComponentFocusable, isNameVisible, setComponentFocusable, setComponentResizeable, setEnabled, setNameVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequenceViewer

public SequenceViewer(Var<icy.sequence.Sequence> variable)

SequenceViewer

public SequenceViewer(VarMutable variable)
Constructs a new SequenceViewer using a mutable variable of type sequence.

Parameters:
variable - the mutable variable containing the Sequence to display
Throws:
java.lang.ClassCastException - if the given variable is not of type Sequence
See Also:
Var.getType()
Method Detail

createEditorComponent

protected 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 SwingVarEditor<icy.sequence.Sequence>
Returns:
a graphical input component that is linked to the variable and can be used to view or adjust the variable value

activateListeners

protected void activateListeners()
Description copied from class: VarEditor
Activates listeners on the editor component. Listeners should be activated here rather than in the VarEditor.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.

Specified by:
activateListeners in class VarEditor<icy.sequence.Sequence>

deactivateListeners

protected void deactivateListeners()
Description copied from class: VarEditor
Deactivates listeners on the editor component. Listeners should be deactivated here rather than in the VarEditor.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.

Specified by:
deactivateListeners in class VarEditor<icy.sequence.Sequence>

getEditorComponent

public icy.gui.component.sequence.SequencePreviewPanel getEditorComponent()
Overrides:
getEditorComponent in class SwingVarEditor<icy.sequence.Sequence>
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)

updateInterfaceValue

protected void updateInterfaceValue()
Description copied from class: VarEditor
Updates the graphical interface component to reflect the new value of the underlying variable (accessible via the Var.getValue() method).

Specified by:
updateInterfaceValue in class VarEditor<icy.sequence.Sequence>

isComponentResizeable

public boolean isComponentResizeable()
Overrides:
isComponentResizeable in class VarEditor<icy.sequence.Sequence>
Returns:
true if the container panel should allow this component to be resized, false otherwise

getComponentVerticalResizeFactor

public double getComponentVerticalResizeFactor()
Description copied from class: VarEditor
Indicates whether and how this component should resize vertically if the container panel allows resizing. If multiple components in the same panel support resizing, the amount of extra space available will be shared between all components depending on the returned weight (from 0 for no resizing to 1 for maximum resizing).
By default, this value is 0.0 (no vertical resizing)

Overrides:
getComponentVerticalResizeFactor in class VarEditor<icy.sequence.Sequence>
Returns:
a value from 0 (no resize allowed) to 1 (resize as much as possible)

valueChanged

public void valueChanged(Var<icy.sequence.Sequence> source,
                         icy.sequence.Sequence oldValue,
                         icy.sequence.Sequence newValue)
Description copied from interface: VarListener
Called when the value of the source variable changes

Specified by:
valueChanged in interface VarListener<icy.sequence.Sequence>
Overrides:
valueChanged in class VarEditor<icy.sequence.Sequence>
Parameters:
source - the variable firing the listener
oldValue - the old variable value
newValue - the new variable value

referenceChanged

public void referenceChanged(Var<icy.sequence.Sequence> source,
                             Var<? extends icy.sequence.Sequence> oldReference,
                             Var<? extends icy.sequence.Sequence> newReference)
Description copied from interface: VarListener
Called when the variable reference changes

Specified by:
referenceChanged in interface VarListener<icy.sequence.Sequence>
Overrides:
referenceChanged in class VarEditor<icy.sequence.Sequence>
Parameters:
source - the variable firing the listener
oldReference - the old variable reference
newReference - the new variable reference

sequenceClosed

public void sequenceClosed(icy.sequence.Sequence sequence)
Specified by:
sequenceClosed in interface icy.sequence.SequenceListener

sequenceChanged

public void sequenceChanged(icy.sequence.SequenceEvent sequenceEvent)
Specified by:
sequenceChanged in interface icy.sequence.SequenceListener