diva.sketch.toolbox
Class CompositeTransducer

java.lang.Object
  extended by diva.sketch.toolbox.CompositeTransducer
All Implemented Interfaces:
Transducer, ClipboardOwner, Transferable, Cloneable

public class CompositeTransducer
extends Object
implements Transducer, Cloneable

A composite class that can be used to multiplex between different transducers. This transducer supports the union of all the data flavors of the children.

Version:
$Revision: 1.3 $
Author:
Michael Shilman (michaels@eecs.berkeley.edu)

Constructor Summary
CompositeTransducer(Transducer[] children)
          This constructor should only be called once, to create the prototype object.
 
Method Summary
 Object getTransferData(DataFlavor flavor)
          Perform recognition on the sketch model and return the transfer data as a string, or as plain text (based on StringSelection's implementation of getTransferData();
 DataFlavor[] getTransferDataFlavors()
          Return the union of all the children's data flavors.
 boolean isDataFlavorSupported(DataFlavor in)
          Return whether any of the child transducers support the given flavor.
 void lostOwnership(Clipboard clipboard, Transferable contents)
          Do nothing.
 Transducer newInstance(SketchModel in)
          Apply the transducer to the given set of strokes by performing sketch recognition on the given strokes.
protected  void setSketchModel(SketchModel in)
          Set the sketch model for a new instance of the transducer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeTransducer

public CompositeTransducer(Transducer[] children)
This constructor should only be called once, to create the prototype object. From then on, the newInstance() method should be used to construct

Method Detail

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Return the union of all the children's data flavors.

Specified by:
getTransferDataFlavors in interface Transferable

getTransferData

public Object getTransferData(DataFlavor flavor)
                       throws UnsupportedFlavorException,
                              IOException
Perform recognition on the sketch model and return the transfer data as a string, or as plain text (based on StringSelection's implementation of getTransferData();

Specified by:
getTransferData in interface Transferable
Throws:
UnsupportedFlavorException
IOException

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor in)
Return whether any of the child transducers support the given flavor.

Specified by:
isDataFlavorSupported in interface Transferable

lostOwnership

public void lostOwnership(Clipboard clipboard,
                          Transferable contents)
Do nothing.

Specified by:
lostOwnership in interface ClipboardOwner

newInstance

public Transducer newInstance(SketchModel in)
Apply the transducer to the given set of strokes by performing sketch recognition on the given strokes.

Specified by:
newInstance in interface Transducer

setSketchModel

protected void setSketchModel(SketchModel in)
                       throws RuntimeException
Set the sketch model for a new instance of the transducer. Called by newInstance(). Sets up the mapping of flavors to the transducers that support those transducers.

Throws:
RuntimeException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.