public class GenericLineWrapPositionStrategy extends java.lang.Object implements LineWrapPositionStrategy
LineWrapPositionStrategy
implementation.
Not thread-safe.Modifier and Type | Class and Description |
---|---|
static class |
GenericLineWrapPositionStrategy.Rule
Encapsulates information about rule to use during line wrapping.
|
static class |
GenericLineWrapPositionStrategy.WrapCondition
Defines how wrapping may be performed for particular symbol.
|
Constructor and Description |
---|
GenericLineWrapPositionStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
addRule(GenericLineWrapPositionStrategy.Rule rule)
Registers given rule with the current strategy.
|
int |
calculateWrapPosition(Document document,
Project project,
int startOffset,
int endOffset,
int maxPreferredOffset,
boolean allowToBeyondMaxPreferredOffset,
boolean isSoftWrap)
Allows to calculate the most appropriate position to wrap target line.
|
protected boolean |
canUseOffset(Document document,
int offset,
boolean virtual) |
public int calculateWrapPosition(Document document, Project project, int startOffset, int endOffset, int maxPreferredOffset, boolean allowToBeyondMaxPreferredOffset, boolean isSoftWrap)
LineWrapPositionStrategy
calculateWrapPosition
in interface LineWrapPositionStrategy
document
- target document which text is being processedproject
- target projectstartOffset
- start offset to use with the given text holder (exclusive)endOffset
- end offset to use with the given text holder (exclusive)maxPreferredOffset
- this method is expected to do its best to return offset that belongs to
(startOffset; maxPreferredOffset]
interval. However, it's allowed
to return value from (maxPreferredOffset; endOffset)
interval
unless 'allowToBeyondMaxPreferredOffset'
if 'false'
allowToBeyondMaxPreferredOffset
- indicates if it's allowed to return value from
(maxPreferredOffset; endOffset]
interval in case of inability to
find appropriate offset from (startOffset; maxPreferredOffset]
intervalisSoftWrap
- identifies if current request is for isSoftWrap wrap position(startOffset; endOffset)
interval where
target line should be wrapped OR -1
if no wrapping should be performedprotected boolean canUseOffset(Document document, int offset, boolean virtual)
public void addRule(GenericLineWrapPositionStrategy.Rule rule) throws java.lang.IllegalArgumentException
rule
- rule to registerjava.lang.IllegalArgumentException
- if another rule for the same symbol is already registered within the current strategy