Package org.omegat.gui.editor
Class SegmentBuilder
- java.lang.Object
-
- org.omegat.gui.editor.SegmentBuilder
-
public class SegmentBuilder extends java.lang.ObjectClass for store information about displayed segment, and for show segment in editor. RTL and Bidirectional support: see good description at http://www.iamcal.com/understanding-bidirectional-text/. Java support of RTL/bidi depends on supported Unicode version. You can usually find supported Unicode version in the Character class comments.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBIDI_LRMstatic charBIDI_LRM_CHARstatic java.lang.StringBIDI_RLMstatic charBIDI_RLM_CHARstatic booleanDONT_INSERT_SOURCE_TEXT_DEFAULTstatic java.lang.StringSEGMENT_MARK_ATTRIBUTEAttributes for show text.static java.lang.StringSEGMENT_SPELL_CHECK
-
Constructor Summary
Constructors Constructor Description SegmentBuilder(EditorController controller, Document3 doc, EditorSettings settings, SourceTextEntry ste, int segmentNumberInProject, boolean hasRTL)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSegmentSeparator()Add separator between segments - one empty line.voidaddSegmentSeparator(int index)javax.swing.text.AttributeSetattrs(boolean isSource, boolean isPlaceholder, boolean isRemoveText, boolean isNBSP)Choose segment part attributes based on rules.voidcreateSegmentElement(boolean isActive, int initialOffset, TMXEntry trans, boolean defaultTranslation)voidcreateSegmentElement(boolean isActive, TMXEntry trans)Create element for one segment.voidcreateSegmentElement(boolean isActive, TMXEntry trans, boolean defaultTranslation)longgetDisplayVersion()intgetEndPosition()Get segment's end position.java.lang.StringgetSourceText()Get source text of entry with internal bidi chars, or null if not displayed.SourceTextEntrygetSourceTextEntry()intgetStartPosition()Get segment's start position.intgetStartSourcePosition()intgetStartTranslationPosition()java.lang.StringgetTranslationText()Get translation text of entry with internal bidi chars, or null if not displayed.booleanhasBeenCreated()booleanisActive()booleanisDefaultTranslation()booleanisInsideSegment(int location)Check if location inside segment.voidprependSegmentElement(boolean isActive, TMXEntry trans)voidprependSegmentSeparator()voidresetTextAttributes()voidsetDefaultTranslation(boolean defaultTranslation)
-
-
-
Field Detail
-
SEGMENT_MARK_ATTRIBUTE
public static final java.lang.String SEGMENT_MARK_ATTRIBUTE
Attributes for show text.- See Also:
- Constant Field Values
-
SEGMENT_SPELL_CHECK
public static final java.lang.String SEGMENT_SPELL_CHECK
- See Also:
- Constant Field Values
-
DONT_INSERT_SOURCE_TEXT_DEFAULT
public static final boolean DONT_INSERT_SOURCE_TEXT_DEFAULT
- See Also:
- Constant Field Values
-
BIDI_LRM
public static final java.lang.String BIDI_LRM
- See Also:
- Constant Field Values
-
BIDI_RLM
public static final java.lang.String BIDI_RLM
- See Also:
- Constant Field Values
-
BIDI_LRM_CHAR
public static final char BIDI_LRM_CHAR
- See Also:
- Constant Field Values
-
BIDI_RLM_CHAR
public static final char BIDI_RLM_CHAR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SegmentBuilder
public SegmentBuilder(EditorController controller, Document3 doc, EditorSettings settings, SourceTextEntry ste, int segmentNumberInProject, boolean hasRTL)
-
-
Method Detail
-
isDefaultTranslation
public boolean isDefaultTranslation()
-
setDefaultTranslation
public void setDefaultTranslation(boolean defaultTranslation)
-
createSegmentElement
public void createSegmentElement(boolean isActive, TMXEntry trans)Create element for one segment.- Parameters:
doc- document
-
createSegmentElement
public void createSegmentElement(boolean isActive, TMXEntry trans, boolean defaultTranslation)
-
prependSegmentElement
public void prependSegmentElement(boolean isActive, TMXEntry trans)
-
createSegmentElement
public void createSegmentElement(boolean isActive, int initialOffset, TMXEntry trans, boolean defaultTranslation)
-
hasBeenCreated
public boolean hasBeenCreated()
-
addSegmentSeparator
public void addSegmentSeparator()
Add separator between segments - one empty line.
-
prependSegmentSeparator
public void prependSegmentSeparator()
-
addSegmentSeparator
public void addSegmentSeparator(int index)
-
getSourceTextEntry
public SourceTextEntry getSourceTextEntry()
-
getDisplayVersion
public long getDisplayVersion()
-
isActive
public boolean isActive()
-
getSourceText
public java.lang.String getSourceText()
Get source text of entry with internal bidi chars, or null if not displayed.
-
getTranslationText
public java.lang.String getTranslationText()
Get translation text of entry with internal bidi chars, or null if not displayed.
-
getStartSourcePosition
public int getStartSourcePosition()
-
getStartTranslationPosition
public int getStartTranslationPosition()
-
getStartPosition
public int getStartPosition()
Get segment's start position.- Returns:
- start position
-
getEndPosition
public int getEndPosition()
Get segment's end position.- Returns:
- end position
-
isInsideSegment
public boolean isInsideSegment(int location)
Check if location inside segment.
-
attrs
public javax.swing.text.AttributeSet attrs(boolean isSource, boolean isPlaceholder, boolean isRemoveText, boolean isNBSP)Choose segment part attributes based on rules.- Parameters:
isSource- is it a source segment or a target segmentisPlaceholder- is it for a placeholder (OmegaT tag or sprintf-variable etc.) or regular text inside the segment?isRemoveText- is it text that should be removed in the translation?isNBSP- is the text a non-breakable space?- Returns:
- the attributes to format the text
-
resetTextAttributes
public void resetTextAttributes()
-
-