Package org.omegat.gui.editor
Class SegmentBuilder
- java.lang.Object
-
- org.omegat.gui.editor.SegmentBuilder
-
public class SegmentBuilder extends java.lang.Object
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 Modifier and Type Field Description static java.lang.String
BIDI_LRM
static char
BIDI_LRM_CHAR
static java.lang.String
BIDI_RLM
static char
BIDI_RLM_CHAR
static boolean
DONT_INSERT_SOURCE_TEXT_DEFAULT
static java.lang.String
SEGMENT_MARK_ATTRIBUTE
Attributes for show text.static java.lang.String
SEGMENT_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 void
addSegmentSeparator()
Add separator between segments - one empty line.void
addSegmentSeparator(int index)
javax.swing.text.AttributeSet
attrs(boolean isSource, boolean isPlaceholder, boolean isRemoveText, boolean isNBSP)
Choose segment part attributes based on rules.void
createSegmentElement(boolean isActive, int initialOffset, TMXEntry trans, boolean defaultTranslation)
void
createSegmentElement(boolean isActive, TMXEntry trans)
Create element for one segment.void
createSegmentElement(boolean isActive, TMXEntry trans, boolean defaultTranslation)
long
getDisplayVersion()
int
getEndPosition()
Get segment's end position.java.lang.String
getSourceText()
Get source text of entry with internal bidi chars, or null if not displayed.SourceTextEntry
getSourceTextEntry()
int
getStartPosition()
Get segment's start position.int
getStartSourcePosition()
int
getStartTranslationPosition()
java.lang.String
getTranslationText()
Get translation text of entry with internal bidi chars, or null if not displayed.boolean
hasBeenCreated()
boolean
isActive()
boolean
isDefaultTranslation()
boolean
isInsideSegment(int location)
Check if location inside segment.void
prependSegmentElement(boolean isActive, TMXEntry trans)
void
prependSegmentSeparator()
void
resetTextAttributes()
void
setDefaultTranslation(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()
-
-