Class TranscriptBatchBuilder
java.lang.Object
ca.phon.app.session.editor.view.transcript.TranscriptBatchBuilder
A class that builds a batch of
DefaultStyledDocument.ElementSpec to be used in a
TranscriptDocument. All document insertions should be done through this class to ensure that the
TranscriptDocument is updated correctly.-
Constructor Summary
ConstructorsConstructorDescriptionTranscriptBatchBuilder(TranscriptDocument document) TranscriptBatchBuilder(TranscriptStyleContext transcriptStyleContext) TranscriptBatchBuilder(TranscriptStyleContext transcriptStyleContext, List<InsertionHook> insertionHooks) TranscriptBatchBuilder(List<InsertionHook> insertionHooks) -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(DefaultStyledDocument.ElementSpec elementSpec) voidappendAll(List<DefaultStyledDocument.ElementSpec> elementSpecList) voidAppends the end and start tags to the end of the batchvoidappendBatchEndStart(AttributeSet endAttrs, AttributeSet startAttrs) Appends the end and start tags to the end of the batchvoidappendBatchLineFeed(AttributeSet endAttrs, AttributeSet startAttrs) Appends a newline character with the given attributes and the start and end tags to the end of the batchvoidappendBatchString(String str, AttributeSet a) Appends aDefaultStyledDocument.ElementSpeccontaining the specified string and attributes to the end of the batchappendComment(Comment comment, boolean chatTierNamesShown) Writes a given comment to the batchappendCommentValue(Comment comment, AttributeSet attrs) Appends an end of lineappendEOL(AttributeSet attrs) voidappendFormattedInternalMedia(InternalMedia internalMedia, AttributeSet additionalAttrs) Appends the specified internal media to the batchvoidappendFormattedSegment(MediaSegment segment, AttributeSet additionalAttrs) Appends a formatted representation of the provided segment to the batchvoidappendFormattedSegment(MediaSegment segment, AttributeSet additionalAttrs, MediaTimeFormatStyle style) Appends a formatted representation of the provided segment in the provided style to the batchWrites a given gem to the batchvoidappendGemValue(Gem gem, AttributeSet attrs) appendGeneric(String label, Tier<?> tier, AttributeSet additionalAttributes) Gets a list ofDefaultStyledDocument.ElementSpecfor a specified "generic tier"appendRecord(Session session, Record record, Transcriber transcriber, boolean chatTierNamesShown) Writes the contents of the given record to the batchappendTier(Session session, Record record, Tier<?> tier, TierViewItem tierViewItem, Transcriber transcriber, boolean chatTierNamesShown, AttributeSet additionalAttrs) Inserts a given tier at the end of the batchappendTierContent(Record record, Tier<?> tier, Transcriber transcriber, AttributeSet tierAttrs) Appends the contents of the given tier to the batchappendTierLabel(Session session, Record record, Tier<?> tier, String label, TierViewItem tierViewItem, boolean chatTierNamesShown, AttributeSet additionalAttrs) Appends the label of the given tier to the batch.intclear()Clears the batch and returns the number of elements removedformatLabelText(String labelText) Formats the provided text to be used as a label by appending the appropriate number of spaces at the beginning or ellipses at the endgetBatch()getBatchEndLineFeed(AttributeSet endAttrs, AttributeSet startAttrs) Gets a list ofDefaultStyledDocument.ElementSpeccontaining a newline character with the specified attributes and theElementSpec.EndTagTypeandElementSpec.StartTagTypetagsGets a list ofDefaultStyledDocument.ElementSpeccontaining theElementSpec.EndTagTypeandElementSpec.StartTagTypetagsgetBatchEndStart(AttributeSet endAttrs, AttributeSet startAttrs) Gets a list ofDefaultStyledDocument.ElementSpeccontaining theElementSpec.EndTagTypeandElementSpec.StartTagTypetagsgetBatchString(String str, AttributeSet a) Gets aDefaultStyledDocument.ElementSpeccontaining the specified string and attributesgetTierText(Tier<?> tier, String transcriber) Gets the text value of a given tier for a given transcriberGets the attributes of the lastDefaultStyledDocument.ElementSpecin a provided listbooleanisEmpty()voidintsize()
-
Constructor Details
-
TranscriptBatchBuilder
public TranscriptBatchBuilder() -
TranscriptBatchBuilder
public TranscriptBatchBuilder(TranscriptStyleContext transcriptStyleContext, List<InsertionHook> insertionHooks) -
TranscriptBatchBuilder
-
TranscriptBatchBuilder
-
TranscriptBatchBuilder
-
-
Method Details
-
getBatchEndStart
Gets a list ofDefaultStyledDocument.ElementSpeccontaining theElementSpec.EndTagTypeandElementSpec.StartTagTypetags- Returns:
- a list containing the end and start tags
-
getBatchEndStart
public static List<DefaultStyledDocument.ElementSpec> getBatchEndStart(AttributeSet endAttrs, AttributeSet startAttrs) Gets a list ofDefaultStyledDocument.ElementSpeccontaining theElementSpec.EndTagTypeandElementSpec.StartTagTypetags- Parameters:
endAttrs- attributes for end tag (may be null)startAttrs- attributes for start tag (may be null)- Returns:
- a list containing the end and start tags
-
getBatch
-
getInsertionHooks
-
append
-
appendAll
-
clear
public int clear()Clears the batch and returns the number of elements removed- Returns:
- the number of elements removed
-
appendBatchEndStart
public void appendBatchEndStart()Appends the end and start tags to the end of the batch -
appendBatchEndStart
Appends the end and start tags to the end of the batch- Parameters:
endAttrs- attributes for end tag (may be null)startAttrs- attributes for starting paragraph (may be null)
-
appendBatchString
Appends aDefaultStyledDocument.ElementSpeccontaining the specified string and attributes to the end of the batch -
getBatchString
Gets aDefaultStyledDocument.ElementSpeccontaining the specified string and attributes- Returns:
- a
DefaultStyledDocument.ElementSpeccontaining the specified string and attributes
-
appendBatchLineFeed
Appends a newline character with the given attributes and the start and end tags to the end of the batch -
getBatchEndLineFeed
public static List<DefaultStyledDocument.ElementSpec> getBatchEndLineFeed(AttributeSet endAttrs, AttributeSet startAttrs) Gets a list ofDefaultStyledDocument.ElementSpeccontaining a newline character with the specified attributes and theElementSpec.EndTagTypeandElementSpec.StartTagTypetags- Parameters:
endAttrs- attributes for end tag (may be null)startAttrs- attributes for start tag (may be null)- Returns:
- a list with the newline character and the end and start tags
-
appendEOL
-
appendEOL
-
formatLabelText
-
appendGeneric
public TranscriptBatchBuilder appendGeneric(String label, Tier<?> tier, AttributeSet additionalAttributes) Gets a list ofDefaultStyledDocument.ElementSpecfor a specified "generic tier"- Parameters:
label- the text for the labeltier- the generic tier that the list will contain the data foradditionalAttributes- any additional attributes to be added to the contents of the returned list (none added ifnull)- Returns:
- a list of
DefaultStyledDocument.ElementSpecrepresenting the specified generic tier
-
appendFormattedInternalMedia
Appends the specified internal media to the batch- Parameters:
internalMedia- the internal media that gets appendedadditionalAttrs- any additional attributes to be added to the segment (none added ifnull)
-
appendFormattedSegment
public void appendFormattedSegment(MediaSegment segment, AttributeSet additionalAttrs, MediaTimeFormatStyle style) Appends a formatted representation of the provided segment in the provided style to the batch- Parameters:
segment- the segment that will be appendedadditionalAttrs- any additional attributes to be added to the segment (none added ifnull)style- the style to format the times of the segment
-
appendFormattedSegment
Appends a formatted representation of the provided segment to the batch- Parameters:
segment- the segment that will be appendedadditionalAttrs- any additional attributes to be added to the segment (none added ifnull)
-
appendComment
Writes a given comment to the batch- Parameters:
comment- the comment that will be writtenchatTierNamesShown- whether or not chat tier names are shown- Returns:
- a mutable attribute set containing the attributes of the last character of the comment to add a newline after if need be
-
appendCommentValue
-
appendGem
Writes a given gem to the batch- Parameters:
gem- the comment that will be writtenchatTierNamesShown- whether or not chat tier names are shown- Returns:
- this builder
-
appendGemValue
-
getTierText
Gets the text value of a given tier for a given transcriber- Parameters:
tier- the tier that the value will come fromtranscriber- the transcriber whose text will be returned- Returns:
- the text value of a given tier for a given transcriber (or the regular text for the tier if the transcriber is the validator or
null)
-
appendTier
public TranscriptBatchBuilder appendTier(Session session, Record record, Tier<?> tier, TierViewItem tierViewItem, Transcriber transcriber, boolean chatTierNamesShown, AttributeSet additionalAttrs) Inserts a given tier at the end of the batch- Parameters:
record-tier- the tier that will be insertedtierViewItem- a reference to aTierViewItemused to get font info if any is presenttranscriber- the transcriber whose text will be batched (if tier is blind)chatTierNamesShown- whether chat tier names are shownadditionalAttrs- an attribute set containing attributes for the containing record to be added to the tier attributes (none will be added ifnull)- Returns:
- a mutable attribute set containing the attributes of the last character of the tier to add a newline after if need be
-
appendTierLabel
public TranscriptBatchBuilder appendTierLabel(Session session, Record record, Tier<?> tier, String label, TierViewItem tierViewItem, boolean chatTierNamesShown, AttributeSet additionalAttrs) Appends the label of the given tier to the batch. This method may be used to force a label different than the tier's name to be used.- Parameters:
session-record-tier-label-tierViewItem-chatTierNamesShown-additionalAttrs-- Returns:
-
appendTierContent
public TranscriptBatchBuilder appendTierContent(Record record, Tier<?> tier, Transcriber transcriber, AttributeSet tierAttrs) Appends the contents of the given tier to the batch- Parameters:
record-tier-transcriber- the transcriber whose text will be batched (if tier is blind)tierAttrs-- Returns:
-
appendRecord
public TranscriptBatchBuilder appendRecord(Session session, Record record, Transcriber transcriber, boolean chatTierNamesShown) Writes the contents of the given record to the batch- Parameters:
session- the session that the record belongs torecord- the record that will be written to the batchchatTierNamesShown- whether or not chat tier names are shown- Returns:
- this builder
-
getTrailingAttributes
Gets the attributes of the lastDefaultStyledDocument.ElementSpecin a provided list- Returns:
- the attributes of the last elementspec
-
setTrailingAttributes
-
size
public int size() -
isEmpty
public boolean isEmpty()
-