org.malai.instrument
Class Instrument

java.lang.Object
  extended by org.malai.instrument.Instrument
All Implemented Interfaces:
ActionHandler, Preferenciable, Modifiable, Reinitialisable, UndoHandler
Direct Known Subclasses:
Border, ExceptionsManager, Hand, Pencil, PreferencesSetter, ScaleRulersCustomiser, Scroller, TabSelector, TextSetter, WidgetInstrument, Zoomer

public abstract class Instrument
extends java.lang.Object
implements Preferenciable, Modifiable, Reinitialisable, ActionHandler

Defines an abstract model of an instrument.

This file is part of libMalai.
Copyright (c) 2009-2012 Arnaud BLOUIN

libMalan is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

libMalan is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Since:
0.1
Version:
0.2
Author:
Arnaud BLOUIN

Field Summary
protected  boolean activated
          Defines if the instrument is activated or not.
protected  java.util.List<Eventable> eventables
          The eventable objects that the instrument uses.
protected  java.util.List<Link<?,?,?>> links
          The links of the instrument.
protected  boolean modified
          Defined if the instrument has been modified.
 
Constructor Summary
Instrument()
          Creates and initialises the instrument.
 
Method Summary
 void addEventable(Eventable eventable)
          Binds the interaction of the links of the instrument to a Eventable object that produces events used by the interactions.
protected  void addLink(Link<?,?,?> link)
          Adds the given link to the list of links of the instrument.
 void clearEvents()
          Stops the interactions of the instrument and clears all its events waiting for a process.
 java.util.List<Link<?,?,?>> getLinks()
           
 int getSizeLinks()
           
 boolean hasLinks()
           
protected abstract  void initialiseLinks()
          Initialises the links of the instrument.
 void interimFeedback()
          Reinitialises the interim feedback of the instrument.
 boolean isActivated()
           
 boolean isModified()
           
 void load(boolean generalPreferences, java.lang.String nsURI, org.w3c.dom.Element meta)
          Loads data save in an XML document.
 void onActionAborted(Action action)
          Notifies the handler when the given action is aborted.
 void onActionAdded(Action action)
          Notifies the handler when the given action is added to the registry.
 void onActionCancelled(Action action)
          Notifies the handler when the given action is cancelled.
 void onActionDone(Action action)
          Notifies the handler when the given action is done.
 void onActionExecuted(Action action)
          Notifies the handler when the given action is executed.
 void onUndoableAdded(Undoable undoable)
          Actions to do when an undoable object is added to the undo register.
 void onUndoableRedo(Undoable undoable)
          Actions to do when an undoable object is redone.
 void onUndoableUndo(Undoable undoable)
          Actions to do when an undoable object is undone.
 void reinit()
          Reinitialises the object.
protected  boolean removeLink(Link<?,?,?> link)
          Removes the given link from the list of links of the instrument.
 void save(boolean generalPreferences, java.lang.String nsURI, org.w3c.dom.Document document, org.w3c.dom.Element root)
          Saves the parameters of the instrument into an XML tag.
 void setActivated(boolean activated)
          Activates or deactivates the instrument.
 void setModified(boolean modified)
          Sets the Modifiable object as modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activated

protected boolean activated
Defines if the instrument is activated or not.


links

protected java.util.List<Link<?,?,?>> links
The links of the instrument.


modified

protected boolean modified
Defined if the instrument has been modified.


eventables

protected java.util.List<Eventable> eventables
The eventable objects that the instrument uses.

Constructor Detail

Instrument

public Instrument()
Creates and initialises the instrument.

Since:
0.1
Method Detail

getSizeLinks

public int getSizeLinks()
Returns:
The number of links that compose the instrument.
Since:
0.2

hasLinks

public boolean hasLinks()
Returns:
True: the instrument has at least one link. False otherwise.
Since:
0.2

getLinks

public java.util.List<Link<?,?,?>> getLinks()
Returns:
The links that compose the instrument. Cannot be null.
Since:
0.2

initialiseLinks

protected abstract void initialiseLinks()
Initialises the links of the instrument.

Since:
0.2

addLink

protected void addLink(Link<?,?,?> link)
Adds the given link to the list of links of the instrument. Eventables object previously added to the instrument are added to the added link.

Parameters:
link - The link to add. If null, nothing is done.
Since:
0.2

removeLink

protected boolean removeLink(Link<?,?,?> link)
Removes the given link from the list of links of the instrument.

Parameters:
link - The link to remove.
Returns:
True: the given link has been removed. False otherwise.
Since:
0.2

addEventable

public void addEventable(Eventable eventable)
Binds the interaction of the links of the instrument to a Eventable object that produces events used by the interactions.

Parameters:
eventable - The eventable object that gathers event used by the interactions.
Since:
0.2

clearEvents

public void clearEvents()
Stops the interactions of the instrument and clears all its events waiting for a process.

Since:
0.2

isActivated

public boolean isActivated()
Returns:
True if the instrument is activated.

setActivated

public void setActivated(boolean activated)
Activates or deactivates the instrument.

Parameters:
activated - True = activation.

interimFeedback

public void interimFeedback()
Reinitialises the interim feedback of the instrument. Must be overridden.


save

public void save(boolean generalPreferences,
                 java.lang.String nsURI,
                 org.w3c.dom.Document document,
                 org.w3c.dom.Element root)
Description copied from interface: Preferenciable
Saves the parameters of the instrument into an XML tag.

Specified by:
save in interface Preferenciable
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,
                 java.lang.String nsURI,
                 org.w3c.dom.Element meta)
Description copied from interface: Preferenciable
Loads data save in an XML document.

Specified by:
load in interface Preferenciable
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.

setModified

public void setModified(boolean modified)
Description copied from interface: Modifiable
Sets the Modifiable object as modified.

Specified by:
setModified in interface Modifiable
Parameters:
modified - True: the element is will tagged as modified.

isModified

public boolean isModified()
Specified by:
isModified in interface Modifiable
Returns:
True: the object has been modified. False otherwise.

reinit

public void reinit()
Description copied from interface: Reinitialisable
Reinitialises the object.

Specified by:
reinit in interface Reinitialisable

onUndoableAdded

public void onUndoableAdded(Undoable undoable)
Description copied from interface: UndoHandler
Actions to do when an undoable object is added to the undo register.

Specified by:
onUndoableAdded in interface UndoHandler
Parameters:
undoable - The undoable object added to the undo register.

onUndoableUndo

public void onUndoableUndo(Undoable undoable)
Description copied from interface: UndoHandler
Actions to do when an undoable object is undone.

Specified by:
onUndoableUndo in interface UndoHandler
Parameters:
undoable - The undone object.

onUndoableRedo

public void onUndoableRedo(Undoable undoable)
Description copied from interface: UndoHandler
Actions to do when an undoable object is redone.

Specified by:
onUndoableRedo in interface UndoHandler
Parameters:
undoable - The redone object.

onActionCancelled

public void onActionCancelled(Action action)
Description copied from interface: ActionHandler
Notifies the handler when the given action is cancelled.

Specified by:
onActionCancelled in interface ActionHandler
Parameters:
action - The cancelled action.

onActionAdded

public void onActionAdded(Action action)
Description copied from interface: ActionHandler
Notifies the handler when the given action is added to the registry.

Specified by:
onActionAdded in interface ActionHandler
Parameters:
action - The added action.

onActionAborted

public void onActionAborted(Action action)
Description copied from interface: ActionHandler
Notifies the handler when the given action is aborted.

Specified by:
onActionAborted in interface ActionHandler
Parameters:
action - The aborted action.

onActionExecuted

public void onActionExecuted(Action action)
Description copied from interface: ActionHandler
Notifies the handler when the given action is executed.

Specified by:
onActionExecuted in interface ActionHandler
Parameters:
action - The executed action.

onActionDone

public void onActionDone(Action action)
Description copied from interface: ActionHandler
Notifies the handler when the given action is done.

Specified by:
onActionDone in interface ActionHandler
Parameters:
action - The action that ends.