Visual Tagging Tool

Markups Operations Design

I. Java Classes

  • Markup
    The data structure in Markup Java object are described as follows.
    • int offset_
    • int length_
    • String tagName_
    • String annotation_
  • Markups
    The data structure in Markups Java object are described as follows.
    • int selectIndex_
    • Vector<Markup> markups_
    • Please notes that:
      • markups_ are sorted by offset (smaller first), the length (bigger first). No Markup objects with same offset and length is allowed.
      • Tag of "Text/Clear" is not used because Delete is used instead of Clear
      • index is the selected markup. -1 is return when no Markup is selected.

II. Algorithm

  • Basic methods
    VTT provides following basic methods to manipulate Markups. These methods are designed as private Java methods in MarkupOperations.java.
    • Add
      • Add a Markup to Markups
      • Add undoBase(ADD) to undoNode
      • Set the selectIndex_ to the added Markup
    • Delete
      • Add undoBase(DELETE) to undoNode
      • Remove the specified Markup from Markups
      • Set the selectIndex_ to the next Markup
    • Change
      • Update the specified Markup in Markups
      • Add undoBase(CHANGE) to undoNode
      • Set the selectIndex_ to the changed Markup

  • Markup Operations
    VTT provides higher level Markups operations based on markup basic methods described above. These operations are designed as public Java methods in MarkupOperations.java so that can be used from key/menu control classes.
    • Delete Operation
      • if the selected Markup in Markups
        • Init UndoNode(DELETE)
        • Delete method
        • Add undoNode
        • Update style to document
        • Update MarkupDialog and MarkupsDialog
        • The selectIndex_ in Markups keeps the same value. After the delete, the selected markup points to the next markup.
      • else
        • beep
    • Join Operation
      • if the selected Markup and the next Markup are in Markups, update new markup by join current and next markups
        • Delete the current selected markup from Markups
        • Delete the next markup from Markups
        • Add new markup;
          • The new markup has the same tag as the selected markup
          • Starts with the start position of the selected markup
          • Ends at the end of the next markup
          • Combines annotations from both selected markup and the next markup
        • The selectIndex_ in Markups keeps the same value. After the join, the selected markup points to the next joined markup.
      • else
        • beep
    • Delete All Operation
      • Delete all markups in Markups
      • Set selectIndex_ in Markups to none (-1) since there is no markup exists.
    • Update Operation
      • If overlap mode is true (markup can be overlap)
        • If no markup is selected, add a markup on the highlight text
        • If a markup is selected, change the selected markup
      • If overlap mode is false (overlap markups is not allowed)
        • If no markup is selected, add the override markup on the highlight text
        • If a markup is selected, change the selected markup
      • Update style to document
      • Update MarkupDialog and MarkupsDialog
      • Set selectIndex_ in Markups to the updated markup.

    • Add a Markup Operation
      • if length of highlight text is > 0
        • Init UndoNode(ADD)
        • Add a new tagged markup to Markups
        • Add undoNode
        • Set selectIndex_ in Markups to the added markup.
      • else
        • beep
    • Change a Markup Operation
      • if tag does not change
        • beep
      • else
        • Update markup in markups
        • Update undoNode
        • Update markups style to document
        • Update MarkupDialog and MarkupsDialog
        • Set selectIndex_ in Markups to the changed markup.
    • Override a Markup Operation
      • if length of highlight text is > 0
        • Find all markups in Markups that have overlap with the highlight text
        • If no overlap markups found
          • Init undoNode(ADD)
        • If some overlap markups found
          • Init undoNode(OVERRIDE)
          • Delete all overlap markups form Markups
          • Add the new override markup
          • Add undoNode
        • Set selectIndex_ in Markups to the override markup.
      • else
        • beep