fr.emn.examples.icondraw
Class DTool

java.lang.Object
  extended byfr.emn.reactiveinput.AbstractDevice
      extended byfr.emn.examples.icondraw.DTool
All Implemented Interfaces:
Device, Processor
Direct Known Subclasses:
DBrushTool

public abstract class DTool
extends AbstractDevice

This is an abstract graphical tool. Update() method is break into 4 methods.


Field Summary
 In activate
           
 In use
           
 
Fields inherited from class fr.emn.reactiveinput.AbstractDevice
currIndex, ins, outs
 
Fields inherited from interface fr.emn.reactiveinput.Device
AUTO_PROPERTIES
 
Method Summary
 void close()
          Add closing code here if needed.
 Device copy()
          Is isCopiable() returns true, copies the device by calling DeviceUtilities.defaultCopy().
 boolean getActivated()
           
 boolean getScreenCoordinates()
           
 boolean hasExternalOutput()
          Specifies whether this device has external (implicit) output or not.
 boolean isActive()
           
 boolean isUsed()
           
 Processor open(OpenContext context)
          Subclass this method if you want to specialize data processing, or if you want to perform some initializations before running the device.
abstract  void paint(java.awt.Graphics2D g)
          Used for tool feedback
 void setActivated(boolean active)
           
 void setScreenCoordinates(boolean value)
           
 void toLocal(java.awt.Point p)
          Use this method to convert a point into local coordinates.
abstract  void update_abort()
          Aborts an interaction.
abstract  boolean update_begin()
          Initiates an interaction.
abstract  void update_end()
          Ends and validates an interaction.
abstract  void update_value(boolean force)
          Update interaction values.
 void update()
          Updates device's output values.
 
Methods inherited from class fr.emn.reactiveinput.AbstractDevice
addIn, addIn, addOut, doDisable, doEnable, finalize, getError, getIndex, getInfo, getIns, getName, getOuts, getProperties, hasExternalInput, init, insertAt, insertAtEnd, insertBefore, isCopiable, isEnabled, isOpenable, setEnabled, setInfo, setInfo, setLastError, setName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activate

public final In activate

use

public final In use
Method Detail

close

public void close()
Description copied from class: AbstractDevice
Add closing code here if needed.

Specified by:
close in interface Device
Overrides:
close in class AbstractDevice

copy

public Device copy()
Description copied from class: AbstractDevice
Is isCopiable() returns true, copies the device by calling DeviceUtilities.defaultCopy(). Returns null if isCopiable() returns false.

Subclass this method if you want to provide another strategy.

Specified by:
copy in interface Device
Overrides:
copy in class AbstractDevice

getScreenCoordinates

public boolean getScreenCoordinates()

hasExternalOutput

public boolean hasExternalOutput()
Description copied from class: AbstractDevice
Specifies whether this device has external (implicit) output or not. Returns false by default.

Return false if the device has no border effects. Most of input and processing devices are in this case.

Return true if the device has border effects, such as graphical feedback, or control of some external value. Examples of devices with external output are application-interfacing devices and all user feedback devices.

This method can be used by the editor for the device's graphical representation. However there is at now no clear definition of what is external output.

Specified by:
hasExternalOutput in interface Device
Overrides:
hasExternalOutput in class AbstractDevice

isActive

public boolean isActive()

isUsed

public boolean isUsed()

open

public Processor open(OpenContext context)
Description copied from class: AbstractDevice
Subclass this method if you want to specialize data processing, or if you want to perform some initializations before running the device.

By default, open() does nothing and returns the device itself as the Processor (or null if it is not openable): AbstractDevice implements both Device and Processor interfaces, so that you can add processing code directly into the device.

If you want to add specialization features, subclass this method to return a specific processor implementation depending on your device configuration.

Example :

public Processor getProcessor() { if (super.open() == null) return null; // Select the right processor if (in2.isValid()) { return new twoParamProcessor(in1, in2, out); else return new oneParamProcessor(in1, out); }

In this method, you may also perform all necessary pre-running initialization. If initialization fails, return null even if isOpenable() returns true.

In all cases, return null if isOpenable() returns false.

Specified by:
open in interface Device
Overrides:
open in class AbstractDevice
See Also:
Processor, Device.open()

paint

public abstract void paint(java.awt.Graphics2D g)
Used for tool feedback


setScreenCoordinates

public void setScreenCoordinates(boolean value)

toLocal

public void toLocal(java.awt.Point p)
Use this method to convert a point into local coordinates. If screenCoordinates is false, no changes are made.


update

public void update()
Description copied from class: AbstractDevice
Updates device's output values.

Subclass init() and update() methods if you want the device to process the data itself. Otherwise, subclass getProcessor() method to use extern processors.

Specified by:
update in interface Processor
Overrides:
update in class AbstractDevice
See Also:
Processor.update()

setActivated

public void setActivated(boolean active)

getActivated

public boolean getActivated()

update_abort

public abstract void update_abort()
Aborts an interaction.


update_begin

public abstract boolean update_begin()
Initiates an interaction.

You can refuse starting an interaction by returning false (e.g. if you do not have enough data). This method will be re-checked the next tick.


update_end

public abstract void update_end()
Ends and validates an interaction.


update_value

public abstract void update_value(boolean force)
Update interaction values.

This method is called during an interaction every time a value may have changed.

Additionnaly, it is called with first=true just after interaction has been initiated (provided that update_begin returned true) and just before interaction has been aborted or validated.