VTT Java
2010 Version

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

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

public class VttDocument
extends java.lang.Object

This class is the VttDocument Java object. It includes three components:

History:

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

Field Summary
static java.lang.String FILE_EXT
          VTT file extension
static java.lang.String MARKUP_FIELD_STR
          markup field header string
static java.lang.String MARKUP_STR
          markup string in the header
static java.lang.String META_DATA_STR
          Meta data in the header
static java.lang.String META_FILE_HISTORY_FIELD_STR
          Meta data: save field header string
static java.lang.String META_TAGS_FILE_FIELD_STR
          Meta data: default tags file field header string
static int MODE_MARKUP
          read in mode of markup
static int MODE_META
          read in mode of text
static int MODE_TAG
          read in mode of tag
static int MODE_TEXT
          read in mode of text
static int NOT_CHECK
          not check value definition
static int RESERVED_TAG_INDEX
          reserved tag index, reserved 1st tag as text tag
static java.lang.String RESERVED_TAG_STR
          reserved tag string definition: the default text reserves 1st tag for clearing tag, and highlight colors
static java.lang.String SEPARATOR_STR
          separate string in the header
static java.lang.String TAG_FIELD_STR
          tag field header string
static int TAG_START_INDEX
          The start tag index, use the 2nd tag as start
static java.lang.String TAG_STR
          tag string in the header
static java.lang.String TEXT_STR
          text string in the header
 
Constructor Summary
VttDocument()
          Create a Vtt document Java object with default values.
VttDocument(java.io.File tagFile)
          Create a Vtt document Java object by specifying a tag file.
 
Method Summary
static void CloseFile(javax.swing.text.DefaultStyledDocument doc, VttDocument vttDocument, VttObj vttObj)
          Close the current opened vttDocument.
 Markups GetMarkups()
          Get the markups list of Vtt documents.
 MetaData GetMetaData()
          Get the Meta Data of Vtt documents.
static int GetMode(java.lang.String line, int curMode)
          Return reading mode: text, tags, markups.
 Tag GetReservedTag()
          Get the reserved tag.
static Tag GetSelectTag(Tag markupTag, ConfigObj configObj, VttObj vttObj)
          Get the select tag from vtt Document.
 Tags GetTags()
          Get the tags list of Vtt documents.
 java.lang.String GetText()
          Get the text of Vtt documents.
 Tag GetTextTag()
          Get text tag.
 boolean HasChanged(java.io.File inFile, VttObj vttObj)
          Check if the vtt has been changed by comparing to the orignal inFile.
static boolean IsHeader(java.lang.String str)
          Check if the input string is a header line.
static boolean IsLegalMarkupPos(int startPos, int length, int maxTextLength)
          Check if a position of the specified start position and length is legal.
static boolean IsLegalMarkupPos(Markup markup, int maxTextLength)
          Check if the position of the specified markup is legal.
 boolean ReadFromFile(java.io.File inFile)
          Read text, tags, markups of Vtt Document from a file
static void SaveFile(java.io.File docFile, VttDocument vttDocument, int vttFormat, VttObj vttObj)
          Save vttDocument to a file.
 void SetMarkups(Markups markups)
          Set the markups list to Vtt document.
 void SetReservedTag(Tag tag)
          set reserve tag to a specified tag
static javax.swing.text.SimpleAttributeSet SetStyleConstants(Tag tag, int fontSize)
          Set style constants by specifying tag and font size.
static javax.swing.text.SimpleAttributeSet SetStyleConstants(Tag tag, int baseFontSize, int zoomFactor)
          Set style constant by specifying tag, base font size, and zoom factor.
 void SetTags(Tags tags)
          Set the tags list to Vtt document.
 void SetText(java.lang.String text)
          Set the text to Vtt document.
static void SetTextStyleByMarkupTag(javax.swing.text.DefaultStyledDocument doc, Markup markup, Tag tag, int baseFontSize, int zoomFactor)
          Set text style base on current markup-tag for the text in the markup range change.
static java.lang.String ToString(VttDocument vttDocument, int vttFormat, VttObj vttObj)
          Convert vttDocuemt to a string representation in the format of text|Tags|Markup.
static java.io.File UpdateDocFileNameToVtt(java.io.File inFile)
          Update Document file name to vtt extension.
static boolean UpdateStyleForMarkups(javax.swing.text.DefaultStyledDocument doc, VttDocument vttDocument, ConfigObj configObj, VttObj vttObj)
          Update style for all markups by going through markups and change style on the text/doc.
static boolean UpdateStyleForMarkups(javax.swing.text.DefaultStyledDocument doc, VttDocument vttDocument, ConfigObj configObj, VttObj vttObj, int zoomFactor)
          Update style for all markups by going through markups and change style on the text/doc.
static void UpdateStyleForText(javax.swing.text.DefaultStyledDocument doc, VttDocument vttDocument, ConfigObj configObj, int zoomFactor)
          Reload and update text style on Vtt document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR_STR

public static final java.lang.String SEPARATOR_STR
separate string in the header

See Also:
Constant Field Values

META_DATA_STR

public static final java.lang.String META_DATA_STR
Meta data in the header

See Also:
Constant Field Values

TEXT_STR

public static final java.lang.String TEXT_STR
text string in the header

See Also:
Constant Field Values

TAG_STR

public static final java.lang.String TAG_STR
tag string in the header

See Also:
Constant Field Values

MARKUP_STR

public static final java.lang.String MARKUP_STR
markup string in the header

See Also:
Constant Field Values

META_TAGS_FILE_FIELD_STR

public static final java.lang.String META_TAGS_FILE_FIELD_STR
Meta data: default tags file field header string

See Also:
Constant Field Values

META_FILE_HISTORY_FIELD_STR

public static final java.lang.String META_FILE_HISTORY_FIELD_STR
Meta data: save field header string

See Also:
Constant Field Values

TAG_FIELD_STR

public static final java.lang.String TAG_FIELD_STR
tag field header string

See Also:
Constant Field Values

MARKUP_FIELD_STR

public static final java.lang.String MARKUP_FIELD_STR
markup field header string

See Also:
Constant Field Values

FILE_EXT

public static final java.lang.String FILE_EXT
VTT file extension

See Also:
Constant Field Values

MODE_META

public static final int MODE_META
read in mode of text

See Also:
Constant Field Values

MODE_TEXT

public static final int MODE_TEXT
read in mode of text

See Also:
Constant Field Values

MODE_TAG

public static final int MODE_TAG
read in mode of tag

See Also:
Constant Field Values

MODE_MARKUP

public static final int MODE_MARKUP
read in mode of markup

See Also:
Constant Field Values

NOT_CHECK

public static final int NOT_CHECK
not check value definition

See Also:
Constant Field Values

RESERVED_TAG_STR

public static final java.lang.String RESERVED_TAG_STR
reserved tag string definition: the default text reserves 1st tag for clearing tag, and highlight colors

See Also:
Constant Field Values

RESERVED_TAG_INDEX

public static final int RESERVED_TAG_INDEX
reserved tag index, reserved 1st tag as text tag

See Also:
Constant Field Values

TAG_START_INDEX

public static final int TAG_START_INDEX
The start tag index, use the 2nd tag as start

See Also:
Constant Field Values
Constructor Detail

VttDocument

public VttDocument()
Create a Vtt document Java object with default values.


VttDocument

public VttDocument(java.io.File tagFile)
Create a Vtt document Java object by specifying a tag file.

Method Detail

GetMetaData

public MetaData GetMetaData()
Get the Meta Data of Vtt documents.

Returns:
the Meta Data of Vtt documents

GetText

public java.lang.String GetText()
Get the text of Vtt documents.

Returns:
the text of Vtt documents

GetTags

public Tags GetTags()
Get the tags list of Vtt documents.

Returns:
the tags lists of Vtt documents

GetMarkups

public Markups GetMarkups()
Get the markups list of Vtt documents.

Returns:
the markups list of Vtt documents

SetMarkups

public void SetMarkups(Markups markups)
Set the markups list to Vtt document.

Parameters:
markups - the markups list to be set

SetText

public void SetText(java.lang.String text)
Set the text to Vtt document.

Parameters:
text - the text to be set

SetTags

public void SetTags(Tags tags)
Set the tags list to Vtt document.

Parameters:
tags - the tags list to be set

ReadFromFile

public boolean ReadFromFile(java.io.File inFile)
Read text, tags, markups of Vtt Document from a file

Parameters:
inFile - the input file
Returns:
true if the input file contains legal format of Vtt document data

HasChanged

public boolean HasChanged(java.io.File inFile,
                          VttObj vttObj)
Check if the vtt has been changed by comparing to the orignal inFile.

Parameters:
inFile - the input file to be compared
vttObj - the Vtt object to be compared
Returns:
true if Vtt document in vtt object has been changed (different) from the input file and vice versa

IsLegalMarkupPos

public static boolean IsLegalMarkupPos(Markup markup,
                                       int maxTextLength)
Check if the position of the specified markup is legal.

Parameters:
markup - the markup to be check on it's position
maxTextLength - max. text length
Returns:
ture if the position of specified markup is legal and vice versa

IsLegalMarkupPos

public static boolean IsLegalMarkupPos(int startPos,
                                       int length,
                                       int maxTextLength)
Check if a position of the specified start position and length is legal.

Parameters:
startPos - the start position
length - the length
maxTextLength - max. text length
Returns:
ture if the postion of specified markup is legal and vice versa

GetReservedTag

public Tag GetReservedTag()
Get the reserved tag. The reserved Tag is the 1st element of tags with name of "Text/Clear". This tag is used for:

Returns:
the reserved tag

SetReservedTag

public void SetReservedTag(Tag tag)
set reserve tag to a specified tag

Parameters:
tag - the tag to be set as reserved tag

GetTextTag

public Tag GetTextTag()
Get text tag. The text tag is composed of reserved tag, foreground color, and background color.

Returns:
the text tag

ToString

public static java.lang.String ToString(VttDocument vttDocument,
                                        int vttFormat,
                                        VttObj vttObj)
Convert vttDocuemt to a string representation in the format of text|Tags|Markup.

Parameters:
vttDocument - the vtt document to be converted to string
vttFormat - the vtt format desired in the string representation
vttObj - the vtt object with configuration to be used
Returns:
string representation of a Vtt document

SaveFile

public static void SaveFile(java.io.File docFile,
                            VttDocument vttDocument,
                            int vttFormat,
                            VttObj vttObj)
Save vttDocument to a file.

Parameters:
docFile - the file the Vtt document to be saved to
vttDocument - the Vtt document to be saved
vttFormat - the Vtt format desired
vttObj - the vtt object with configuration to be used

CloseFile

public static void CloseFile(javax.swing.text.DefaultStyledDocument doc,
                             VttDocument vttDocument,
                             VttObj vttObj)
Close the current opened vttDocument.

Parameters:
doc - the open styled document of Vtt document
vttDocument - the Vtt document to be saved
vttObj - the vtt object with configuration to be used

UpdateStyleForText

public static void UpdateStyleForText(javax.swing.text.DefaultStyledDocument doc,
                                      VttDocument vttDocument,
                                      ConfigObj configObj,
                                      int zoomFactor)
Reload and update text style on Vtt document.

Parameters:
doc - the open styled document of Vtt document
vttDocument - the Vtt document to be updated
configObj - the Vtt configuration object
zoomFactor - the zoom in/out factor of Vtt document

UpdateStyleForMarkups

public static boolean UpdateStyleForMarkups(javax.swing.text.DefaultStyledDocument doc,
                                            VttDocument vttDocument,
                                            ConfigObj configObj,
                                            VttObj vttObj)
Update style for all markups by going through markups and change style on the text/doc.

Parameters:
doc - the open styled document of Vtt document
vttDocument - the Vtt document to be updated
configObj - the Vtt configuration object
vttObj - the vtt object with configuration to be used
Returns:
false if there is an error while updating style on markups

UpdateStyleForMarkups

public static boolean UpdateStyleForMarkups(javax.swing.text.DefaultStyledDocument doc,
                                            VttDocument vttDocument,
                                            ConfigObj configObj,
                                            VttObj vttObj,
                                            int zoomFactor)
Update style for all markups by going through markups and change style on the text/doc.

Parameters:
doc - the open styled document of Vtt document
vttDocument - the Vtt document to be updated
configObj - the Vtt configuration object
vttObj - the vtt object with configuration to be used
zoomFactor - the zoom in/out factor of Vtt document
Returns:
false if there is an error while updating style on markups

SetTextStyleByMarkupTag

public static void SetTextStyleByMarkupTag(javax.swing.text.DefaultStyledDocument doc,
                                           Markup markup,
                                           Tag tag,
                                           int baseFontSize,
                                           int zoomFactor)
Set text style base on current markup-tag for the text in the markup range change.

Parameters:
doc - the open styled document of Vtt document
markup - the markup (range) to apply text style
tag - the tag to apply text style
baseFontSize - the base font size of text style
zoomFactor - the zoom in/out factor of Vtt document

SetStyleConstants

public static javax.swing.text.SimpleAttributeSet SetStyleConstants(Tag tag,
                                                                    int baseFontSize,
                                                                    int zoomFactor)
Set style constant by specifying tag, base font size, and zoom factor.

Parameters:
tag - the tag to apply text style
baseFontSize - the base font size of text style
zoomFactor - the zoom in/out factor of Vtt document
Returns:
the simple attribute set for Vtt document

SetStyleConstants

public static javax.swing.text.SimpleAttributeSet SetStyleConstants(Tag tag,
                                                                    int fontSize)
Set style constants by specifying tag and font size.

Parameters:
tag - the tag to apply text style
fontSize - the font size of text style
Returns:
the simple attribute set for Vtt document

UpdateDocFileNameToVtt

public static java.io.File UpdateDocFileNameToVtt(java.io.File inFile)
Update Document file name to vtt extension.

Parameters:
inFile - the input file
Returns:
the file with vtt extension

GetSelectTag

public static Tag GetSelectTag(Tag markupTag,
                               ConfigObj configObj,
                               VttObj vttObj)
Get the select tag from vtt Document.

Parameters:
markupTag - the tag of selected markup
configObj - the Vtt configuration object
vttObj - the vtt object with configuration to be used
Returns:
the selected tag

GetMode

public static int GetMode(java.lang.String line,
                          int curMode)
Return reading mode: text, tags, markups.

Parameters:
line - the lien to be read in
curMode - the current reading mode
Returns:
the updated reading mode

IsHeader

public static boolean IsHeader(java.lang.String str)
Check if the input string is a header line.

Parameters:
str - the input string
Returns:
true if it is part of header

VTT Java
2010 Version

Submit a bug or feature

Copyright © 2010 National Library of Medicine