anvil.annot
Class AnvilAnnotation

java.lang.Object
  |
  +--java.util.Observable
        |
        +--anvil.annot.AnvilAnnotation
All Implemented Interfaces:
Annotation

public class AnvilAnnotation
extends java.util.Observable
implements Annotation

This class stores the annotation of one video file.


Field Summary
 java.lang.String DEFAULT_NAME
           
static java.lang.String PRIMARY_TRACK
          Full class name
static java.lang.String RST_TRACK_NAME
          Standard name of the rhetorical structure track.
static java.lang.String SECONDARY_TRACK
          Full class name
static java.lang.String SINGLETON_TRACK
          Full class name
static java.lang.String SPAN_TRACK
          Full class name
static java.lang.String SPEECH_ANALYSIS_TRACK
          Full class name
static java.lang.String TRL_TRACK_NAME
          Standard name of the transliteration track.
static java.lang.String WAVEFORM_TRACK
          Full class name
 java.lang.String XML_BREATH
           
 java.lang.String XML_LONGBREATH
           
 java.lang.String XML_LONGPAUSE
           
 java.lang.String XML_PAUSE
           
 
Constructor Summary
AnvilAnnotation(AnnotationSpec s)
          Constructor for annotation object.
AnvilAnnotation(AnnotationSpec s, AnnotationProperties props)
           
 
Method Summary
 boolean addBookmark(Bookmark bm)
           
 void addVideoPath(java.lang.String path)
           
 void clearBookmarks()
          Clears list of bookmarks.
 AnnotationContainer clearContainer(java.lang.String name)
          Clears track of all elements.
 void clearIntensityData()
           
 void clearPitchData()
           
 void clearVideoPaths()
           
 void createManual(java.io.File dir)
          Creates HTML documentation in form of an annotation manual from the loaded specification.
protected  void finalize()
          Called by garbage collector.
 Bookmark findBookmark(java.lang.String name)
           
 java.lang.String[] findContainerNames()
          Returns all container names in a String array.
 java.lang.String[] findNodeNames(java.lang.String classname)
          Finds all annotation nodes (group or track) of the given class.
 java.util.List findNodes(java.lang.String classname)
          Finds nodes by class name.
 java.util.List findNonPrimaryTracks()
           
 java.lang.String[] findNonStaticTrackNames()
          Returns names of all non static tracks in a String array.
 java.lang.String[] findTrackNames()
          Returns all track names in a String array.
 java.lang.String[] findTrackNames(java.lang.String classname)
          Finds all (non-static) tracks of the given class.
 java.util.List findTracks(java.lang.String classname)
          Finds tracks by class name.
 AnnotationNode getAnnotationNode(java.lang.String name)
          Returns annotation node with name if it exists, null otherwise.
 java.util.List getBookmarks()
           
 AnnotationContainer getContainer(java.lang.String name)
          Returns container with name if it exists, null otherwise.
 java.io.File getFullPath(java.lang.String file)
          If given path is not absolute, returns absolute path by gluing the given path to the path of the annotation.
 GroupNode getGroup(java.lang.String name)
          Returns group with name if it exists, null otherwise.
 java.util.List getGroups()
          Returns a list of all group nodes.
 java.io.File getIntensityFile()
           
 java.lang.String getIntensityTrack()
           
 javax.media.Time getMaxEndTime()
          Computes maximum end time across all tracks.
 java.util.List getMissing()
          Returns list of missing files (pitch or intensity) after loading.
 java.lang.String getName()
          Returns file name (without full path) or DEFAULT_NAME if no path is specified yet.
 java.util.AbstractList getNodes()
          Returns list of all annotation nodes.
 java.io.File getPath()
           
 java.io.File getPitchFile()
          Returns path where this annotation is saved or null if annotation has never been saved.
 java.lang.String getPitchTrack()
           
 AnnotationProperties getProperties()
           
 GroupNode getRoot()
          Returns the group node that lies at the top of the track/group hierarchy.
 anvil.annot.meta.SessionData getSessionData()
          Returns session meta-data.
 AnnotationSet getSet(java.lang.String name)
          Returns set with name if it exists, null otherwise.
 java.util.List getSets()
          Returns a list of all annotation sets.
 AnnotationSpec getSpec()
          Returns annotation specification object.
 Track getTrack(java.lang.String name)
          Returns track with name if it exists, null otherwise.
 java.util.List getTracks()
          Returns a list of all (non-static) tracks.
 java.util.List getVideoPaths()
          Returns a list of strings which are the video file names.
 boolean hasWaveform()
          Returns whether the annotation contains a waveform.
 void importTextgridFile(java.io.File file, java.lang.String trackname)
          Reads short textgrid file (*.TextGrid) as produced by "Praat", expecting one interval tier called "words".
 boolean isModified()
          Returns whether the annotation has been modified since the last save.
 AnnotationNode makeTrack(GroupNode parent, ContainerSpec tspec)
          Creates and adds track according to the given specification.
 void print()
          Prints contents of all groups and tracks to standard output.
 boolean removeGroup(java.lang.String name)
          Removes group and returns true if group was found at all.
 boolean removeGroupOrTrack(java.lang.String name)
          Tries to remove track named name, then a group.
 boolean removeTrack(java.lang.String name)
          Removes track and returns true if removal was successful
 void setBookmarks(java.util.List bookmarks)
           
 void setIntensityData(java.io.File file, java.lang.String track)
           
 void setMissing(java.util.List ls)
           
 void setModified(boolean mod)
          Sets the modified flag.
 void setPath(java.io.File file)
           
 void setPitchData(java.io.File file, java.lang.String track)
           
 void setProperties(AnnotationProperties p)
           
 void setSessionData(anvil.annot.meta.SessionData dat)
          Sets session meta-data.
 boolean setTagPause(boolean val)
          If this is set to true, anvil will insert pause markers into the "trl" track when writing an anvil file, according to the time interval between two elements (words).
 void setVideoPaths(java.util.List paths)
           
 java.lang.String toString()
           
 void trackChanged()
          Called by track when elements have been added, deleted etc.
 int updateReciprocalLinks()
          Steps through all elements with ReciprocalLink type attributes and checks if the linked up elements have a backpointer.
 void writeAnvilFile()
          Writes annotation to current file path in Anvil's XML format.
 void writeAnvilFile(java.io.File file)
          Writes annotation data to specified file.
 void writeTrackToTxtFile(Track track, java.io.File file)
          Writes contents of track to an ASCII file.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface anvil.annot.Annotation
addObserver
 

Field Detail

TRL_TRACK_NAME

public static final java.lang.String TRL_TRACK_NAME
Standard name of the transliteration track.

See Also:
Constant Field Values

RST_TRACK_NAME

public static final java.lang.String RST_TRACK_NAME
Standard name of the rhetorical structure track.

See Also:
Constant Field Values

PRIMARY_TRACK

public static final java.lang.String PRIMARY_TRACK
Full class name

See Also:
Constant Field Values

SECONDARY_TRACK

public static final java.lang.String SECONDARY_TRACK
Full class name

See Also:
Constant Field Values

SINGLETON_TRACK

public static final java.lang.String SINGLETON_TRACK
Full class name

See Also:
Constant Field Values

SPAN_TRACK

public static final java.lang.String SPAN_TRACK
Full class name

See Also:
Constant Field Values

WAVEFORM_TRACK

public static final java.lang.String WAVEFORM_TRACK
Full class name

See Also:
Constant Field Values

SPEECH_ANALYSIS_TRACK

public static final java.lang.String SPEECH_ANALYSIS_TRACK
Full class name

See Also:
Constant Field Values

XML_BREATH

public final java.lang.String XML_BREATH
See Also:
Constant Field Values

XML_LONGBREATH

public final java.lang.String XML_LONGBREATH
See Also:
Constant Field Values

XML_PAUSE

public final java.lang.String XML_PAUSE
See Also:
Constant Field Values

XML_LONGPAUSE

public final java.lang.String XML_LONGPAUSE
See Also:
Constant Field Values

DEFAULT_NAME

public final java.lang.String DEFAULT_NAME
See Also:
Constant Field Values
Constructor Detail

AnvilAnnotation

public AnvilAnnotation(AnnotationSpec s)
                throws BuildAnnTreeException
Constructor for annotation object.

Parameters:
s - annotation specification object

AnvilAnnotation

public AnvilAnnotation(AnnotationSpec s,
                       AnnotationProperties props)
                throws BuildAnnTreeException
Method Detail

getPitchFile

public java.io.File getPitchFile()
Description copied from interface: Annotation
Returns path where this annotation is saved or null if annotation has never been saved.

Specified by:
getPitchFile in interface Annotation

getPitchTrack

public java.lang.String getPitchTrack()
Specified by:
getPitchTrack in interface Annotation

setPitchData

public void setPitchData(java.io.File file,
                         java.lang.String track)
Specified by:
setPitchData in interface Annotation

clearPitchData

public void clearPitchData()

getIntensityFile

public java.io.File getIntensityFile()

getIntensityTrack

public java.lang.String getIntensityTrack()

setIntensityData

public void setIntensityData(java.io.File file,
                             java.lang.String track)

clearIntensityData

public void clearIntensityData()

getSessionData

public anvil.annot.meta.SessionData getSessionData()
Description copied from interface: Annotation
Returns session meta-data.

Specified by:
getSessionData in interface Annotation

finalize

protected void finalize()
Called by garbage collector.

Overrides:
finalize in class java.lang.Object

setMissing

public void setMissing(java.util.List ls)

getMissing

public java.util.List getMissing()
Returns list of missing files (pitch or intensity) after loading.


updateReciprocalLinks

public int updateReciprocalLinks()
Steps through all elements with ReciprocalLink type attributes and checks if the linked up elements have a backpointer.


getFullPath

public java.io.File getFullPath(java.lang.String file)
If given path is not absolute, returns absolute path by gluing the given path to the path of the annotation.


hasWaveform

public boolean hasWaveform()
Returns whether the annotation contains a waveform.

Specified by:
hasWaveform in interface Annotation

addVideoPath

public void addVideoPath(java.lang.String path)

clearVideoPaths

public void clearVideoPaths()

setVideoPaths

public void setVideoPaths(java.util.List paths)

getVideoPaths

public java.util.List getVideoPaths()
Returns a list of strings which are the video file names.


isModified

public boolean isModified()
Description copied from interface: Annotation
Returns whether the annotation has been modified since the last save.

Specified by:
isModified in interface Annotation

setModified

public void setModified(boolean mod)
Description copied from interface: Annotation
Sets the modified flag.

Specified by:
setModified in interface Annotation

addBookmark

public boolean addBookmark(Bookmark bm)

clearBookmarks

public void clearBookmarks()
Clears list of bookmarks.


setBookmarks

public void setBookmarks(java.util.List bookmarks)

getBookmarks

public java.util.List getBookmarks()
Specified by:
getBookmarks in interface Annotation

findBookmark

public Bookmark findBookmark(java.lang.String name)

getName

public java.lang.String getName()
Returns file name (without full path) or DEFAULT_NAME if no path is specified yet.


getProperties

public AnnotationProperties getProperties()
Specified by:
getProperties in interface Annotation

setProperties

public void setProperties(AnnotationProperties p)
Specified by:
setProperties in interface Annotation

getSpec

public AnnotationSpec getSpec()
Description copied from interface: Annotation
Returns annotation specification object.

Specified by:
getSpec in interface Annotation

getTracks

public java.util.List getTracks()
Returns a list of all (non-static) tracks.

Specified by:
getTracks in interface Annotation

getSets

public java.util.List getSets()
Returns a list of all annotation sets.


getGroups

public java.util.List getGroups()
Returns a list of all group nodes.

Specified by:
getGroups in interface Annotation

getNodes

public java.util.AbstractList getNodes()
Returns list of all annotation nodes.

Specified by:
getNodes in interface Annotation

getTrack

public Track getTrack(java.lang.String name)
Returns track with name if it exists, null otherwise.

Specified by:
getTrack in interface Annotation

getContainer

public AnnotationContainer getContainer(java.lang.String name)
Returns container with name if it exists, null otherwise.


getAnnotationNode

public AnnotationNode getAnnotationNode(java.lang.String name)
Description copied from interface: Annotation
Returns annotation node with name if it exists, null otherwise.

Specified by:
getAnnotationNode in interface Annotation
Parameters:
name - full path name of desired node

getGroup

public GroupNode getGroup(java.lang.String name)
Returns group with name if it exists, null otherwise.

Specified by:
getGroup in interface Annotation

getSet

public AnnotationSet getSet(java.lang.String name)
Returns set with name if it exists, null otherwise.


getRoot

public GroupNode getRoot()
Description copied from interface: Annotation
Returns the group node that lies at the top of the track/group hierarchy.

Specified by:
getRoot in interface Annotation

getPath

public java.io.File getPath()
Specified by:
getPath in interface Annotation

setPath

public void setPath(java.io.File file)

getMaxEndTime

public javax.media.Time getMaxEndTime()
Computes maximum end time across all tracks.


clearContainer

public AnnotationContainer clearContainer(java.lang.String name)
Clears track of all elements.

Returns:
chosen track or null if none was found.

removeGroupOrTrack

public boolean removeGroupOrTrack(java.lang.String name)
Tries to remove track named name, then a group. Returns whether this was successful or not.


removeTrack

public boolean removeTrack(java.lang.String name)
Removes track and returns true if removal was successful


removeGroup

public boolean removeGroup(java.lang.String name)
Removes group and returns true if group was found at all.


findTracks

public java.util.List findTracks(java.lang.String classname)
Finds tracks by class name.

Parameters:
classname - class: PRIMARY_TRACK, SPAN_TRACK or SINGLETON_TRACK
Returns:
list of track objects

findTrackNames

public java.lang.String[] findTrackNames(java.lang.String classname)
Finds all (non-static) tracks of the given class.

Parameters:
classname - use static Annotation variables PRIMARY_TRACK, SPAN_TRACK, SINGLETON_TRACK, WAVEFORM_TRACK, PITCH_TRACK etc.
Returns:
array of track names

findNodes

public java.util.List findNodes(java.lang.String classname)
Finds nodes by class name.

Parameters:
classname - class: PRIMARY_TRACK, SPAN_TRACK or SINGLETON_TRACK
Returns:
list of node objects

findNodeNames

public java.lang.String[] findNodeNames(java.lang.String classname)
Finds all annotation nodes (group or track) of the given class.

Parameters:
classname - use static Annotation variables PRIMARY_TRACK, SPAN_TRACK, SINGLETON_TRACK, WAVEFORM_TRACK, PITCH_TRACK etc.
Returns:
array of track names

findNonStaticTrackNames

public java.lang.String[] findNonStaticTrackNames()
Returns names of all non static tracks in a String array.


findTrackNames

public java.lang.String[] findTrackNames()
Returns all track names in a String array.


findContainerNames

public java.lang.String[] findContainerNames()
Returns all container names in a String array.


trackChanged

public void trackChanged()
Called by track when elements have been added, deleted etc.


findNonPrimaryTracks

public java.util.List findNonPrimaryTracks()

makeTrack

public AnnotationNode makeTrack(GroupNode parent,
                                ContainerSpec tspec)
Creates and adds track according to the given specification.

Specified by:
makeTrack in interface Annotation
Parameters:
tspec - track specification object
Returns:
new track

setTagPause

public boolean setTagPause(boolean val)
If this is set to true, anvil will insert pause markers into the "trl" track when writing an anvil file, according to the time interval between two elements (words).


writeTrackToTxtFile

public void writeTrackToTxtFile(Track track,
                                java.io.File file)
                         throws java.lang.Exception
Writes contents of track to an ASCII file.

Parameters:
file - File to write data on.
java.lang.Exception

createManual

public void createManual(java.io.File dir)
                  throws java.io.IOException
Creates HTML documentation in form of an annotation manual from the loaded specification.

Parameters:
dir - directory where to write HTML files.
java.io.IOException

writeAnvilFile

public void writeAnvilFile(java.io.File file)
                    throws java.lang.Exception
Writes annotation data to specified file.

java.lang.Exception

writeAnvilFile

public void writeAnvilFile()
                    throws AnnotationException,
                           java.io.IOException
Description copied from interface: Annotation
Writes annotation to current file path in Anvil's XML format. Note that this will not clear the modified flag. The user has to see to that.

Specified by:
writeAnvilFile in interface Annotation
AnnotationException
java.io.IOException

importTextgridFile

public void importTextgridFile(java.io.File file,
                               java.lang.String trackname)
                        throws java.lang.Exception
Reads short textgrid file (*.TextGrid) as produced by "Praat", expecting one interval tier called "words".

java.lang.Exception

print

public void print()
Description copied from interface: Annotation
Prints contents of all groups and tracks to standard output.

Specified by:
print in interface Annotation

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setSessionData

public void setSessionData(anvil.annot.meta.SessionData dat)
Description copied from interface: Annotation
Sets session meta-data.

Specified by:
setSessionData in interface Annotation