Class TranscriptEditor

All Implemented Interfaces:
IExtendable, ClipboardOwner, ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class TranscriptEditor extends JEditorPane implements IExtendable, ClipboardOwner
A custom JEditorPane implementation for displaying and modifying Phon session transcripts.
See Also:
  • Field Details

    • transcriptDocumentPopulated

      public static final EditorEventType<Void> transcriptDocumentPopulated
    • recordChangedInSingleRecordMode

      public static final EditorEventType<Void> recordChangedInSingleRecordMode
      The editor event type for the event that gets fired if the current record changes when the editor is in "single record view" mode
    • transcriptLocationChanged

      public static final EditorEventType<TranscriptEditor.TranscriptLocationChangeData> transcriptLocationChanged
      The editor event type for the session location change event
  • Constructor Details

  • Method Details

    • removeEditorActions

      public void removeEditorActions()
      Removes editor actions for specific events
    • addTierChangeListener

      public void addTierChangeListener(TranscriptEditorTierChangeListener listener)
    • removeTierChangeListener

      public void removeTierChangeListener(TranscriptEditorTierChangeListener listener)
    • getUndoSupport

      public SessionEditUndoSupport getUndoSupport()
    • getEventManager

      public EditorEventManager getEventManager()
    • getFirstVisibleTierName

      public String getFirstVisibleTierName()
    • getTranscriptEditorCaret

      public TranscriptEditorCaret getTranscriptEditorCaret()
    • getDataModel

      public EditorDataModel getDataModel()
    • getMediaModel

      public SessionMediaModel getMediaModel()
    • setMediaModel

      public void setMediaModel(SessionMediaModel mediaModel)
    • getSegmentPlayback

      public SegmentPlayback getSegmentPlayback()
    • getUndoManager

      public UndoManager getUndoManager()
    • getCurrentRecordIndex

      public int getCurrentRecordIndex()
      Gets the record index of the carets current position
      Returns:
      the record index (returns -1 if caret not in a record)
    • getTranscriptDocument

      public TranscriptDocument getTranscriptDocument()
    • getSession

      public Session getSession()
    • getCurrentElementIndex

      public int getCurrentElementIndex()
      Gets the transcript element index for the current caret pos
      Returns:
      the transcript element index
    • setCurrentElementIndex

      public void setCurrentElementIndex(int index)
      Moves the caret to the beginning of the transcript element at the index specified
      Parameters:
      index - the transcript element index
    • setCurrentRecordIndex

      public void setCurrentRecordIndex(int index)
      Moves the caret to the beginning of the record at the index specified
    • toggleSingleRecordView

      public void toggleSingleRecordView()
      Toggle single record view
    • isSingleRecordView

      public boolean isSingleRecordView()
      Is the document in single record view
      Returns:
      true if single record view, false otherwise
    • setSingleRecordView

      public void setSingleRecordView(boolean singleRecordView)
      Sets whether the document is in single record view
      Parameters:
      singleRecordView -
    • isTranscriberValidator

      public boolean isTranscriberValidator()
      Checks if the current transcriber is the validator
      Returns:
      whether the transcriber is the validator
    • getCurrentSessionLocation

      public TranscriptElementLocation getCurrentSessionLocation()
      Returns the current location in the document as a TranscriptElementLocation
      Returns:
      the current location in the document
    • setCurrentSessionLocation

      public void setCurrentSessionLocation(TranscriptElementLocation currentTranscriptLocation)
      Sets the current location in the document, this method does not set the caret position only the internal location
      Parameters:
      currentTranscriptLocation - the new location in the document
    • getUpDownOffset

      public int getUpDownOffset()
    • setUpDownOffset

      public void setUpDownOffset(int upDownOffset)
    • isCaretMoveFromUpDown

      public boolean isCaretMoveFromUpDown()
    • setCaretMoveFromUpDown

      public void setCaretMoveFromUpDown(boolean caretMoveFromUpDown)
    • nextTierOrElement

      public void nextTierOrElement()
      Moves the caret to the start of the next tier or transcript element
    • prevTierOrElement

      public void prevTierOrElement()
      Moves the caret to the start of the previous tier or transcript element
    • getNextValidIndex

      public int getNextValidIndex(int currentPos, boolean looping)
      Gets the next valid index for the caret from the given position
      Parameters:
      currentPos - the starting position of the caret
      looping - whether the caret should loop back to the start of the doc at the end
      Returns:
      the next valid caret position
    • getPrevValidIndex

      public int getPrevValidIndex(int currentPos, boolean looping)
      Gets the previous valid index for the caret from the given position
      Parameters:
      currentPos - the starting position of the caret
      looping - whether the caret should loop back to the end of the doc at the start
      Returns:
      the previous valid caret position
    • sameOffsetInPrevTierOrElement

      public void sameOffsetInPrevTierOrElement()
      Moves the caret to the position in the previous line with the same offset from the labels (or the end of the line if it's not long enough)
    • offsetInPrevTierOrElement

      public void offsetInPrevTierOrElement(int offsetInContent)
      Moves the caret to the position in the previous line with the same offset from the labels
      Parameters:
      offsetInContent -
    • offsetInPrevTierOrElement

      public void offsetInPrevTierOrElement(int caretPos, int offsetInContent)
      Moves the caret to the position in the previous line with the same offset from the labels
      Parameters:
      offsetInContent -
    • sameOffsetInNextTierOrElement

      public void sameOffsetInNextTierOrElement()
      Moves the caret to the position in the next line with the same offset from the labels
    • offsetInNextTierOrElement

      public void offsetInNextTierOrElement(int offsetInContent)
      Moves the caret to the position in the next line with the offset from the labels (or the end of the line if it's not long enough)
      Parameters:
      offsetInContent - the offset in the content
    • offsetInNextTierOrElement

      public void offsetInNextTierOrElement(int caretPos, int offsetInContent)
      Moves the caret to the position in the next line with the offset from the labels (or the end of the line if it's not long enough)
      Parameters:
      caretPos - the current caret position
      offsetInContent - the offset in the content
    • getStartOfPrevTierOrElement

      public int getStartOfPrevTierOrElement(int caretPos)
      Gets the start position of the previous line
      Parameters:
      caretPos - the starting caret pos
    • getStartOfNextTierOrElement

      public int getStartOfNextTierOrElement(int caretPos)
      Gets the start position of the next line
      Parameters:
      caretPos - the starting caret pos
    • charPosToSessionLocation

      public TranscriptElementLocation charPosToSessionLocation(int charPos)
      Converts a character position in the document into a TranscriptElementLocation object
      Parameters:
      charPos - the position in the document
      Returns:
      the converted session location object
    • sessionLocationToCharPos

      public int sessionLocationToCharPos(TranscriptElementLocation transcriptLocation)
      Converts a session location into a character position in the document
      Parameters:
      transcriptLocation - the session location object
      Returns:
      the converted character position, or -1 if the location is invalid
    • addNotTraversableAttribute

      public void addNotTraversableAttribute(String attributeKey)
      Adds an attribute to the "not traversable" set
      Parameters:
      attributeKey - the attribute to be added
    • removeNotTraversableAttribute

      public void removeNotTraversableAttribute(String attributeKey)
      Removes an attribute from the "not traversable" set
      Parameters:
      attributeKey - the attribute to be removed
    • saveCurrentLine

      public void saveCurrentLine()
      Saves the changes made to the line the caret is currently on
    • commitChanges

      public void commitChanges(int charPos)
      Commit changed tier data at caret location
    • tierHasUncommittedChanges

      public boolean tierHasUncommittedChanges(int charPos)
      Report if tier at caret position has uncommitted changes
      Parameters:
      charPos - the character position in the document
      Returns:
      true if there are uncommitted changes, false otherwise
    • onPressedEnter

      public void onPressedEnter(PhonActionEvent<Void> pae)
      Runs when the user presses enter
    • onPressedHome

      public void onPressedHome()
      Runs when the user presses home
    • onPressedEnd

      public void onPressedEnd()
      Runs when the user presses end
    • changeSpeaker

      public void changeSpeaker(TranscriptEditor.RecordParticipant data)
      Changes the speaker of a given record to a given participant
      Parameters:
      data - a record containing the record and the participant that will become the new speaker
    • genericDataChanged

      public void genericDataChanged(Tier<?> genericTier, String newData)
      Changes the data in a given generic tier if the provided data is different
      Parameters:
      genericTier - the generic tier that the data is changing for
      newData - the possible new data for the tier
    • showTier

      public void showTier(EditorEventType.TierViewChangedData data)
      Shows the specified tiers (and moves the caret if needed)
      Parameters:
      data - the data from the tier view changed event
    • tierFontOrNameChanged

      public void tierFontOrNameChanged(EditorEventType.TierViewChangedData data)
      Updates the fonts of the specified tiers
      Parameters:
      data - the data from the tier view changed event
    • changeTierData

      public void changeTierData(Record record, Tier<?> tier, String newData)
      Changes the data in a given tier if the provided data is different
      Parameters:
      record - the record that the tier belongs to
      tier - the tier that the data is changing for
      newData - the possible new data for the tier
    • commentDataChanged

      public void commentDataChanged(Comment comment, String newData)
      Changes the data in a given comment if the provided data is different
      Parameters:
      comment - the comment that the data is changing for
      newData - the possible new data for the tier
    • gemDataChanged

      public void gemDataChanged(Gem gem, String newData)
      Changes the data in a given gem if the provided data is different
      Parameters:
      gem - the gem that the data is changing for
      newData - the possible new data for the tier
    • moveTier

      public void moveTier(EditorEventType.TierViewChangedData data)
      Moves the specified tiers (and the caret if needed)
      Parameters:
      data - the data from the tier view changed event
    • hideTier

      public void hideTier(EditorEventType.TierViewChangedData data)
      Hides the specified tiers (and moves the caret if needed)
      Parameters:
      data - the data from the tier view changed event
    • boxSelectBounds

      public void boxSelectBounds(TranscriptDocument.StartEnd bounds)
      Sets the box selection to the specified bounds
      Parameters:
      bounds - a touple containing the upper and lower bounds positions
    • removeCurrentBoxSelect

      public void removeCurrentBoxSelect()
      Removes the current box select
    • getCurrentCallout

      public CalloutWindow getCurrentCallout()
      Get the current callout window (if any)
      Returns:
      the current callout window, null if none
    • setCurrentCallout

      public void setCurrentCallout(CalloutWindow callout)
      Set the current callout window
      Parameters:
      callout -
    • showCallout

      public void showCallout(boolean modal, JComponent content, int sideOfWindow, Rectangle pointAtRect)
      Show a callout window with the provided contents. If a callout is already shown, it will be disposed.
      Parameters:
      modal -
      content -
      sideOfWindow -
      pointAtRect -
    • showNonFocusableCallout

      public CalloutWindow showNonFocusableCallout(boolean modal, JComponent content, int sideOfWindow, Rectangle pointAtRect)
      Show a callout window with the provided contents. If a callout is already shown, it will be disposed.
      Parameters:
      modal -
      content -
      sideOfWindow -
      pointAtRect -
      Returns:
      the callout window
    • hideCallout

      public void hideCallout()
      Hide current callout window
    • cut

      public void cut()
      Overrides:
      cut in class JTextComponent
    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • recalculateTierLabelWidth

      public void recalculateTierLabelWidth(Collection<String> additionalTierNames)
      Recalculates the width of the tier labels and updates all paragraph attributes
      Parameters:
      additionalTierNames - additional tier names to consider when recalculating the tier label width
    • recalculateTierLabelWidth

      public void recalculateTierLabelWidth()
      Recalculates the width of the tier labels and updates all paragraph attributes
    • addAdditionalTierName

      public void addAdditionalTierName(String tierName)
      Add a tier name to the set of tier names used to calculate the width of the tier labels.
      Parameters:
      tierName - the tier name to add
    • removeAdditionalTierName

      public void removeAdditionalTierName(String tierName)
      Remove a tier name from the set of tier names used to calculate the width of the tier labels.
      Parameters:
      tierName - the tier name to remove
    • loadSession

      public void loadSession()
      Loads the session on the document
    • getExtensions

      public Set<Class<?>> getExtensions()
      Description copied from interface: IExtendable
      Return all extension types supported
      Specified by:
      getExtensions in interface IExtendable
    • getExtension

      public <T> T getExtension(Class<T> cap)
      Description copied from interface: IExtendable
      Get the requested extension if available.
      Specified by:
      getExtension in interface IExtendable
      Returns:
      the capability object or null if the cability is not available
    • putExtension

      public <T> T putExtension(Class<T> cap, T impl)
      Description copied from interface: IExtendable
      Add a new extension.
      Specified by:
      putExtension in interface IExtendable
      Parameters:
      cap - the extension to add
      Returns:
      the added extension implementation
    • removeExtension

      public <T> T removeExtension(Class<T> cap)
      Description copied from interface: IExtendable
      Remove a capability.
      Specified by:
      removeExtension in interface IExtendable
      Parameters:
      cap - the capability to remove
    • lostOwnership

      public void lostOwnership(Clipboard clipboard, Transferable contents)
      Specified by:
      lostOwnership in interface ClipboardOwner
    • getTransferHandler

      public TransferHandler getTransferHandler()
      Overrides:
      getTransferHandler in class JComponent