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.ParentCOMPARATORARRAY_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, onRemovedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbulkUpdateFinished, bulkUpdateStartingbeforeFoldRegionRemovedonBatchModeStart, onUpdatedpublic void reinitSettings()
public boolean isRespectAdditionalColumns()
SoftWrapModelExadditional 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 SoftWrapModelExpublic void forceAdditionalColumnsUsage()
SoftWrapModelEx'true' from SoftWrapModelEx.isRespectAdditionalColumns().forceAdditionalColumnsUsage in interface SoftWrapModelExpublic boolean isSoftWrappingEnabled()
SoftWrapModel'soft wrap' feature is enabled.isSoftWrappingEnabled in interface SoftWrapModeltrue if 'soft wraps' are enabled; false otherwisepublic SoftWrap getSoftWrap(int offset)
SoftWrapModelgetSoftWrap in interface SoftWrapModeloffset - target document offsetnull otherwisepublic int getSoftWrapIndex(int offset)
SoftWrapModelExsoft wraps collection.
'Target' soft wrap is the one that starts at the given offset.getSoftWrapIndex in interface SoftWrapModelExoffset - 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)
SoftWrapModelgetSoftWrapsForRange in interface SoftWrapModelstart - start document offset range to use (inclusive)end - end document offset range to use (inclusive)public java.util.List<? extends SoftWrap> getSoftWrapsForLine(int documentLine)
SoftWrapModelgetSoftWrapsForLine in interface SoftWrapModeldocumentLine - target document linepublic java.util.List<? extends SoftWrap> getRegisteredSoftWraps()
getRegisteredSoftWraps in interface SoftWrapModelExpublic boolean isVisible(SoftWrap softWrap)
SoftWrapModelisVisible in interface SoftWrapModelsoftWrap - 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)
SoftWrapModelExpaint in interface SoftWrapModelExg - 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)
SoftWrapModelExgetMinDrawingWidthInPixels in interface SoftWrapModelExdrawingType - target drawing typepublic void prepareToMapping()
public boolean isInsideSoftWrap(VisualPosition visual)
isInsideSoftWrap in interface SoftWrapModelvisual - 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 SoftWrapModelvisual - 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 SoftWrapModelpublic boolean addSoftWrapChangeListener(SoftWrapChangeListener listener)
SoftWrapModelExaddSoftWrapChangeListener in interface SoftWrapModelExlistener - listener to registertrue if given listener was not registered before; false otherwisepublic int getPriority()
getPriority in interface PrioritizedDocumentListenerpublic void beforeDocumentChange(DocumentEvent event)
DocumentListenerbeforeDocumentChange in interface DocumentListenerevent - the event containing the information about the change.public void documentChanged(DocumentEvent event)
DocumentListenerdocumentChanged in interface DocumentListenerevent - 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 FoldingListenerregion - fold region that is just collapsed or expandedpublic void onFoldProcessingEnd()
FoldingListeneronFoldProcessingEnd in interface FoldingListenerpublic void onUpdated(Inlay inlay, int changeFlags)
onUpdated in interface InlayModel.ListenerchangeFlags - see InlayModel.ChangeFlagspublic void onBatchModeFinish(Editor editor)
onBatchModeFinish in interface InlayModel.ListenerInlayModel.execute(boolean, Runnable)public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerpublic void dispose()
Disposabledispose in interface Disposablepublic void release()
SoftWrapModelrelease in interface SoftWrapModelpublic SoftWrapApplianceManager getApplianceManager()
public void setSoftWrapPainter(SoftWrapPainter painter)
public EditorTextRepresentationHelper getEditorTextRepresentationHelper()
getEditorTextRepresentationHelper in interface SoftWrapModelExpublic void setEditorTextRepresentationHelper(EditorTextRepresentationHelper editorTextRepresentationHelper)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isDirty()