Package org.omegat.gui.editor
Class SegmentBuilder
java.lang.Object
org.omegat.gui.editor.SegmentBuilder
Class 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 -
Constructor Summary
ConstructorsConstructorDescriptionSegmentBuilder(EditorController controller, Document3 doc, EditorSettings settings, SourceTextEntry ste, int segmentNumberInProject, boolean hasRTL) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd separator between segments - one empty line.voidaddSegmentSeparator(int index) attrs(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 an element for one segment.voidcreateSegmentElement(boolean isActive, TMXEntry trans, boolean defaultTranslation) Create an element for one segment.longintGet segment's end position.@Nullable StringGet source text of entry with internal bidi chars, or null if not displayed.intGet segment's start position.intint@Nullable StringGet translation text of entry with internal bidi chars, or null if not displayed.booleanbooleanisActive()booleanbooleanisInsideSegment(int location) Check if location inside segment.voidprependSegmentElement(boolean isActive, TMXEntry trans) voidvoidvoidsetDefaultTranslation(boolean defaultTranslation)
-
Field Details
-
SEGMENT_MARK_ATTRIBUTE
Attributes for show text.- See Also:
-
SEGMENT_SPELL_CHECK
- See Also:
-
DONT_INSERT_SOURCE_TEXT_DEFAULT
public static final boolean DONT_INSERT_SOURCE_TEXT_DEFAULT- See Also:
-
BIDI_LRM
- See Also:
-
BIDI_RLM
- See Also:
-
BIDI_LRM_CHAR
public static final char BIDI_LRM_CHAR- See Also:
-
BIDI_RLM_CHAR
public static final char BIDI_RLM_CHAR- See Also:
-
-
Constructor Details
-
SegmentBuilder
public SegmentBuilder(EditorController controller, Document3 doc, EditorSettings settings, SourceTextEntry ste, int segmentNumberInProject, boolean hasRTL)
-
-
Method Details
-
isDefaultTranslation
public boolean isDefaultTranslation() -
setDefaultTranslation
public void setDefaultTranslation(boolean defaultTranslation) -
createSegmentElement
Create an element for one segment.- Parameters:
isActive- flag to indicate activenesstrans- translation entry
-
createSegmentElement
Create an element for one segment.- Parameters:
isActive- flag to indicate activenesstrans- translation entrydefaultTranslation- flag to indicate it is a default translation
-
prependSegmentElement
-
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
-
getDisplayVersion
public long getDisplayVersion() -
isActive
public boolean isActive() -
getSourceText
Get source text of entry with internal bidi chars, or null if not displayed. -
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 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()
-