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 TypeMethodDescriptionvoid
append
(DefaultStyledDocument.ElementSpec elementSpec) void
appendAll
(List<DefaultStyledDocument.ElementSpec> elementSpecList) void
Appends the end and start tags to the end of the batchvoid
appendBatchEndStart
(AttributeSet endAttrs, AttributeSet startAttrs) Appends the end and start tags to the end of the batchvoid
appendBatchLineFeed
(AttributeSet endAttrs, AttributeSet startAttrs) Appends a newline character with the given attributes and the start and end tags to the end of the batchvoid
appendBatchString
(String str, AttributeSet a) Appends aDefaultStyledDocument.ElementSpec
containing the specified string and attributes to the end of the batchappendComment
(Comment comment, boolean chatTierNamesShown) Writes a given comment to the batchAppends an end of lineappendEOL
(AttributeSet attrs) void
appendFormattedInternalMedia
(InternalMedia internalMedia, AttributeSet additionalAttrs) Appends the specified internal media to the batchvoid
appendFormattedSegment
(MediaSegment segment, AttributeSet additionalAttrs) Appends a formatted representation of the provided segment to the batchvoid
appendFormattedSegment
(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 batchappendGeneric
(String label, Tier<?> tier, AttributeSet additionalAttributes) Gets a list ofDefaultStyledDocument.ElementSpec
for 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.int
clear()
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.ElementSpec
containing a newline character with the specified attributes and theElementSpec.EndTagType
andElementSpec.StartTagType
tagsGets a list ofDefaultStyledDocument.ElementSpec
containing theElementSpec.EndTagType
andElementSpec.StartTagType
tagsgetBatchEndStart
(AttributeSet endAttrs, AttributeSet startAttrs) Gets a list ofDefaultStyledDocument.ElementSpec
containing theElementSpec.EndTagType
andElementSpec.StartTagType
tagsgetBatchString
(String str, AttributeSet a) Gets aDefaultStyledDocument.ElementSpec
containing 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.ElementSpec
in a provided listboolean
isEmpty()
void
int
size()
-
Constructor Details
-
TranscriptBatchBuilder
public TranscriptBatchBuilder() -
TranscriptBatchBuilder
public TranscriptBatchBuilder(TranscriptStyleContext transcriptStyleContext, List<InsertionHook> insertionHooks) -
TranscriptBatchBuilder
-
TranscriptBatchBuilder
-
TranscriptBatchBuilder
-
-
Method Details
-
getBatchEndStart
Gets a list ofDefaultStyledDocument.ElementSpec
containing theElementSpec.EndTagType
andElementSpec.StartTagType
tags- Returns:
- a list containing the end and start tags
-
getBatchEndStart
public static List<DefaultStyledDocument.ElementSpec> getBatchEndStart(AttributeSet endAttrs, AttributeSet startAttrs) Gets a list ofDefaultStyledDocument.ElementSpec
containing theElementSpec.EndTagType
andElementSpec.StartTagType
tags- 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.ElementSpec
containing the specified string and attributes to the end of the batch -
getBatchString
Gets aDefaultStyledDocument.ElementSpec
containing the specified string and attributes- Returns:
- a
DefaultStyledDocument.ElementSpec
containing 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.ElementSpec
containing a newline character with the specified attributes and theElementSpec.EndTagType
andElementSpec.StartTagType
tags- 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.ElementSpec
for 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.ElementSpec
representing 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
-
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
-
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 aTierViewItem
used 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.ElementSpec
in a provided list- Returns:
- the attributes of the last elementspec
-
setTrailingAttributes
-
size
public int size() -
isEmpty
public boolean isEmpty()
-