VTT Java
2010 Version

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

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

public class Markup
extends java.lang.Object

This class is the Markup Java object. Markup is used to label a selected text by different tags with different colors, fonts, sizes, styles, etc.

History:

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

Constructor Summary
Markup()
          Create a Markup Java object with default values.
Markup(int offset, int length, java.lang.String tagName, java.lang.String tagCategory, java.lang.String annotation)
          Create a Markup Java object by specifying offset, length, tag name, tag category, and annotation.
Markup(Markup markup)
          Create a Markup Java object by the specified markup.
 
Method Summary
static void DoMarkUp(Tag tag, javax.swing.text.DefaultStyledDocument doc, int offset, int length, int baseFontSize, javax.swing.text.SimpleAttributeSet sas, boolean replace)
          Apply tag, offset, length of markup to text.
 boolean Equals(Markup markup)
          Check if this markup equals to the specified markup.
 java.lang.String GetAnnotation()
          Get the annotation of applied tag.
 int GetLength()
          Get the length.
 java.lang.String GetMarkupName()
          Get markup name.
 int GetOffset()
          Get the offset.
 java.lang.String GetTagCategory()
          Get the category of applied tag.
 java.lang.String GetTaggedText(java.lang.String text)
          Get the markup text of this markup, start at offset, end at offset + length.
 java.lang.String GetTagName()
          Get the name of applied tag.
 java.lang.String GetTagNameCategory()
          Get the name and category string of applied tag.
 boolean IsOverlap(int start, int end)
          Check is a smear (by specifying the start and end position) overlap this markup.
static Markup Join(Markup markup1, Markup markup2)
          Join two markups together.
 void SetAnnotation(java.lang.String annotation)
          Set the annotation.
 void SetLength(int length)
          Set the length.
 void SetOffset(int offset)
          Set the offset.
 void SetTagCategory(java.lang.String tagCategory)
          Set the category of applied tag.
 void SetTagName(java.lang.String tagName)
          Set the name of applied tag.
 java.lang.String ToString()
          Convert markup data to string in the format of:
offset|length|tagName|tagCategory|Annotation
 java.lang.String ToString(boolean showAnnotation)
          Convert markup data to string with option of showing annotation in the format of:
offset|length|tagName|tagCategory|Annotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Markup

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


Markup

public Markup(Markup markup)
Create a Markup Java object by the specified markup.

Parameters:
markup - the specified markup

Markup

public Markup(int offset,
              int length,
              java.lang.String tagName,
              java.lang.String tagCategory,
              java.lang.String annotation)
Create a Markup Java object by specifying offset, length, tag name, tag category, and annotation.

Parameters:
offset - the offset position
length - the length
tagName - the name of tag
tagCategory - the category of tag
annotation - the annotation
Method Detail

SetOffset

public void SetOffset(int offset)
Set the offset.

Parameters:
offset - the beginning position

SetLength

public void SetLength(int length)
Set the length.

Parameters:
length - the length

SetTagName

public void SetTagName(java.lang.String tagName)
Set the name of applied tag.

Parameters:
tagName - the name of applied tag

SetTagCategory

public void SetTagCategory(java.lang.String tagCategory)
Set the category of applied tag.

Parameters:
tagCategory - the category of applied tag

SetAnnotation

public void SetAnnotation(java.lang.String annotation)
Set the annotation.

Parameters:
annotation - the annotation

GetOffset

public int GetOffset()
Get the offset.

Returns:
the beginning position (offset)

GetLength

public int GetLength()
Get the length.

Returns:
the length

GetTagName

public java.lang.String GetTagName()
Get the name of applied tag.

Returns:
the name of applied tag

GetTagCategory

public java.lang.String GetTagCategory()
Get the category of applied tag.

Returns:
the category of applied tag

GetTagNameCategory

public java.lang.String GetTagNameCategory()
Get the name and category string of applied tag.

Returns:
the name and category string of applied tag

GetAnnotation

public java.lang.String GetAnnotation()
Get the annotation of applied tag.

Returns:
the annotation

DoMarkUp

public static void DoMarkUp(Tag tag,
                            javax.swing.text.DefaultStyledDocument doc,
                            int offset,
                            int length,
                            int baseFontSize,
                            javax.swing.text.SimpleAttributeSet sas,
                            boolean replace)
Apply tag, offset, length of markup to text.

Parameters:
tag - the tag of the applied markup
doc - the styled document that markup is applied to
offset - the offset of the applied markup
length - the length of the applied markup
baseFontSize - the base font size of the document
sas - the simple attribute set of the applied markup
replace - a boolean flag of replacing the previous attribute

Join

public static Markup Join(Markup markup1,
                          Markup markup2)
Join two markups together.

Parameters:
markup1 - the first markup to join
markup2 - the second markup to join
Returns:
the joined markup

GetTaggedText

public java.lang.String GetTaggedText(java.lang.String text)
Get the markup text of this markup, start at offset, end at offset + length.

Parameters:
text - the untagged text
Returns:
the tagged text

GetMarkupName

public java.lang.String GetMarkupName()
Get markup name. It is defined as offset-length and is unique in Markups.

Returns:
the name (offset-length) of the markup

ToString

public java.lang.String ToString()
Convert markup data to string in the format of:
offset|length|tagName|tagCategory|Annotation

Returns:
a String represent the makrup

ToString

public java.lang.String ToString(boolean showAnnotation)
Convert markup data to string with option of showing annotation in the format of:
offset|length|tagName|tagCategory|Annotation

Returns:
a String represent the makrup

Equals

public boolean Equals(Markup markup)
Check if this markup equals to the specified markup. Two markups are equal when they have same offset, length, name, category, and annotation.

Returns:
true if this markup equals to the specified markup

IsOverlap

public boolean IsOverlap(int start,
                         int end)
Check is a smear (by specifying the start and end position) overlap this markup.

Parameters:
start - the start position of the smear
end - the end position of the smear
Returns:
true if the specified smear range overlap this markup

VTT Java
2010 Version

Submit a bug or feature

Copyright © 2010 National Library of Medicine