org.annotation.wordfreak
Class Annotation

java.lang.Object
  extended byorg.annotation.util.FeatureMap
      extended byorg.annotation.wordfreak.Annotation
All Implemented Interfaces:
java.lang.Comparable, javax.swing.tree.MutableTreeNode, Property, Recursable, java.awt.datatransfer.Transferable, TreeComparable, javax.swing.tree.TreeNode

public class Annotation
extends FeatureMap
implements Recursable, java.lang.Comparable, Property, TreeComparable, java.awt.datatransfer.Transferable, javax.swing.tree.MutableTreeNode

Class for storing annotations. Annotations minimally need offsets (a span) and the tree structure in which they are organized. They typically also have features for their type, annotator, and confidence.


Field Summary
static java.lang.String ANNOTATOR
          The name of the annotator property.
static java.lang.String COMMENT
          The name of the comment property.
static java.lang.String CONFIDENCE
          The name of the confidence property.
static Annotation[] EMPTY_ARRAY
           
static java.lang.String EMPTY_SPAN_STRING
          The string that will be displayed for traces and other null elements
static java.lang.String ID
          The name of the ID property.
static java.lang.String LABEL
          The name of the type property.
static org.annotation.wordfreak.NoFileComparator NOFILECOMPARATOR
          Used to sort annotations without caring about the file they are from.
static org.annotation.wordfreak.OffsetComparator OFFSETCOMPARATOR
           
static java.lang.String ORDER
           
static java.lang.String SPAN
          The name of the span property.
static org.annotation.wordfreak.SpanComparator SPANCOMPARATOR
           
static java.lang.String TYPE
          The name of the type property.
 
Fields inherited from class org.annotation.util.FeatureMap
DEFAULT_SET_DELIMITER, properties
 
Constructor Summary
Annotation(AnnotationTree t, Annotation a)
          Copies the specified annotation creating a new annotation with identical properties with the specified tree.
Annotation(AnnotationTree tree, Span span)
          Creates a new annotation with the given tree and span.
Annotation(AnnotationTree tree, Span span, Annotation[] children)
          Creates a new annotatinon with the given tree and children.
Annotation(AnnotationTree tree, Span s, java.util.List children)
          Creates a new annotation with the given tree and children.
Annotation(AnnotationTree tree, Span span, java.util.List children, java.lang.String type, java.lang.String annotator, double confidence)
          Creates a new annotation with the given tree, children, type, annotator and confidence.
Annotation(AnnotationTree tree, Span span, java.lang.String type, java.lang.String annotator, double confidence)
          Creates a new annotation with the given tree, span, type, annotator and confidence.
Annotation(AnnotationTree tree, Span span, java.lang.String type, java.lang.String annotator, double confidence, java.lang.String comment)
          Creates a new annotation with the given tree, span, type, annotator, confidence and comment.
 
Method Summary
 void add(Annotation a)
          Add the specified annotation to this annotation or one of its children.
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 void addFeatureValue(java.lang.String p, java.lang.String v, java.lang.String delim)
          Adds a value to this annotation's feature set.
 void addType(java.lang.String t)
           
static Annotation adjustedAnnotation(AnnotationTree tree, Annotation a, int adjustment)
          Copies the specified annotation and adjusts its span by the specified adjustment creating a new annotation with identical properties using the specified tree.
 boolean allowsChildren()
           
 int binarySearch(Annotation a)
           
 java.util.Enumeration children()
           
 void clear()
           
 int compareTo(java.lang.Object o)
           
 int compareToNoFile(java.lang.Object o)
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(int i)
           
 Annotation[] getAllContainedNodesOfType(java.lang.String type)
          Returns an array of all annotations which are children of this and are of the specified type.
 Annotation[] getAllContainedNodesOfTypes(java.util.Set types)
          Returns an array of all the annotations which are children of this and are of any of the specified types.
 boolean getAllowsChildren()
           
 Annotation getAncestorOfType(java.lang.String type)
          Returns the first ancestor of this which is of the specified type.
 AnnotationFile getAnnotationFile()
           
 AnnotationTree getAnnotationTree()
           
 java.lang.String getAnnotator()
           
 javax.swing.tree.TreeNode getChildAt(int i)
           
 int getChildCount()
           
 java.util.List getChildren()
          Returns a list containing the children nodes of this.
 java.lang.String getComment()
           
 double getConfidence()
           
 Annotation[] getContainedNodesOfType(java.lang.String type)
          Returns an array of the top-most annotations which are children of this and any of the specified types.
 Annotation[] getContainedNodesOfTypes(java.util.Set types)
          Returns an array of the top-most annotations which are children of this and are of any of the specified types.
 int getDepth()
           
 Annotation getEndAnnotation()
           
 java.lang.String getFeature(java.lang.String p)
           
 java.lang.String getFeatures()
           
 AnnotationFile getFile()
           
 Annotation getFirstLeaf()
           
 java.lang.String getId()
           
 int getIndex(javax.swing.tree.TreeNode n)
           
 java.util.Set getLabel()
           
 Annotation getLastLeaf()
           
 java.util.List getLeaves()
           
 Annotation getNextDepthFirst()
           
 Annotation getNextLeaf()
           
 javax.swing.tree.TreeNode getParent()
           
 javax.swing.tree.TreeNode[] getPath()
           
 java.util.List getPathTo(java.lang.Object o)
           
 Annotation getPreviousDepthFirst()
           
 Annotation getPreviousLeaf()
           
 boolean getSave()
           
 java.lang.String getSingleType()
           
 Span getSpan()
          Returns the span for this annotation.
 Annotation getStartAnnotation()
           
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
           
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
           
 java.util.Set getType()
           
 boolean gt(java.lang.Object o)
          Determines whether this is greater than o.
 boolean hasChildren()
           
 boolean hasPathTo(java.lang.Object o)
           
 boolean hasProperty(java.lang.String p)
           
 int indexOf(java.lang.Object o)
           
 void insert(javax.swing.tree.MutableTreeNode n, int i)
           
 boolean intersects(java.lang.Object o)
          Determines whether this intersects o.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
           
 boolean isDescendantOf(Annotation a)
           
 boolean isEmpty()
           
 boolean isLeaf()
           
 java.util.Iterator iterator()
          Returns an iterator for the children of this annotation.
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int i)
           
 boolean lt(java.lang.Object o)
          Determines whether this is less than o.
 boolean readBytes(java.io.DataInputStream s)
           
 void remove(Annotation a)
          Removes the annotation a from this causing it to shrink.
 void remove(Annotation a, boolean shrink)
          Removes the annotaiton a from this causing it to shrink if shrink is true.
 void remove(int i)
          Removes the ith child from this causing this to shrink.
 void remove(javax.swing.tree.MutableTreeNode n)
           
 boolean remove(java.lang.Object o)
          Removes o from this if it is an Annotation causing this to shrink.
 boolean removeAll(java.util.Collection c)
           
 Annotation removeEndAnnotation()
           
 void removeFeature(java.lang.String p)
           
 void removeFeatureValue(java.lang.String p, java.lang.String v, java.lang.String delim)
          Removes a feature value from this annotation's feature set.
 void removeFromParent()
           
 Annotation removeStartAnnotation()
           
 void removeType(java.lang.String t)
           
 void setAnnotations(Annotation[] anns)
           
 void setAnnotations(java.util.List anns)
           
 void setAnnotator(java.lang.String a)
           
 void setComment(java.lang.String c)
           
 void setConfidence(double c)
           
 void setFeature(java.lang.String p, java.lang.String v)
           
 void setId(java.lang.String id)
           
 void setParent(javax.swing.tree.MutableTreeNode p)
           
 void setSave(boolean save)
          Used to specify whether this annotation should be saved.
 void setSpan(Span s)
           
 void setSpan(Span s, boolean update)
           
 void setType(java.util.Set t)
           
 void setType(java.lang.String t)
           
 void setUserObject(java.lang.Object o)
           
 int size()
           
 java.util.List subList(int s, int e)
           
 boolean subsumes(java.lang.Object o)
          Determines whether this subsumes o.
 java.lang.Object[] toArray()
           
 void toArray(Annotation[] a)
           
 java.lang.Object[] toArray(java.lang.Object[] o)
           
 java.lang.String toString()
           
 java.lang.String toText()
           
 boolean writeBytes(java.io.DataOutputStream s)
           
 
Methods inherited from class org.annotation.util.FeatureMap
addFeatureValue, existsFeature, getFeatureAsSet, getFeatureAsSet, getFeatureSet, removeFeatureValue, setFeatures, setProperties
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOFILECOMPARATOR

public static final org.annotation.wordfreak.NoFileComparator NOFILECOMPARATOR
Used to sort annotations without caring about the file they are from.


SPANCOMPARATOR

public static final org.annotation.wordfreak.SpanComparator SPANCOMPARATOR

OFFSETCOMPARATOR

public static final org.annotation.wordfreak.OffsetComparator OFFSETCOMPARATOR

ORDER

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

EMPTY_ARRAY

public static final Annotation[] EMPTY_ARRAY

EMPTY_SPAN_STRING

public static final java.lang.String EMPTY_SPAN_STRING
The string that will be displayed for traces and other null elements

See Also:
Constant Field Values

TYPE

public static final java.lang.String TYPE
The name of the type property.

See Also:
Constant Field Values

ID

public static final java.lang.String ID
The name of the ID property. This is used for relations so that annotations can refer to one another.

See Also:
Constant Field Values

LABEL

public static final java.lang.String LABEL
The name of the type property. This is largly unused but may one day replace type and type will become the class of annotation.

See Also:
Constant Field Values

SPAN

public static final java.lang.String SPAN
The name of the span property.

See Also:
Constant Field Values

CONFIDENCE

public static final java.lang.String CONFIDENCE
The name of the confidence property.

See Also:
Constant Field Values

ANNOTATOR

public static final java.lang.String ANNOTATOR
The name of the annotator property.

See Also:
Constant Field Values

COMMENT

public static final java.lang.String COMMENT
The name of the comment property.

See Also:
Constant Field Values
Constructor Detail

Annotation

public Annotation(AnnotationTree tree,
                  Span span)
Creates a new annotation with the given tree and span.

Parameters:
tree - The annotation tree for this annotation.
span - The span of this annotation.

Annotation

public Annotation(AnnotationTree tree,
                  Span span,
                  Annotation[] children)
Creates a new annotatinon with the given tree and children. This constructor assumes that all decendents of the annotation are not currently in the annotation tree. The span will be grown if it needs to be to accomidate its children.

Parameters:
tree - The tree for the new annotation.
span - The span for this annotation.
children - The children of the new annotation.

Annotation

public Annotation(AnnotationTree t,
                  Annotation a)
Copies the specified annotation creating a new annotation with identical properties with the specified tree. This does not preserve the tree structure the specified annotation.

Parameters:
t - The tree for the new annotation.
a - The annotaion to be copied.

Annotation

public Annotation(AnnotationTree tree,
                  Span span,
                  java.lang.String type,
                  java.lang.String annotator,
                  double confidence)
Creates a new annotation with the given tree, span, type, annotator and confidence.

Parameters:
tree - The tree for the new annotation.
span - The span for the new annotation.
type - The type of the new annotation.
annotator - The annotator's name for the new annotation.
confidence - The annotator's confidence in this annotation.

Annotation

public Annotation(AnnotationTree tree,
                  Span span,
                  java.lang.String type,
                  java.lang.String annotator,
                  double confidence,
                  java.lang.String comment)
Creates a new annotation with the given tree, span, type, annotator, confidence and comment.

Parameters:
tree - The tree for the new annotation.
span - The span of the new annotation.
type - The type of the new annotation.
annotator - The annotator's name for the new annotation.
confidence - The annotator's confidence in this annotation.
comment - A comment about this annotation.

Annotation

public Annotation(AnnotationTree tree,
                  Span s,
                  java.util.List children)
Creates a new annotation with the given tree and children. This constructor assumes that all decendents of the annotation are no currently in the annotation tree.

Parameters:
tree - The tree which contains the new annotation.
children - The children of the annotation.

Annotation

public Annotation(AnnotationTree tree,
                  Span span,
                  java.util.List children,
                  java.lang.String type,
                  java.lang.String annotator,
                  double confidence)
Creates a new annotation with the given tree, children, type, annotator and confidence. This constructor assumes that all decendents of the annotation are no currently in the annotation tree.

Parameters:
tree - The tree which contains the new annotation.
children - The children of the annotation.
type - The type of the new annotation.
annotator - The annotator name for this annotation.
confidence - The annotator confidence in this annotation.
Method Detail

adjustedAnnotation

public static Annotation adjustedAnnotation(AnnotationTree tree,
                                            Annotation a,
                                            int adjustment)
Copies the specified annotation and adjusts its span by the specified adjustment creating a new annotation with identical properties using the specified tree.

Parameters:
tree - The tree for the new annotation.
a - The annotaion to be copied.
adjustment - The value added to the start and end of the specified annotation's span to create the adjusted annotation.
Returns:
An annotation whose span has been adjusted by the specified from the specified annotation but that is identical to the specified annotation with respect to ther properties.

getChildAt

public javax.swing.tree.TreeNode getChildAt(int i)
Specified by:
getChildAt in interface javax.swing.tree.TreeNode

get

public java.lang.Object get(int i)

getIndex

public int getIndex(javax.swing.tree.TreeNode n)
Specified by:
getIndex in interface javax.swing.tree.TreeNode

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface Recursable

lastIndexOf

public int lastIndexOf(java.lang.Object o)

listIterator

public java.util.ListIterator listIterator()

listIterator

public java.util.ListIterator listIterator(int i)

subList

public java.util.List subList(int s,
                              int e)

toArray

public java.lang.Object[] toArray(java.lang.Object[] o)

getStartAnnotation

public Annotation getStartAnnotation()

getEndAnnotation

public Annotation getEndAnnotation()

getFirstLeaf

public Annotation getFirstLeaf()

getNextLeaf

public Annotation getNextLeaf()

getPreviousLeaf

public Annotation getPreviousLeaf()

getLastLeaf

public Annotation getLastLeaf()

getNextDepthFirst

public Annotation getNextDepthFirst()

getPreviousDepthFirst

public Annotation getPreviousDepthFirst()

setParent

public void setParent(javax.swing.tree.MutableTreeNode p)
Specified by:
setParent in interface javax.swing.tree.MutableTreeNode

getParent

public javax.swing.tree.TreeNode getParent()
Specified by:
getParent in interface javax.swing.tree.TreeNode

insert

public void insert(javax.swing.tree.MutableTreeNode n,
                   int i)
Specified by:
insert in interface javax.swing.tree.MutableTreeNode

add

public boolean add(java.lang.Object o)

add

public void add(Annotation a)
Add the specified annotation to this annotation or one of its children. The specified annotation is first removed from its existing parent, causing that parent to shrink and the span of the node where the specified annotaiton is inserted is updated and may grow to accomidate this annotaiton.

Parameters:
a - The annotation to be added to this annotation.

addAll

public boolean addAll(java.util.Collection c)

removeAll

public boolean removeAll(java.util.Collection c)

binarySearch

public int binarySearch(Annotation a)

removeFromParent

public void removeFromParent()
Specified by:
removeFromParent in interface javax.swing.tree.MutableTreeNode

remove

public void remove(javax.swing.tree.MutableTreeNode n)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode

remove

public void remove(int i)
Removes the ith child from this causing this to shrink.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode

remove

public boolean remove(java.lang.Object o)
Removes o from this if it is an Annotation causing this to shrink. If o is not Annotaiton an exception is thrown.


remove

public void remove(Annotation a)
Removes the annotation a from this causing it to shrink.


remove

public void remove(Annotation a,
                   boolean shrink)
Removes the annotaiton a from this causing it to shrink if shrink is true.


clear

public void clear()

removeStartAnnotation

public Annotation removeStartAnnotation()

removeEndAnnotation

public Annotation removeEndAnnotation()

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface javax.swing.tree.TreeNode

getAllowsChildren

public boolean getAllowsChildren()
Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface javax.swing.tree.TreeNode

size

public int size()
Specified by:
size in interface Recursable

iterator

public java.util.Iterator iterator()
Returns an iterator for the children of this annotation.

Specified by:
iterator in interface Recursable
Returns:
an iterator over the children or over an empty list if no children are present.

hasChildren

public boolean hasChildren()

allowsChildren

public boolean allowsChildren()

setAnnotations

public void setAnnotations(java.util.List anns)

setAnnotations

public void setAnnotations(Annotation[] anns)

getDepth

public int getDepth()

getSave

public boolean getSave()

setSave

public void setSave(boolean save)
Used to specify whether this annotation should be saved.

Parameters:
save - Specify true to same this annotation, false otherwise.

getId

public java.lang.String getId()

setId

public void setId(java.lang.String id)

getFeature

public java.lang.String getFeature(java.lang.String p)
Overrides:
getFeature in class FeatureMap

setFeature

public void setFeature(java.lang.String p,
                       java.lang.String v)
Overrides:
setFeature in class FeatureMap

removeFeature

public void removeFeature(java.lang.String p)
Overrides:
removeFeature in class FeatureMap

addFeatureValue

public void addFeatureValue(java.lang.String p,
                            java.lang.String v,
                            java.lang.String delim)
Description copied from class: FeatureMap
Adds a value to this annotation's feature set.

Overrides:
addFeatureValue in class FeatureMap
Parameters:
p - the name of the feature.
v - the value to be added to the set.
delim - the delimitor used to seperate the values.

removeFeatureValue

public void removeFeatureValue(java.lang.String p,
                               java.lang.String v,
                               java.lang.String delim)
Description copied from class: FeatureMap
Removes a feature value from this annotation's feature set.

Overrides:
removeFeatureValue in class FeatureMap
Parameters:
p - the name of the feature.
v - the value to be removed from the set.
delim - the delimitor which seperates the values.

getFeatures

public java.lang.String getFeatures()

getSpan

public Span getSpan()
Returns the span for this annotation.

Returns:
the span for this annotation.

setSpan

public void setSpan(Span s)

setSpan

public void setSpan(Span s,
                    boolean update)

getAnnotationTree

public AnnotationTree getAnnotationTree()

getAnnotationFile

public AnnotationFile getAnnotationFile()

getFile

public AnnotationFile getFile()

getLabel

public java.util.Set getLabel()

getType

public java.util.Set getType()

getSingleType

public java.lang.String getSingleType()

addType

public void addType(java.lang.String t)

removeType

public void removeType(java.lang.String t)

setType

public void setType(java.lang.String t)

setType

public void setType(java.util.Set t)

getAnnotator

public java.lang.String getAnnotator()

setAnnotator

public void setAnnotator(java.lang.String a)

getConfidence

public double getConfidence()

setConfidence

public void setConfidence(double c)

getComment

public java.lang.String getComment()

setComment

public void setComment(java.lang.String c)

setUserObject

public void setUserObject(java.lang.Object o)
Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode

toString

public java.lang.String toString()

writeBytes

public boolean writeBytes(java.io.DataOutputStream s)

readBytes

public boolean readBytes(java.io.DataInputStream s)

toText

public java.lang.String toText()

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

compareToNoFile

public int compareToNoFile(java.lang.Object o)

hasProperty

public boolean hasProperty(java.lang.String p)
Specified by:
hasProperty in interface Property

containsAll

public boolean containsAll(java.util.Collection c)

subsumes

public boolean subsumes(java.lang.Object o)
Description copied from interface: TreeComparable
Determines whether this subsumes o. If this equals o then this subsumes o.

Specified by:
subsumes in interface TreeComparable

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface Recursable

getPath

public javax.swing.tree.TreeNode[] getPath()

getPathTo

public java.util.List getPathTo(java.lang.Object o)
Specified by:
getPathTo in interface Recursable

hasPathTo

public boolean hasPathTo(java.lang.Object o)
Specified by:
hasPathTo in interface Recursable

isDescendantOf

public boolean isDescendantOf(Annotation a)

intersects

public boolean intersects(java.lang.Object o)
Description copied from interface: TreeComparable
Determines whether this intersects o.

Specified by:
intersects in interface Recursable

lt

public boolean lt(java.lang.Object o)
Description copied from interface: TreeComparable
Determines whether this is less than o.

Specified by:
lt in interface Recursable

gt

public boolean gt(java.lang.Object o)
Description copied from interface: TreeComparable
Determines whether this is greater than o.

Specified by:
gt in interface Recursable

equals

public boolean equals(java.lang.Object o)

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
Specified by:
getTransferData in interface java.awt.datatransfer.Transferable

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable

isEmpty

public boolean isEmpty()

toArray

public java.lang.Object[] toArray()

toArray

public void toArray(Annotation[] a)

getLeaves

public java.util.List getLeaves()

children

public java.util.Enumeration children()
Specified by:
children in interface javax.swing.tree.TreeNode

getChildren

public java.util.List getChildren()
Returns a list containing the children nodes of this. If this has no children an empty list is returned.

Returns:
a list containing the children of this.

getAncestorOfType

public Annotation getAncestorOfType(java.lang.String type)
Returns the first ancestor of this which is of the specified type.

Parameters:
type - The type of the ancestor.
Returns:
the first ancestor of this which is of the specified type or null if no such ancestor exists.

getAllContainedNodesOfType

public Annotation[] getAllContainedNodesOfType(java.lang.String type)
Returns an array of all annotations which are children of this and are of the specified type.

Parameters:
type - The type of the children.
Returns:
An array containing the children of this (if any) which are of the specified type. A zero length array is return if no appropiate children are found.

getContainedNodesOfType

public Annotation[] getContainedNodesOfType(java.lang.String type)
Returns an array of the top-most annotations which are children of this and any of the specified types.

Parameters:
type - The types of the children.
Returns:
An array containing the top-most children of this (if any) which are of the specified type. A zero length array is return if no appropiate children are found.

getContainedNodesOfTypes

public Annotation[] getContainedNodesOfTypes(java.util.Set types)
Returns an array of the top-most annotations which are children of this and are of any of the specified types.

Parameters:
types - The potential types of the children.
Returns:
An array containing the top-most children of this (if any) which are of at least one of the specified types. A zero length array is return if no appropiate children are found.

getAllContainedNodesOfTypes

public Annotation[] getAllContainedNodesOfTypes(java.util.Set types)
Returns an array of all the annotations which are children of this and are of any of the specified types.

Parameters:
types - The potential types of the children.
Returns:
An array containing the all children of this (if any) which are of at least one of the specified types. A zero length array is return if no appropiate children are found.


Copyright © 2004 Thomas Morton and Jeremy LaCivita. All Rights Reserved.