Package nzilbb.converter
Class Converter
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Panel
-
- java.applet.Applet
-
- javax.swing.JApplet
-
- nzilbb.util.GuiProgram
-
- nzilbb.converter.Converter
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
public abstract class Converter extends GuiProgram
Base class for converters, which implements a number of common functions for convenience.- Author:
- Robert Fromont robert@fromont.net.nz
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
-
Field Summary
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description Converter()
Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ParameterSet
configureFromCommandLine(ParameterSet parameters, Schema schema)
Sets any parameter values that might have been specified on the the command line - i.e.void
convert(File inputFile)
Converts a file.void
convert(Vector<File> inputFiles)
Converts all files by deserializing all first, and then serializing all resulting graphs at once.void
convertBatch(Vector<File> files)
Converts a batch of files.void
convertFiles()
Converts the files in the files list.ParameterSet
deserializationParameters(ParameterSet parameters)
Adjust the parameters for deserialization.Graph[]
deserialize(Vector<NamedStream> streams, Schema schema)
Deserializes a file to one or more graphs.ParameterSet
deserializerConfiguration(ParameterSet config)
Adjust the configuration of the deserializer.Boolean
getBatchMode()
Getter forbatchMode
: Whether to start processing immediately (true) or wait until the user presses "Convert" (false).abstract GraphDeserializer
getDeserializer()
Gets the deserializer thatconvert(File)
uses.Boolean
getHelp()
Getter forhelp
: Display help info about available serialization parameters.String[]
getLayersToSerialize()
Specifies which layers should be given to the serializer.Schema
getSchema()
Specify the schema to used byconvert(File)
.abstract GraphSerializer
getSerializer()
Gets the serializer thatconvert(File)
uses.Boolean
getVerbose()
Getter forverbose
: Whether detailed verbose output is printed or not.String
help()
Generates help information.void
init()
void
processTranscripts(Graph[] transcripts)
Process the transcripts after they were deserialized, but before they're serialized.ParameterSet
serializerConfiguration(ParameterSet config)
Adjust the configuration of the serializer.void
setBatchMode(Boolean newBatchMode)
Setter forbatchMode
: Whether to start processing immediately (true) or wait until the user presses "Convert" (false).Converter
setHelp(Boolean newHelp)
Setter forhelp
: Display help info about available serialization parameters.Converter
setSwitch(String name, String value)
Specify the value for an extra switch, which will be passed to the deserializer and serializer.void
setVerbose(Boolean newVerbose)
Setter forverbose
: Whether detailed verbose output is printed or not.void
start()
-
Methods inherited from class nzilbb.util.GuiProgram
getDefaultHeight, getDefaultWidth, getDefaultWindowTitle, getParameterInfo, getUsage, getV, getVersion, interpretAppletParameters, interpretPropertiesParameters, mainRun, setDefaultHeight, setDefaultWidth, setDefaultWindowTitle, setUsage, setV, setVersion, wrap
-
Methods inherited from class javax.swing.JApplet
getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
-
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Method Detail
-
getHelp
public Boolean getHelp()
Getter forhelp
: Display help info about available serialization parameters.- Returns:
- Display help info about available serialization parameters.
-
setHelp
@Switch(value="Display help info about available serialization parameters", compulsory=false) public Converter setHelp(Boolean newHelp)
Setter forhelp
: Display help info about available serialization parameters.- Parameters:
newHelp
- Display help info about available serialization parameters.
-
getVerbose
public Boolean getVerbose()
Getter forverbose
: Whether detailed verbose output is printed or not.- Returns:
- Whether detailed verbose output is printed or not.
-
setVerbose
@Switch(value="Print verbose output", compulsory=false) public void setVerbose(Boolean newVerbose)
Setter forverbose
: Whether detailed verbose output is printed or not.- Parameters:
newVerbose
- Whether detailed verbose output is printed or not.
-
getBatchMode
public Boolean getBatchMode()
Getter forbatchMode
: Whether to start processing immediately (true) or wait until the user presses "Convert" (false).- Returns:
- Whether to start processing immediately (true) or wait until the user presses "Convert" (false).
-
setBatchMode
@Switch(value="Start processing immediately, rather than waiting for the user to press Convert", compulsory=false) public void setBatchMode(Boolean newBatchMode)
Setter forbatchMode
: Whether to start processing immediately (true) or wait until the user presses "Convert" (false).- Parameters:
newBatchMode
- Whether to start processing immediately (true) or wait until the user presses "Convert" (false).
-
getDeserializer
public abstract GraphDeserializer getDeserializer()
Gets the deserializer thatconvert(File)
uses.- Returns:
- The deserializer to use.
-
getSerializer
public abstract GraphSerializer getSerializer()
Gets the serializer thatconvert(File)
uses.- Returns:
- The serializer to use.
-
getLayersToSerialize
public String[] getLayersToSerialize()
Specifies which layers should be given to the serializer. The default implementaion returns only the "utterance" layer.- Returns:
- An array of layer IDs.
-
deserializerConfiguration
public ParameterSet deserializerConfiguration(ParameterSet config)
Adjust the configuration of the deserializer. Implementors can adjust the default configuration before it's applied. This method is invoked once for each input file.- Parameters:
config
- The default configuration.- Returns:
- The new configuration.
-
deserializationParameters
public ParameterSet deserializationParameters(ParameterSet parameters)
Adjust the parameters for deserialization. Implementors can adjust the default configuration before it's applied. This method is invoked once for each input file.- Parameters:
parameters
- The default parameters.- Returns:
- The new configuration.
-
serializerConfiguration
public ParameterSet serializerConfiguration(ParameterSet config)
Adjust the configuration of the serializer. Implementors can adjust the default configuration before it's applied. This method is invoked once for each input file.- Parameters:
config
- The default configuration.- Returns:
- The new configuration.
-
processTranscripts
public void processTranscripts(Graph[] transcripts)
Process the transcripts after they were deserialized, but before they're serialized. Implementors can rename speakers, adjust meta-data, or change the graph in any other way required before serialization.- Parameters:
transcripts
-
-
getSchema
public Schema getSchema()
Specify the schema to used byconvert(File)
.- Returns:
- The schema.
-
convert
public void convert(File inputFile) throws SerializationException, Exception
Converts a file. The default implementation uses a default schema, default settings for serializations, and serializes the "utterance" layer only.- Parameters:
inputFile
-- Throws:
Exception
SerializationException
-
convert
public void convert(Vector<File> inputFiles) throws SerializationException, Exception
Converts all files by deserializing all first, and then serializing all resulting graphs at once. The default implementation uses a default schema, default settings for serializations, and serializes the "utterance" layer only.- Parameters:
inputFiles
-- Throws:
Exception
SerializationException
-
deserialize
public Graph[] deserialize(Vector<NamedStream> streams, Schema schema) throws SerializationException, Exception
Deserializes a file to one or more graphs. The default implementation uses a default schema.- Parameters:
streams
- An input transcript and perhaps media streams.- Throws:
Exception
SerializationException
-
help
public String help()
Generates help information.- Returns:
- The help information for this converter, including general info, and info about the deserializer and serializer.
-
convertFiles
public void convertFiles()
Converts the files in the files list.
-
convertBatch
public void convertBatch(Vector<File> files)
Converts a batch of files.- Parameters:
files
-
-
configureFromCommandLine
public ParameterSet configureFromCommandLine(ParameterSet parameters, Schema schema)
Sets any parameter values that might have been specified on the the command line - i.e. that are in theGuiProgram.extraSwitches
map.- Parameters:
parameters
- The parameters to configure.schema
- The source of any layers specified.- Returns:
- The given parameter set.
-
setSwitch
public Converter setSwitch(String name, String value)
Specify the value for an extra switch, which will be passed to the deserializer and serializer.- Parameters:
name
- The switch name.value
- The value for the switch.- Returns:
- A reference to this object, so that calls can be stacked like a builder.
-
-