net.sourceforge.nite.tools.videolabeler
Class LabelAnnotationLayer

java.lang.Object
  extended by net.sourceforge.nite.tools.videolabeler.AnnotationLayer
      extended by net.sourceforge.nite.tools.videolabeler.LabelAnnotationLayer

public class LabelAnnotationLayer
extends AnnotationLayer

In this annotation layer the annotation targets are elements from an object set or ontology. Each label is assigned its own colour using a ValueColourMap. The element formatter displays the label of an annotation target. The label is displayed between brackets [] and the text will have the colour that was assigned to the label.


Constructor Summary
LabelAnnotationLayer(NLayer layer, java.lang.String codeName, java.lang.String panelType, org.w3c.dom.Node layerInfo)
          Constructs a new label annotation layer.
 
Method Summary
 void createGap(NOMElement annotation, double startTime, double endTime)
          Splits an annotation, so there will be a gap between the specified start time and end time.
 ValueColourMap getColourMap()
          Returns a colour map that maps targets (instances of NOMElement) to colours.
 java.lang.String getLabel(NOMElement annotation)
          Returns the label of an annotation in this layer.
 java.lang.String getLabelAttribute()
          Returns the attribute of an object set or ontology element that contains the label of the annotation target.
 NPointer getPointer()
          Returns the pointer that points from an annotation to its target.
 java.util.HashMap getStyleMap()
          Returns a hash map that maps style names to styles.
 NOMElement getTarget(NOMElement annotation)
          Returns the target of the specified annotation.
 java.lang.String getTargetName(NOMElement target)
          Returns the label of the specified target element.
 java.lang.String getTargetRootID()
          Returns the root ID of the target object set or ontology.
 java.util.List getTargets()
          Returns the possible targets of this layer.
 boolean sameTargets(NOMElement elem1, NOMElement elem2)
          Compares two annotations and returns true if they have the same target.
 
Methods inherited from class net.sourceforge.nite.tools.videolabeler.AnnotationLayer
createTargetControlPanel, getCodeElement, getElementFormatter, getNLayer, showAnnotationArea
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelAnnotationLayer

public LabelAnnotationLayer(NLayer layer,
                            java.lang.String codeName,
                            java.lang.String panelType,
                            org.w3c.dom.Node layerInfo)
                     throws java.lang.ClassNotFoundException,
                            java.lang.NoSuchMethodException,
                            java.lang.Exception

Constructs a new label annotation layer. The layerInfo parameter is the layerinfo element from the configuration file. It should have the following two attributes:

Parameters:
layer - the NXT layer
codeName - the name of the code elements that represent annotations in this layer
panelType - the qualified class name of the target control panel that should be used with this layer
layerInfo - the layerinfo element
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.Exception
Method Detail

getPointer

public NPointer getPointer()

Returns the pointer that points from an annotation to its target.

Returns:
the pointer that points from an annotation to its target

getLabelAttribute

public java.lang.String getLabelAttribute()

Returns the attribute of an object set or ontology element that contains the label of the annotation target.

Returns:
the label attribute

getTargetRootID

public java.lang.String getTargetRootID()

Returns the root ID of the target object set or ontology. The ID consists of the name of the object set or ontology, a # character, and the ID of the root element of the object set or ontology. If the targets of this layer are in an ontology, the returned root ID can be used to create an OntologyTreeView.

Returns:
the root ID of the target object set or ontology

getColourMap

public ValueColourMap getColourMap()

Returns a colour map that maps targets (instances of NOMElement) to colours.

Returns:
the colour map

getTargets

public java.util.List getTargets()

Returns the possible targets of this layer. This method returns a list with the elements in the object set or ontology that this layer points to. The objects in the list are instances of NOMElement.

Returns:
a list with the targets of the layer

getStyleMap

public java.util.HashMap getStyleMap()

Returns a hash map that maps style names to styles.

Overrides:
getStyleMap in class AnnotationLayer
Returns:
a hash map that maps style names to styles

getTargetName

public java.lang.String getTargetName(NOMElement target)

Returns the label of the specified target element. The target element should have an attribute with the name of the labelattribute specified in the layerinfo element from the configuration file. This method returns the value of that attribute. If there is no such attribute, this method returns null.

Returns:
the label of the specified target element or null

getTarget

public NOMElement getTarget(NOMElement annotation)

Returns the target of the specified annotation. If the annotation does not have a target or the target could not be retrieved, this method returns null.


getLabel

public java.lang.String getLabel(NOMElement annotation)

Returns the label of an annotation in this layer. If the label could not be retrieved, this method returns null.

Specified by:
getLabel in class AnnotationLayer
Parameters:
annotation - an annotation in this layer
Returns:
the label of the specified annotation or null

createGap

public void createGap(NOMElement annotation,
                      double startTime,
                      double endTime)
               throws java.lang.Exception

Splits an annotation, so there will be a gap between the specified start time and end time. The specified annotation must start before the start time and it must end after the end time.

Specified by:
createGap in class AnnotationLayer
Parameters:
annotation - the annotation that will be split
startTime - the time where the gap will start
endTime - the time where the gap will end
Throws:
java.lang.Exception - if an error occurs

sameTargets

public boolean sameTargets(NOMElement elem1,
                           NOMElement elem2)

Compares two annotations and returns true if they have the same target. If the two annotations are adjacent, it means they can be merged into one annotation.

Specified by:
sameTargets in class AnnotationLayer
Parameters:
elem1 - the first annotation
elem2 - the second annotation
Returns:
true if both annotations have the same target, false otherwise