public class SoftWrapModelImpl extends InlayModel.SimpleAdapter implements SoftWrapModelEx, PrioritizedDocumentListener, FoldingListener, java.beans.PropertyChangeListener, Dumpable, Disposable
SoftWrapModelEx
implementation.
Works as a mix of GoF Facade and Bridge
, i.e. delegates the processing to the target sub-components and provides
utility methods built on top of sub-components API.
Not thread-safe.Disposable.Parent
COMPARATOR
ARRAY_FACTORY, EMPTY_ARRAY
Modifier and Type | Method and Description |
---|---|
boolean |
addSoftWrapChangeListener(SoftWrapChangeListener listener)
Registers given listener within the current model
|
void |
beforeDocumentChange(DocumentEvent event)
Called before the text of the document is changed.
|
void |
beforeDocumentChangeAtCaret()
Notifies current model that target document is about to be changed at current caret location.
|
void |
dispose()
Usually not invoked directly, see class javadoc.
|
void |
documentChanged(DocumentEvent event)
Called after the text of the document has been changed.
|
int |
doPaint(java.awt.Graphics g,
SoftWrapDrawingType drawingType,
int x,
int y,
int lineHeight) |
java.lang.String |
dumpState() |
void |
forceAdditionalColumnsUsage()
Allows to instruct current model to return
'true' from SoftWrapModelEx.isRespectAdditionalColumns() . |
SoftWrapApplianceManager |
getApplianceManager() |
EditorTextRepresentationHelper |
getEditorTextRepresentationHelper() |
int |
getMinDrawingWidthInPixels(SoftWrapDrawingType drawingType)
Allows to ask for the minimal width in pixels required for painting of the given type.
|
int |
getPriority() |
java.util.List<? extends SoftWrap> |
getRegisteredSoftWraps() |
SoftWrap |
getSoftWrap(int offset)
Asks current model for the soft wrap registered for the given document offset if any.
|
int |
getSoftWrapIndex(int offset)
Tries to find index of the target soft wrap at
soft wraps collection . |
java.util.List<? extends SoftWrap> |
getSoftWrapsForLine(int documentLine)
Allows to ask current model about all soft wraps registered for the given document line.
|
java.util.List<? extends SoftWrap> |
getSoftWrapsForRange(int start,
int end)
Allows to ask current model about all soft wraps registered for the given document offsets range.
|
boolean |
isDirty() |
boolean |
isInsideOrBeforeSoftWrap(VisualPosition visual)
Allows to answer if given visual position points to soft wrap-introduced virtual space or points just before soft wrap.
|
boolean |
isInsideSoftWrap(VisualPosition visual)
Allows to answer if given visual position points to soft wrap-introduced virtual space.
|
boolean |
isRespectAdditionalColumns()
IJ editor defines a notion of
additional columns . |
boolean |
isSoftWrappingEnabled()
Allows to answer if
'soft wrap' feature is enabled. |
boolean |
isVisible(SoftWrap softWrap)
Allows to answer if given soft wrap is shown.
|
void |
onBatchModeFinish(Editor editor) |
void |
onFoldProcessingEnd()
Informs that fold processing is done.
|
void |
onFoldRegionStateChange(FoldRegion region)
Informs that
'collapsed' state of given fold region is just changed, or that the given fold region has just been created. |
void |
onUpdated(Inlay inlay,
int changeFlags) |
int |
paint(java.awt.Graphics g,
SoftWrapDrawingType drawingType,
int x,
int y,
int lineHeight)
Asks to paint drawing of target type at the given graphics buffer at the given position.
|
void |
prepareToMapping()
Encapsulates preparations for performing document dimension mapping (e.g.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt) |
void |
reinitSettings()
Called on editor settings change.
|
void |
release()
Callback method to ask soft wrap model to release all resources.
|
void |
setEditorTextRepresentationHelper(EditorTextRepresentationHelper editorTextRepresentationHelper) |
void |
setSoftWrapPainter(SoftWrapPainter painter) |
java.lang.String |
toString() |
onAdded, onRemoved
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
bulkUpdateFinished, bulkUpdateStarting
beforeFoldRegionRemoved
onBatchModeStart, onUpdated
public void reinitSettings()
public boolean isRespectAdditionalColumns()
SoftWrapModelEx
additional columns
. They define additional
amount of space to be used during editor component's width calculation (IJ editor perform 'preventive UI component expansion'
when user types near the right edge).
The main idea of soft wraps is to avoid horizontal scrolling, so, when soft wrapping is enabled and succeeds (so that resulting
text layout fits view area's width), additional columns wont be added to the preferred editor width.
This method answers whether the above behaviour should be overridden, and additional columns setting should be respected regardless of
soft wrapping success. This happens when SoftWrapModelEx.forceAdditionalColumnsUsage()
has been invoked previously.isRespectAdditionalColumns
in interface SoftWrapModelEx
public void forceAdditionalColumnsUsage()
SoftWrapModelEx
'true'
from SoftWrapModelEx.isRespectAdditionalColumns()
.forceAdditionalColumnsUsage
in interface SoftWrapModelEx
public boolean isSoftWrappingEnabled()
SoftWrapModel
'soft wrap'
feature is enabled.isSoftWrappingEnabled
in interface SoftWrapModel
true
if 'soft wraps'
are enabled; false
otherwisepublic SoftWrap getSoftWrap(int offset)
SoftWrapModel
getSoftWrap
in interface SoftWrapModel
offset
- target document offsetnull
otherwisepublic int getSoftWrapIndex(int offset)
SoftWrapModelEx
soft wraps collection
.
'Target'
soft wrap is the one that starts at the given offset.getSoftWrapIndex
in interface SoftWrapModelEx
offset
- target offsetCollections.binarySearch(List, Object)
contract, i.e. non-negative returned
index points to soft wrap that starts at the given offset; '-(negative value) - 1'
points
to position at soft wraps collection
where soft wrap for the given index
should be insertedpublic java.util.List<? extends SoftWrap> getSoftWrapsForRange(int start, int end)
SoftWrapModel
getSoftWrapsForRange
in interface SoftWrapModel
start
- start document offset range to use (inclusive)end
- end document offset range to use (inclusive)public java.util.List<? extends SoftWrap> getSoftWrapsForLine(int documentLine)
SoftWrapModel
getSoftWrapsForLine
in interface SoftWrapModel
documentLine
- target document linepublic java.util.List<? extends SoftWrap> getRegisteredSoftWraps()
getRegisteredSoftWraps
in interface SoftWrapModelEx
public boolean isVisible(SoftWrap softWrap)
SoftWrapModel
isVisible
in interface SoftWrapModel
softWrap
- soft wrap to checktrue
if given soft wrap is visible; false
otherwisepublic int paint(java.awt.Graphics g, SoftWrapDrawingType drawingType, int x, int y, int lineHeight)
SoftWrapModelEx
paint
in interface SoftWrapModelEx
g
- target graphics buffer to draw indrawingType
- target drawing typex
- target 'x'
coordinate to usey
- target 'y'
coordinate to uselineHeight
- line height used at editorpublic int doPaint(java.awt.Graphics g, SoftWrapDrawingType drawingType, int x, int y, int lineHeight)
public int getMinDrawingWidthInPixels(SoftWrapDrawingType drawingType)
SoftWrapModelEx
getMinDrawingWidthInPixels
in interface SoftWrapModelEx
drawingType
- target drawing typepublic void prepareToMapping()
public boolean isInsideSoftWrap(VisualPosition visual)
isInsideSoftWrap
in interface SoftWrapModel
visual
- target visual position to checktrue
if given visual position points to soft wrap-introduced virtual space;
false
otherwisepublic boolean isInsideOrBeforeSoftWrap(VisualPosition visual)
isInsideOrBeforeSoftWrap
in interface SoftWrapModel
visual
- target visual position to checktrue
if given visual position points to soft wrap-introduced virtual space;
false
otherwisepublic void beforeDocumentChangeAtCaret()
SoftWrapModel
'soft wrap' -> 'hard wrap'
conversion if the user types in virtual
soft wraps-introduced space.beforeDocumentChangeAtCaret
in interface SoftWrapModel
public boolean addSoftWrapChangeListener(SoftWrapChangeListener listener)
SoftWrapModelEx
addSoftWrapChangeListener
in interface SoftWrapModelEx
listener
- listener to registertrue
if given listener was not registered before; false
otherwisepublic int getPriority()
getPriority
in interface PrioritizedDocumentListener
public void beforeDocumentChange(DocumentEvent event)
DocumentListener
beforeDocumentChange
in interface DocumentListener
event
- the event containing the information about the change.public void documentChanged(DocumentEvent event)
DocumentListener
documentChanged
in interface DocumentListener
event
- the event containing the information about the change.public void onFoldRegionStateChange(FoldRegion region)
FoldingListener
'collapsed'
state of given fold region is just changed, or that the given fold region has just been created.
Note: listener should delay fold region state processing until FoldingListener.onFoldProcessingEnd()
is called.
I.e. folding model may return inconsistent data between current moment and FoldingListener.onFoldProcessingEnd()
.onFoldRegionStateChange
in interface FoldingListener
region
- fold region that is just collapsed or expandedpublic void onFoldProcessingEnd()
FoldingListener
onFoldProcessingEnd
in interface FoldingListener
public void onUpdated(Inlay inlay, int changeFlags)
onUpdated
in interface InlayModel.Listener
changeFlags
- see InlayModel.ChangeFlags
public void onBatchModeFinish(Editor editor)
onBatchModeFinish
in interface InlayModel.Listener
InlayModel.execute(boolean, Runnable)
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
public void dispose()
Disposable
dispose
in interface Disposable
public void release()
SoftWrapModel
release
in interface SoftWrapModel
public SoftWrapApplianceManager getApplianceManager()
public void setSoftWrapPainter(SoftWrapPainter painter)
public EditorTextRepresentationHelper getEditorTextRepresentationHelper()
getEditorTextRepresentationHelper
in interface SoftWrapModelEx
public void setEditorTextRepresentationHelper(EditorTextRepresentationHelper editorTextRepresentationHelper)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isDirty()