Class TranscriptBatchBuilder

java.lang.Object
ca.phon.app.session.editor.view.transcript.TranscriptBatchBuilder

public class TranscriptBatchBuilder extends Object
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 Details

  • Method Details

    • getBatchEndStart

      public static List<DefaultStyledDocument.ElementSpec> getBatchEndStart()
      Gets a list of DefaultStyledDocument.ElementSpec containing the ElementSpec.EndTagType and ElementSpec.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 of DefaultStyledDocument.ElementSpec containing the ElementSpec.EndTagType and ElementSpec.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

      public List<InsertionHook> getInsertionHooks()
    • append

      public void append(DefaultStyledDocument.ElementSpec elementSpec)
    • appendAll

      public void appendAll(List<DefaultStyledDocument.ElementSpec> elementSpecList)
    • 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

      public void appendBatchEndStart(AttributeSet endAttrs, AttributeSet startAttrs)
      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

      public void appendBatchString(String str, AttributeSet a)
      Appends a DefaultStyledDocument.ElementSpec containing the specified string and attributes to the end of the batch
    • getBatchString

      public static DefaultStyledDocument.ElementSpec getBatchString(String str, AttributeSet a)
      Gets a DefaultStyledDocument.ElementSpec containing the specified string and attributes
      Returns:
      a DefaultStyledDocument.ElementSpec containing the specified string and attributes
    • appendBatchLineFeed

      public void appendBatchLineFeed(AttributeSet endAttrs, AttributeSet startAttrs)
      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 of DefaultStyledDocument.ElementSpec containing a newline character with the specified attributes and the ElementSpec.EndTagType and ElementSpec.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

      public TranscriptBatchBuilder appendEOL()
      Appends an end of line
      Returns:
      this builder
    • appendEOL

      public TranscriptBatchBuilder appendEOL(AttributeSet attrs)
    • formatLabelText

      public String formatLabelText(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 end
      Parameters:
      labelText - the text to be formatted
      Returns:
      the formatted text
    • appendGeneric

      public TranscriptBatchBuilder appendGeneric(String label, Tier<?> tier, AttributeSet additionalAttributes)
      Gets a list of DefaultStyledDocument.ElementSpec for a specified "generic tier"
      Parameters:
      label - the text for the label
      tier - the generic tier that the list will contain the data for
      additionalAttributes - any additional attributes to be added to the contents of the returned list (none added if null)
      Returns:
      a list of DefaultStyledDocument.ElementSpec representing the specified generic tier
    • appendFormattedInternalMedia

      public void appendFormattedInternalMedia(InternalMedia internalMedia, AttributeSet additionalAttrs)
      Appends the specified internal media to the batch
      Parameters:
      internalMedia - the internal media that gets appended
      additionalAttrs - any additional attributes to be added to the segment (none added if null)
    • 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 appended
      additionalAttrs - any additional attributes to be added to the segment (none added if null)
      style - the style to format the times of the segment
    • appendFormattedSegment

      public void appendFormattedSegment(MediaSegment segment, AttributeSet additionalAttrs)
      Appends a formatted representation of the provided segment to the batch
      Parameters:
      segment - the segment that will be appended
      additionalAttrs - any additional attributes to be added to the segment (none added if null)
    • appendComment

      public TranscriptBatchBuilder appendComment(Comment comment, boolean chatTierNamesShown)
      Writes a given comment to the batch
      Parameters:
      comment - the comment that will be written
      chatTierNamesShown - 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

      public TranscriptBatchBuilder appendGem(Gem gem, boolean chatTierNamesShown)
      Writes a given gem to the batch
      Parameters:
      gem - the comment that will be written
      chatTierNamesShown - whether or not chat tier names are shown
      Returns:
      this builder
    • getTierText

      public String getTierText(Tier<?> tier, String transcriber)
      Gets the text value of a given tier for a given transcriber
      Parameters:
      tier - the tier that the value will come from
      transcriber - 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 inserted
      tierViewItem - a reference to a TierViewItem used to get font info if any is present
      transcriber - the transcriber whose text will be batched (if tier is blind)
      chatTierNamesShown - whether chat tier names are shown
      additionalAttrs - an attribute set containing attributes for the containing record to be added to the tier attributes (none will be added if null)
      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 to
      record - the record that will be written to the batch
      chatTierNamesShown - whether or not chat tier names are shown
      Returns:
      this builder
    • getTrailingAttributes

      public SimpleAttributeSet getTrailingAttributes()
      Gets the attributes of the last DefaultStyledDocument.ElementSpec in a provided list
      Returns:
      the attributes of the last elementspec
    • setTrailingAttributes

      public void setTrailingAttributes(AttributeSet attrs)
    • size

      public int size()
    • isEmpty

      public boolean isEmpty()