VTT Java
2010 Version

gov.nih.nlm.nls.vtt.Model
Class Markups

java.lang.Object
  extended by gov.nih.nlm.nls.vtt.Model.Markups

public class Markups
extends java.lang.Object

This class is the collection of Java object Markup. This class is used directly in VTT.

History:

Version:
V-2010
Author:
NLM NLS Development Team, clu

Field Summary
static int ADD
          markup action: add a markup
static int CHANGE
          markup action: change a markup, position or tag
static int DELETE
          markup action: delete a markup
static int JOIN
          markup action: join a selected markup and the next
static int MAX_LENGTH_SIZE
          Vtt fixed format definiton: max field size for length
static int MAX_OFFSET_SIZE
          Vtt fixed format definiton: max field size for offset
static int MAX_TAG_CATEGORY_SIZE
          Vtt fixed format definiton: max field size for tag category
static int MAX_TAG_NAME_SIZE
          Vtt fixed format definiton: max field size for tag name
static int NO_SELECT
          selection variables: no select
static int OVERRIDE
          markup action: override selected markups/next
 
Constructor Summary
Markups()
          Create a Markups Java object with default values.
Markups(java.lang.String inFile, Tags tags)
          Create a Markups Java object by specifying input file and tags.
 
Method Summary
 void AddMarkup(Markup markup)
          Add a markup to markups list.
 int DecreaseSelectIndex(boolean showAll, VttObj vttObj)
          Decrease the selected index to the previous display markup, and then return the end position of markup
 void DeleteMarkupByTag(java.lang.String tagNameCategory)
          Delete all markups with specified tag nameCategory.
 int FindSelectIndex(int curPos)
          Find the selected index by specifying the current position.
 void FindSelectIndex(int start, int length)
          Find the select index by start and end (smear)
 void FindSelectIndex(Markup markup)
          Find the select index by specifying the markup
static java.lang.String GetActionStr(int action)
          Convert action to the action string.
 int GetFirstSelectIndex(boolean showAll, VttObj vttObj)
          Move the selected markup to the first from the beginning and then return the beginning position of the markup.
 int GetIndex(Markup markup)
          get the index of a specified Markup by name (offset and length), This method returns -1 if the specified markup does not exist.
 int GetLastSelectIndex(boolean showAll, VttObj vttObj)
          Move the selected markup to the last from the end and then return the end position of markup.
 Markup GetMarkup(int index)
          Get markup by specifying the index.
 java.util.Vector<Markup> GetMarkups()
          Get the markups.
static java.util.Vector<java.lang.String> GetReportStrs(java.util.Vector<java.lang.String> nameCategoryList, java.util.Vector<Markup> markups)
          Get the markup report in a format of line Vector of String.
 int GetSelectIndex()
          Get the selected index.
 Markup GetSelectMarkup()
          Get the selected markup.
 int GetSize()
          Get the size of markups.
 int IncreaseSelectIndex(boolean showAll, VttObj vttObj)
          Increase the selected index to the next display markup, and then return the end position of markup
 void LoadMarkupsFromFile(java.lang.String inFile, Tags tags)
          Load markups from a file.
static Markup ReadMarkupFromLine(java.lang.String line)
          Read a markup from a string (line), without tags checking.
static Markup ReadMarkupFromLine(java.lang.String line, Tags tags, int maxTextPos)
          Read a markup from a string (line), with tags checking.
static Markup ReadMarkupFromLine(java.lang.String line, Tags tags, int maxTextPos, int verboseType)
          Read a markup from a string (line), with tags checking and verbose type options.
 void RemoveMarkupAt(int index)
          Remove markup from specified position.
 void SaveMarkupsToFile(java.lang.String outFile)
          save markups to file.
 void SetMarkupAt(Markup markup, int index)
          Set markup at specified position.
 void SetSelectIndex(int selectIndex)
          Set the selected index.
 void SetSelectMarkup(Markup markup)
          Set a markup to the selected markup on markups list.
 void SortMarkups()
          Sort the markups by: offset (smaller go first) length (bigger go first if offset is the same)
static java.lang.String ToString(java.util.Vector<Markup> markups)
          Convert specified markups to String.
static java.lang.String ToString(java.util.Vector<Markup> markups, boolean showHeader, boolean showAnnotation)
          Convert specified markups to String with options of showing header and annotation.
static java.lang.String ToString(java.util.Vector<Markup> markups, java.lang.String text, int vttFormat, ConfigObj configObj)
          Convert specified markups to string with specifying text, vtt format, and configuration.
static java.lang.String ToString(java.util.Vector<Markup> markups, java.lang.String text, int vttFormat, ConfigObj configObj, boolean showHeader)
          Convert specified markups to string with specifying text, vtt format, configuration, and flag of showing header.
 void UpdateTagNameCategoryInMarkups(java.lang.String orgNameCategory, java.lang.String newNameCategory)
          update tag name category for all markups with specified the original and new name category.
static void WriteMarkupsToFile(java.io.BufferedWriter out, java.util.Vector<Markup> markups)
          Write specified markups to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_SELECT

public static final int NO_SELECT
selection variables: no select

See Also:
Constant Field Values

ADD

public static final int ADD
markup action: add a markup

See Also:
Constant Field Values

CHANGE

public static final int CHANGE
markup action: change a markup, position or tag

See Also:
Constant Field Values

DELETE

public static final int DELETE
markup action: delete a markup

See Also:
Constant Field Values

JOIN

public static final int JOIN
markup action: join a selected markup and the next

See Also:
Constant Field Values

OVERRIDE

public static final int OVERRIDE
markup action: override selected markups/next

See Also:
Constant Field Values

MAX_OFFSET_SIZE

public static final int MAX_OFFSET_SIZE
Vtt fixed format definiton: max field size for offset

See Also:
Constant Field Values

MAX_LENGTH_SIZE

public static final int MAX_LENGTH_SIZE
Vtt fixed format definiton: max field size for length

See Also:
Constant Field Values

MAX_TAG_NAME_SIZE

public static final int MAX_TAG_NAME_SIZE
Vtt fixed format definiton: max field size for tag name

See Also:
Constant Field Values

MAX_TAG_CATEGORY_SIZE

public static final int MAX_TAG_CATEGORY_SIZE
Vtt fixed format definiton: max field size for tag category

See Also:
Constant Field Values
Constructor Detail

Markups

public Markups()
Create a Markups Java object with default values.


Markups

public Markups(java.lang.String inFile,
               Tags tags)
Create a Markups Java object by specifying input file and tags.

Method Detail

GetMarkups

public java.util.Vector<Markup> GetMarkups()
Get the markups.

Returns:
a vector of Markup objects

GetSize

public int GetSize()
Get the size of markups.

Returns:
the size of Markup objects

GetMarkup

public Markup GetMarkup(int index)
Get markup by specifying the index.

Parameters:
index - the index of interested markup
Returns:
the markup of the specified index

AddMarkup

public void AddMarkup(Markup markup)
Add a markup to markups list.

Parameters:
markup - the markup to be added

SetSelectMarkup

public void SetSelectMarkup(Markup markup)
Set a markup to the selected markup on markups list.

Parameters:
markup - the markup to be set

SetMarkupAt

public void SetMarkupAt(Markup markup,
                        int index)
Set markup at specified position.

Parameters:
markup - the markup to be set
index - the index of markup to be set on the markups list

RemoveMarkupAt

public void RemoveMarkupAt(int index)
Remove markup from specified position.

Parameters:
index - the position of markup to be removed on the markups list

GetIndex

public int GetIndex(Markup markup)
get the index of a specified Markup by name (offset and length), This method returns -1 if the specified markup does not exist.

Parameters:
markup - the markup is in interested
Returns:
the index of interested markup on the markups list

SaveMarkupsToFile

public void SaveMarkupsToFile(java.lang.String outFile)
save markups to file.

Parameters:
outFile - the file of markups list to be saved to

LoadMarkupsFromFile

public void LoadMarkupsFromFile(java.lang.String inFile,
                                Tags tags)
Load markups from a file. This method checks if all markups belongs to existing Tags.

Parameters:
inFile - the file of markups list to be loaded from
tags - the tags used in the VttDocument

UpdateTagNameCategoryInMarkups

public void UpdateTagNameCategoryInMarkups(java.lang.String orgNameCategory,
                                           java.lang.String newNameCategory)
update tag name category for all markups with specified the original and new name category.

Parameters:
orgNameCategory - original nameCategory
newNameCategory - new nameCategory

DeleteMarkupByTag

public void DeleteMarkupByTag(java.lang.String tagNameCategory)
Delete all markups with specified tag nameCategory.

Parameters:
tagNameCategory - tag namecategory of markup to be deleted

WriteMarkupsToFile

public static void WriteMarkupsToFile(java.io.BufferedWriter out,
                                      java.util.Vector<Markup> markups)
                               throws java.io.IOException
Write specified markups to a file.

Parameters:
out - the buffered writer of out file destination
markups - markups to be sent to a file
Throws:
java.io.IOException

ToString

public static java.lang.String ToString(java.util.Vector<Markup> markups)
Convert specified markups to String.

Parameters:
markups - the markups to be converted to string
Returns:
the string representation of the specified markups

ToString

public static java.lang.String ToString(java.util.Vector<Markup> markups,
                                        boolean showHeader,
                                        boolean showAnnotation)
Convert specified markups to String with options of showing header and annotation.

Parameters:
markups - the markups to be converted to string
showHeader - a boolean flag of showing header
showAnnotation - a boolean flag of showing annotation
Returns:
the string representation of the specified markups

ToString

public static java.lang.String ToString(java.util.Vector<Markup> markups,
                                        java.lang.String text,
                                        int vttFormat,
                                        ConfigObj configObj)
Convert specified markups to string with specifying text, vtt format, and configuration.

Parameters:
markups - the markups to be converted to string
text - the text section of vtt document
vttFormat - vtt formats: SIMPLE_FORMAT, READABLE_FORMAT, FIX_LENGTH_FORMAT, and SIMPLEST_FORMAT
configObj - vtt configuration object
Returns:
the string representation of the specified markups

ToString

public static java.lang.String ToString(java.util.Vector<Markup> markups,
                                        java.lang.String text,
                                        int vttFormat,
                                        ConfigObj configObj,
                                        boolean showHeader)
Convert specified markups to string with specifying text, vtt format, configuration, and flag of showing header.

Parameters:
markups - the markups to be converted to string
text - the text section of vtt document
vttFormat - vtt formats: SIMPLE_FORMAT, READABLE_FORMAT, FIX_LENGTH_FORMAT, and SIMPLEST_FORMAT
configObj - vtt configuration object
showHeader - a boolean flag of showing header
Returns:
the string representation of the specified markups

GetReportStrs

public static java.util.Vector<java.lang.String> GetReportStrs(java.util.Vector<java.lang.String> nameCategoryList,
                                                               java.util.Vector<Markup> markups)
Get the markup report in a format of line Vector of String.

Parameters:
nameCategoryList - the vector of nameCategory to shown on the report
markups - the markups to be reports
Returns:
a report composed of a vector of line (String)

ReadMarkupFromLine

public static Markup ReadMarkupFromLine(java.lang.String line)
Read a markup from a string (line), without tags checking.

Parameters:
line - the input line for the markup
Returns:
the markup object read from the input line

ReadMarkupFromLine

public static Markup ReadMarkupFromLine(java.lang.String line,
                                        Tags tags,
                                        int maxTextPos)
Read a markup from a string (line), with tags checking.

Parameters:
line - the input line for the markup
tags - the tags in vtt Document used for valifying
maxTextPos - the max. tetx position
Returns:
the markup object read from the input line

ReadMarkupFromLine

public static Markup ReadMarkupFromLine(java.lang.String line,
                                        Tags tags,
                                        int maxTextPos,
                                        int verboseType)
Read a markup from a string (line), with tags checking and verbose type options.

Parameters:
line - the input line for the markup
tags - the tags in vtt Document used for valifying
maxTextPos - the max. tetx position
verboseType - verbose types: VERVOSE_GUI and VERBOSE_STD_IO
Returns:
the markup object read from the input line

GetActionStr

public static java.lang.String GetActionStr(int action)
Convert action to the action string.

Parameters:
action - the integer value of action
Returns:
the string representation of action

GetSelectIndex

public int GetSelectIndex()
Get the selected index.

Returns:
the selected index

GetSelectMarkup

public Markup GetSelectMarkup()
Get the selected markup.

Returns:
the selected markup

SetSelectIndex

public void SetSelectIndex(int selectIndex)
Set the selected index.

Parameters:
selectIndex - the selected index

SortMarkups

public void SortMarkups()
Sort the markups by:


FindSelectIndex

public int FindSelectIndex(int curPos)
Find the selected index by specifying the current position. This method should be called whenever Caret position is changed. It returns position of cur caret of end of selected markup.

Parameters:
curPos - the current position of caret
Returns:
the index of selected markup, returns -1 if no markup is selected

FindSelectIndex

public void FindSelectIndex(Markup markup)
Find the select index by specifying the markup

Parameters:
markup - the markup to be found for its index

FindSelectIndex

public void FindSelectIndex(int start,
                            int length)
Find the select index by start and end (smear)

Parameters:
start - the start position of smear
length - the length of smear

GetFirstSelectIndex

public int GetFirstSelectIndex(boolean showAll,
                               VttObj vttObj)
Move the selected markup to the first from the beginning and then return the beginning position of the markup.

Parameters:
showAll - a boolean flag of showing all markups
vttObj - the vtt object
Returns:
the beginning position of the first select markup from the beginning

GetLastSelectIndex

public int GetLastSelectIndex(boolean showAll,
                              VttObj vttObj)
Move the selected markup to the last from the end and then return the end position of markup.

Parameters:
showAll - a boolean flag of showing all markups
vttObj - the vtt object
Returns:
the end position of the last select markup from the end

IncreaseSelectIndex

public int IncreaseSelectIndex(boolean showAll,
                               VttObj vttObj)
Increase the selected index to the next display markup, and then return the end position of markup

Parameters:
showAll - a boolean flag of showing all markups
vttObj - the vtt object
Returns:
the end position of selected markup

DecreaseSelectIndex

public int DecreaseSelectIndex(boolean showAll,
                               VttObj vttObj)
Decrease the selected index to the previous display markup, and then return the end position of markup

Parameters:
showAll - a boolean flag of showing all markups
vttObj - the vtt object
Returns:
the end position of selected markup

VTT Java
2010 Version

Submit a bug or feature

Copyright © 2010 National Library of Medicine