Module interacto.java.api
Package io.github.interacto.instrument
Class InstrumentImpl<T extends WidgetBinding<? extends Command>>
- java.lang.Object
-
- io.github.interacto.instrument.InstrumentImpl<T>
-
- All Implemented Interfaces:
Instrument<T>,Modifiable,Preferenciable,Reinitialisable
public abstract class InstrumentImpl<T extends WidgetBinding<? extends Command>> extends Object implements Instrument<T>
The base class of an instrument.- Author:
- Arnaud BLOUIN
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactivatedDefines whether the instrument is activated.protected List<T>bindingsThe widget bindings of the instrument.protected Set<io.reactivex.disposables.Disposable>disposablesprotected booleanmodifiedDefined whether the instrument has been modified.
-
Constructor Summary
Constructors Constructor Description InstrumentImpl()Creates and initialises the instrument.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddBinding(T binding)Adds the given widget binding to the list of bindings of the instrument.protected voidaddDisposable(io.reactivex.disposables.Disposable disposable)The instrument can store disposable objects that will be flushed on un-installation.voidclearEvents()Stops the interactions of the instrument and clears all its events waiting for a process.protected abstract voidconfigureBindings()Initialises the bindings of the instrument.intgetNbWidgetBindings()List<T>getWidgetBindings()booleanhasWidgetBindings()booleanisActivated()booleanisModified()voidload(boolean generalPreferences, String nsURI, Element meta)Loads data save in an XML document.voidreinit()Reinitialises the object.voidsave(boolean generalPreferences, String nsURI, Document document, Element root)Saves the parameters of the instrument into an XML tag.voidsetActivated(boolean toBeActivated)Activates or deactivates the instrument.voidsetModified(boolean isModified)Sets the Modifiable object as modified.voiduninstallBindings()
-
-
-
Field Detail
-
activated
protected boolean activated
Defines whether the instrument is activated.
-
bindings
protected final List<T extends WidgetBinding<? extends Command>> bindings
The widget bindings of the instrument.
-
modified
protected boolean modified
Defined whether the instrument has been modified.
-
disposables
protected final Set<io.reactivex.disposables.Disposable> disposables
-
-
Method Detail
-
addDisposable
protected void addDisposable(io.reactivex.disposables.Disposable disposable)
The instrument can store disposable objects that will be flushed on un-installation. This method stores a disposable object.- Parameters:
disposable- The disposable object to store. Nothing done if null.
-
getNbWidgetBindings
public int getNbWidgetBindings()
- Specified by:
getNbWidgetBindingsin interfaceInstrument<T extends WidgetBinding<? extends Command>>- Returns:
- The number of widget bindings that compose the instrument.
-
hasWidgetBindings
public boolean hasWidgetBindings()
- Specified by:
hasWidgetBindingsin interfaceInstrument<T extends WidgetBinding<? extends Command>>- Returns:
- True: the instrument has at least one widget binding. False otherwise.
-
getWidgetBindings
public List<T> getWidgetBindings()
- Specified by:
getWidgetBindingsin interfaceInstrument<T extends WidgetBinding<? extends Command>>- Returns:
- The widget bindings that compose the instrument. Cannot be null.
-
configureBindings
protected abstract void configureBindings()
Initialises the bindings of the instrument.
-
addBinding
public void addBinding(T binding)
Adds the given widget binding to the list of bindings of the instrument.- Parameters:
binding- The widget binding to add. If null, nothing is done.
-
clearEvents
public void clearEvents()
Description copied from interface:InstrumentStops the interactions of the instrument and clears all its events waiting for a process.- Specified by:
clearEventsin interfaceInstrument<T extends WidgetBinding<? extends Command>>
-
isActivated
public boolean isActivated()
- Specified by:
isActivatedin interfaceInstrument<T extends WidgetBinding<? extends Command>>- Returns:
- True if the instrument is activated.
-
setActivated
public void setActivated(boolean toBeActivated)
Description copied from interface:InstrumentActivates or deactivates the instrument.- Specified by:
setActivatedin interfaceInstrument<T extends WidgetBinding<? extends Command>>- Parameters:
toBeActivated- True = activation.
-
save
public void save(boolean generalPreferences, String nsURI, Document document, Element root)Description copied from interface:PreferenciableSaves the parameters of the instrument into an XML tag.- Specified by:
savein interfacePreferenciable- Parameters:
generalPreferences- True: this operation is called to save the general preferences of the interactive system. Otherwise, it is called to save a presentation in a document. This parameter is useful when different information must be saved during a presentation backup or a general preferences backup.nsURI- The namespace that must be added to tags corresponding to the instrument's parameters.document- The XML document.root- The root element that will contains the instrument's parameters.
-
load
public void load(boolean generalPreferences, String nsURI, Element meta)Description copied from interface:PreferenciableLoads data save in an XML document.- Specified by:
loadin interfacePreferenciable- Parameters:
generalPreferences- True: this operation is called to load the general preferences of the interactive system. Otherwise, it is called to load a presentation in a document. This parameter is useful when different information must be loaded during a presentation backup or a general preferences backup.nsURI- The namespace that must be added to tags corresponding to the instrument's parameters.meta- The meta data element.
-
isModified
public boolean isModified()
- Specified by:
isModifiedin interfaceModifiable- Returns:
- True: the object has been modified. False otherwise.
-
setModified
public void setModified(boolean isModified)
Description copied from interface:ModifiableSets the Modifiable object as modified.- Specified by:
setModifiedin interfaceModifiable- Parameters:
isModified- True: the element is will tagged as modified.
-
reinit
public void reinit()
Description copied from interface:ReinitialisableReinitialises the object.- Specified by:
reinitin interfaceReinitialisable
-
uninstallBindings
public void uninstallBindings()
- Specified by:
uninstallBindingsin interfaceInstrument<T extends WidgetBinding<? extends Command>>
-
-