Class GenericStyledArea<PS,SEG,S>
- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- org.fxmisc.richtext.GenericStyledArea<PS,SEG,S>
-
- Type Parameters:
PS- type of style that can be applied to paragraphs (e.g.TextFlow.SEG- type of segment used inParagraph. Can be only text (plain or styled) or a type that combines text and otherNodes.S- type of style that can be applied to a segment.
- All Implemented Interfaces:
Styleable,EventTarget,Virtualized,ClipboardActions<PS,SEG,S>,EditActions<PS,SEG,S>,TwoDimensional,NavigationActions<PS,SEG,S>,StyleActions<PS,S>,TextEditingArea<PS,SEG,S>,UndoActions,ViewActions<PS,SEG,S>
- Direct Known Subclasses:
StyledTextArea
public class GenericStyledArea<PS,SEG,S> extends Region implements TextEditingArea<PS,SEG,S>, EditActions<PS,SEG,S>, ClipboardActions<PS,SEG,S>, NavigationActions<PS,SEG,S>, StyleActions<PS,S>, UndoActions, ViewActions<PS,SEG,S>, TwoDimensional, Virtualized
Text editing control that renders and edits aEditableStyledDocument. Accepts user input (keyboard, mouse) and provides API to assign style to text ranges. It is suitable for syntax highlighting and rich-text editors.Adding Scrollbars to the Area
By default, scroll bars do not appear when the content spans outside of the viewport. To add scroll bars, the area needs to be wrapped in a
VirtualizedScrollPane. For example,// shows area without scroll bars InlineCssTextArea area = new InlineCssTextArea(); // add scroll bars that will display as needed VirtualizedScrollPane<InlineCssTextArea> vsPane = new VirtualizedScrollPane<>(area); Parent parent = // creation code parent.getChildren().add(vsPane)Auto-Scrolling to the Caret
Every time the underlying
EditableStyledDocumentchanges via user interaction (e.g. typing) through theGenericStyledArea, the area will scroll to insure the caret is kept in view. However, this does not occur if changes are done programmatically. For example, let's say the area is displaying the bottom part of the area'sEditableStyledDocumentand some code changes something in the top part of the document that is not currently visible. If there is no call torequestFollowCaret()at the end of that code, the area will not auto-scroll to that section of the document. The change will occur, and the user will continue to see the bottom part of the document as before. If such a call is there, then the area will scroll to the top of the document and no longer display the bottom part of it.For example...
// assuming the user is currently seeing the top of the area // then changing the bottom, currently not visible part of the area... int startParIdx = 40; int startColPosition = 2; int endParIdx = 42; int endColPosition = 10; // ...by itself will not scroll the viewport to where the change occurs area.replaceText(startParIdx, startColPosition, endParIdx, endColPosition, "replacement text"); // adding this line after the last modification to the area will cause the viewport to scroll to that change // leaving the following line out will leave the viewport unaffected and the user will not notice any difference area.requestFollowCaret();Additionally, when overriding the default user-interaction behavior, remember to include a call to
requestFollowCaret().Setting the area's
UndoManagerThe default UndoManager can undo/redo either
PlainTextChanges orRichTextChanges. To create your own specialized version that may use changes different than these (or a combination of these changes with others), create them using the convenient factory methods inUndoUtils.Overriding default keyboard behavior
GenericStyledAreausesKEY_TYPEDto handle ordinary character input andKEY_PRESSEDto handle control key combinations (including Enter and Tab). To add or override some keyboard shortcuts, while keeping the rest in place, you would combine the default event handler with a new one that adds or overrides some of the default key combinations.For example, this is how to bind
Ctrl+Sto thesave()operation:import static javafx.scene.input.KeyCode.*; import static javafx.scene.input.KeyCombination.*; import static org.fxmisc.wellbehaved.event.EventPattern.*; import static org.fxmisc.wellbehaved.event.InputMap.*; import org.fxmisc.wellbehaved.event.Nodes; // installs the following consume InputMap, // so that a CTRL+S event saves the document and consumes the event Nodes.addInputMap(area, consume(keyPressed(S, CONTROL_DOWN), event -> save()));Overriding default mouse behavior
The area's default mouse behavior properly handles auto-scrolling and dragging the selected text to a new location. As such, some parts cannot be partially overridden without it affecting other behavior.The following lists either
EventPatterns that cannot be overridden without negatively affecting the default mouse behavior or describe how to safely override things in a special way without disrupting the auto scroll behavior.-
First (1 click count) Primary Button Mouse Pressed Events:
(
EventPattern.mousePressed(MouseButton.PRIMARY).onlyIf(e -> e.getClickCount() == 1)). Do not override. Instead, useonOutsideSelectionMousePressed,onInsideSelectionMousePressReleased, or see next item. - (
All Other Mouse Pressed Events (e.g., Primary with 2+ click count):
Aside from hiding the context menu if it is showing (use
ViewActions.hideContextMenu()some((where in your overriding InputMap to maintain this behavior), these can be safely overridden via any of theInputMapTemplate's factory methodsorInputMap's factory methods. -
Primary-Button-only Mouse Drag Detection Events:
(
EventPattern.eventType(MouseEvent.DRAG_DETECTED).onlyIf(e -> e.getButton() == MouseButton.PRIMARY && !e.isMiddleButtonDown() && !e.isSecondaryButtonDown())). Do not override. Instead, useonNewSelectionDragoronSelectionDrag. -
Primary-Button-only Mouse Drag Events:
(
EventPattern.mouseDragged().onlyIf(e -> e.getButton() == MouseButton.PRIMARY && !e.isMiddleButtonDown() && !e.isSecondaryButtonDown())) Do not override, but see next item. -
All Other Mouse Drag Events:
You may safely override other Mouse Drag Events using different
EventPatterns without affecting default behavior only if process InputMaps (InputMapTemplate.process(javafx.event.EventType, BiFunction),InputMapTemplate.process(org.fxmisc.wellbehaved.event.EventPattern, BiFunction),InputMap.process(javafx.event.EventType, Function), orInputMap.process(org.fxmisc.wellbehaved.event.EventPattern, Function)) are used andInputHandler.Result.PROCEEDis returned. The area has a "catch all" Mouse Drag InputMap that will auto scroll towards the mouse drag event when it occurs outside the bounds of the area and will stop auto scrolling when the mouse event occurs within the area. However, this only works if the event is not consumed before the event reaches that InputMap. To insure the auto scroll feature is enabled, setisAutoScrollOnDragDesired()to true in your process InputMap. If the feature is not desired for that specific drag event, set it to false in the process InputMap. Note: Due to this "catch-all" nature, all Mouse Drag Events are consumed. -
Primary-Button-only Mouse Released Events:
(
EventPattern.mouseReleased().onlyIf(e -> e.getButton() == MouseButton.PRIMARY && !e.isMiddleButtonDown() && !e.isSecondaryButtonDown())). Do not override. Instead, useonNewSelectionDragFinished,onSelectionDropped, or see next item. -
All other Mouse Released Events:
You may override other Mouse Released Events using different
EventPatterns without affecting default behavior only if process InputMaps (InputMapTemplate.process(javafx.event.EventType, BiFunction),InputMapTemplate.process(org.fxmisc.wellbehaved.event.EventPattern, BiFunction),InputMap.process(javafx.event.EventType, Function), orInputMap.process(org.fxmisc.wellbehaved.event.EventPattern, Function)) are used andInputHandler.Result.PROCEEDis returned. The area has a "catch-all" InputMap that will consume all mouse released events and stop auto scroll if it was scrolling. However, this only works if the event is not consumed before the event reaches that InputMap. Note: Due to this "catch-all" nature, all Mouse Released Events are consumed.
CSS, Style Classes, and Pseudo Classes
Refer to the RichTextFX CSS Reference Guide .
Area Actions and Other Operations
To distinguish the actual operations one can do on this area from the boilerplate methods within this area (e.g. properties and their getters/setters, etc.), look at the interfaces this area implements. Each lists and documents methods that fall under that category.
To update multiple portions of the area's underlying document in one call, see
createMultiChange().Calculating a Position Within the Area
To calculate a position or index within the area, read through the javadoc of
TwoDimensionalandTwoDimensional.Bias. Also, read the difference between "position" and "index" inStyledDocument.getAbsolutePosition(int, int).
-
-
Property Summary
-
Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
-
Properties inherited from class javafx.scene.Parent
needsLayout
-
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
Properties inherited from interface org.fxmisc.richtext.TextEditingArea
anchor, caretBounds, caretColumn, caretPosition, currentParagraph, selectedText, selectionBounds, selection, showCaret
-
Properties inherited from interface org.fxmisc.richtext.UndoActions
redoAvailable, undoAvailable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.NavigationActions
NavigationActions.SelectionPolicy
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.model.TwoDimensional
TwoDimensional.Bias, TwoDimensional.Position
-
-
Field Summary
Fields Modifier and Type Field Description static IndexRangeEMPTY_RANGEIndex range [0, 0).protected booleanfoldCheck-
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
-
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Constructor Summary
Constructors Constructor Description GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, EditableStyledDocument<PS,SEG,S> document, TextOps<SEG,S> segmentOps, boolean preserveStyle, Function<StyledSegment<SEG,S>,Node> nodeFactory)Creates an area with flexibility in all of its options.GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, EditableStyledDocument<PS,SEG,S> document, TextOps<SEG,S> segmentOps, Function<StyledSegment<SEG,S>,Node> nodeFactory)The same asGenericStyledArea(Object, BiConsumer, Object, TextOps, Function)except that this constructor can be used to create anotherGenericStyledAreathat renders and edits the sameEditableStyledDocumentor when one wants to use a customEditableStyledDocumentimplementation.GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, TextOps<SEG,S> segmentOps, boolean preserveStyle, Function<StyledSegment<SEG,S>,Node> nodeFactory)Same asGenericStyledArea(Object, BiConsumer, Object, TextOps, Function)but also allows one to specify whether the undo manager should be a plain or rich undo manager viapreserveStyle.GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, TextOps<SEG,S> segmentOps, Function<StyledSegment<SEG,S>,Node> nodeFactory)Creates a text area with empty text content.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddCaret(CaretNode caret)booleanaddSelection(Selection<PS,SEG,S> selection)Optional<Integer>allParToVisibleParIndex(int allParIndex)Maps a paragraph index fromTextEditingArea.getParagraphs()into the index system ofViewActions.getVisibleParagraphs().BooleanPropertyautoHeightProperty()BooleanPropertyautoScrollOnDragDesiredProperty()SuspendableNobeingUpdatedProperty()True when an update to the area'sunderling editable documentis still occurring or the viewport is being updated.protected doublecomputePrefHeight(double width)protected voidconfigurePlaceholder(Node placeholder)Override this to customize the placeholder's layout.ObjectProperty<ContextMenu>contextMenuObjectProperty()DoublePropertycontextMenuXOffsetProperty()DoublePropertycontextMenuYOffsetProperty()MultiChangeBuilder<PS,SEG,S>createMultiChange()Starts building a list of changes to be used to update multiple portions of the underlying document in one call.MultiChangeBuilder<PS,SEG,S>createMultiChange(int initialNumOfChanges)Same asTextEditingArea.createMultiChange()but the number of changes are specified to be more memory efficient.voiddisplaceCaret(int pos)voiddispose()Disposes this area, preventing memory leaks.BooleanPropertyeditableProperty()Var<Double>estimatedScrollXProperty()The estimated scrollX value.Var<Double>estimatedScrollYProperty()The estimated scrollY value.protected voidfold(int startPos, int endPos, UnaryOperator<PS> styleMixin)Folds (hides/collapses) paragraphs from character positionstartPostoendPos, into (i.e.protected voidfoldParagraphs(int start, int end, UnaryOperator<PS> styleMixin)Folds (hides/collapses) paragraphs fromstarttoend, into (i.e.protected voidfoldSelectedParagraphs(UnaryOperator<PS> styleMixin)Convenience method to fold (hide/collapse) the currently selected paragraphs, into (i.e.intgetAbsolutePosition(int paragraphIndex, int columnIndex)Returns the absolute position (i.e.BiConsumer<TextFlow,PS>getApplyParagraphStyle()Gets the style applicator.<T extends Node & Caret>
Optional<Bounds>getCaretBoundsOnScreen(T caret)Using the paragraph index of the "all paragraph" index system, returns the bounds of a caret on the given paragraph orOptional.empty()if no caret is on that paragraph or the pragraph is not visible.CaretSelectionBind<PS,SEG,S>getCaretSelectionBind()Gets the area's mainCaretSelectionBind.Optional<Bounds>getCharacterBoundsOnScreen(int from, int to)Gets the character bounds on screenstatic List<CssMetaData<? extends Styleable,?>>getClassCssMetaData()EditableStyledDocument<PS,SEG,S>getContent()The underlying document of this area that can be displayed by multipleStyledTextAreas.ContextMenugetContextMenu()Gets theContextMenufor the area, which is by default null.doublegetContextMenuXOffset()Gets the value of the property contextMenuXOffset.doublegetContextMenuYOffset()Gets the value of the property contextMenuYOffset.List<CssMetaData<? extends Styleable,?>>getCssMetaData()intgetCurrentLineEndInParargraph()intgetCurrentLineStartInParargraph()StyledDocument<PS,SEG,S>getDocument()Rich-text content of this text-editing area.PSgetInitialParagraphStyle()Style used by default when no other style is provided.SgetInitialTextStyle()Style used by default when no other style is provided.LocalegetLocale()This is used to determine word and sentence breaks while navigating or selecting.EventHandler<MouseEvent>getOnInsideSelectionMousePressReleased()Gets the value of the property onInsideSelectionMousePressReleased.EventHandler<MouseEvent>getOnNewSelectionDragFinished()Gets the value of the property onNewSelectionDragFinished.EventHandler<MouseEvent>getOnOutsideSelectionMousePressed()Gets the value of the property onOutsideSelectionMousePressed.EventHandler<MouseEvent>getOnSelectionDropped()Gets the value of the property onSelectionDropped.Optional<Bounds>getParagraphBoundsOnScreen(int paragraphIndex)Returns the bounds of the paragraph if it is visible orOptional.empty()if it's not.NodegetParagraphGraphic(int parNdx)PSgetParagraphInsertionStyle()intgetParagraphLinesCount(int paragraphIndex)Gets the number of lines a paragraph spans whenViewActions.isWrapText()is true, or otherwise returns 1.LiveList<Paragraph<PS,SEG,S>>getParagraphs()Unmodifiable observable list of paragraphs in this text area.IndexRangegetParagraphSelection(Selection selection, int paragraph)PSgetParagraphStyleForInsertionAt(int pos)ReturnsStyleActions.getInitialParagraphStyle()ifStyleActions.getUseInitialStyleForInsertion()is true; otherwise, returns the paragraph style at the given position.NodegetPlaceholder()Gets the value of the property placeholder.TextOps<SEG,S>getSegOps()Returns the object used for operating oversegmentsand their stylesSgetStyleAtPosition(int position)Returns the style at the given position.SgetStyleAtPosition(int paragraph, int position)Returns the style at the given position in the given paragraph.Optional<Tuple2<Codec<PS>,Codec<StyledSegment<SEG,S>>>>getStyleCodecs()Gets codecs to encode/decode style information to/from binary format.SgetStyleOfChar(int index)Returns the style of the character with the given index.SgetStyleOfChar(int paragraph, int index)Returns the style of the character with the given index in the given paragraph.IndexRangegetStyleRangeAtPosition(int position)Returns the range of homogeneous style that includes the given position.IndexRangegetStyleRangeAtPosition(int paragraph, int position)Returns the range of homogeneous style that includes the given position in the given paragraph.StyleSpans<S>getStyleSpans(int paragraph)Returns styles of the whole paragraph.StyleSpans<S>getStyleSpans(int from, int to)Returns the styles in the given character range.StyleSpans<S>getStyleSpans(int paragraph, int from, int to)Returns the styles in the given character range of the given paragraph.StringgetText(int paragraph)Returns text content of the given paragraph.StringgetText(int start, int end)Returns text content of the given character range.StringgetText(IndexRange range)Returns text content of the given character range.SgetTextInsertionStyle()SgetTextStyleForInsertionAt(int pos)ReturnsStyleActions.getInitialTextStyle()ifStyleActions.getUseInitialStyleForInsertion()is true; otherwise, returns the style at the given position.UndoManagergetUndoManager()Undo manager of this text area.doublegetViewportHeight()Gets the height of the viewport and ignores the padding values added to the area.BoundsgetVisibleParagraphBoundsOnScreen(int visibleParagraphIndex)Returns the bounds of the paragraph if it is visible orOptional.empty()if it's not.LiveList<Paragraph<PS,SEG,S>>getVisibleParagraphs()Gets the visible paragraphs, even the ones that are barely displayed.protected voidhandleInputMethodEvent(InputMethodEvent event)CharacterHithit(double x, double y)Helpful for determining which letter is at point x, y:booleanisAutoHeight()Gets the value of the property autoHeight.booleanisAutoScrollOnDragDesired()Gets the value of the property autoScrollOnDragDesired.protected booleanisContextMenuPresent()booleanisEditable()Gets the value of the property editable.booleanisLineHighlighterOn()booleanisOverwriteMode()Gets the value of the property overwriteMode.booleanisPreserveStyle()Indicates whether style should be preserved on undo/redo (and in the future copy/paste and text move).booleanisWrapText()Gets the value of the property wrapText.protected voidlayoutChildren()ObservableValue<Integer>lengthProperty()voidlineEnd(NavigationActions.SelectionPolicy policy)Move the caret to the end of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraphintlineIndex(int paragraphIndex, int columnPosition)Returns 0 if the given paragraph displays its content across only one line, or returns the index of the line on which the given column position appears if the paragraph spans multiple lines.voidlineStart(NavigationActions.SelectionPolicy policy)Move the caret to the start of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraphObjectProperty<Duration>mouseOverTextDelayProperty()EventStream<List<PlainTextChange>>multiPlainChanges()EventStream<List<RichTextChange<PS,SEG,S>>>multiRichChanges()voidnextLine(NavigationActions.SelectionPolicy selectionPolicy)Scrolls the text one line UP while maintaining the caret's position on screen, so that it is now on the NEXT line.voidnextPage(NavigationActions.SelectionPolicy selectionPolicy)Moves caret to the next page (i.e.TwoDimensional.PositionoffsetToPosition(int charOffset, TwoDimensional.Bias bias)Creates a two dimensional position in some entity (e.g.ObjectProperty<EventHandler<MouseEvent>>onInsideSelectionMousePressReleasedProperty()ObjectProperty<EventHandler<MouseEvent>>onNewSelectionDragFinishedProperty()ObjectProperty<Consumer<Point2D>>onNewSelectionDragProperty()ObjectProperty<EventHandler<MouseEvent>>onOutsideSelectionMousePressedProperty()ObjectProperty<Consumer<Point2D>>onSelectionDragProperty()ObjectProperty<EventHandler<MouseEvent>>onSelectionDroppedProperty()ReadOnlyBooleanPropertyoverwriteModeProperty()Indicates weather the area is in overwrite or insert mode.ObjectProperty<IntFunction<? extends Node>>paragraphGraphicFactoryProperty()ObjectProperty<Node>placeholderProperty()EventStream<PlainTextChange>plainTextChanges()TwoDimensional.Positionposition(int row, int col)Creates a two dimensional position in some entity (e.g.voidprevLine(NavigationActions.SelectionPolicy selectionPolicy)Scrolls the text one line DOWN while maintaining the caret's position on screen, so that it is now on the PREVIOUS line.voidprevPage(NavigationActions.SelectionPolicy selectionPolicy)Moves caret to the previous page (i.e.voidrecreateParagraphGraphic(int parNdx)booleanremoveCaret(CaretNode caret)booleanremoveSelection(Selection<PS,SEG,S> selection)voidreplace(int start, int end, StyledDocument<PS,SEG,S> replacement)Replaces a range of characters with the given rich-text document.voidreplace(int start, int end, SEG seg, S style)Replaces a range of characters with the given segment.voidreplaceText(int start, int end, String text)Replaces a range of characters with the given text.voidrequestFollowCaret()If the caret is not visible within the area's view, the area will scroll so that caret is visible in the next layout pass.EventStream<RichTextChange<PS,SEG,S>>richChanges()voidscrollBy(Point2D deltas)voidscrollXBy(double deltaX)voidscrollXToPixel(double pixel)voidscrollYBy(double deltaY)voidscrollYToPixel(double pixel)voidsetAutoHeight(boolean value)Sets the value of the property autoHeight.voidsetAutoScrollOnDragDesired(boolean val)Sets the value of the property autoScrollOnDragDesired.voidsetContextMenu(ContextMenu menu)voidsetContextMenuXOffset(double offset)Sets the value of the property contextMenuXOffset.voidsetContextMenuYOffset(double offset)Sets the value of the property contextMenuYOffset.voidsetEditable(boolean value)Sets the value of the property editable.voidsetLineHighlighterFill(Paint highlight)The default fill is "highlighter" yellow.voidsetLineHighlighterOn(boolean show)Highlights the line that the main caret is on.
Line highlighting automatically follows the caret.voidsetLocale(Locale editorLocale)voidsetOnInsideSelectionMousePressReleased(EventHandler<MouseEvent> handler)Sets the value of the property onInsideSelectionMousePressReleased.voidsetOnNewSelectionDragFinished(EventHandler<MouseEvent> handler)Sets the value of the property onNewSelectionDragFinished.voidsetOnOutsideSelectionMousePressed(EventHandler<MouseEvent> handler)Sets the value of the property onOutsideSelectionMousePressed.voidsetOnSelectionDropped(EventHandler<MouseEvent> handler)Sets the value of the property onSelectionDropped.voidsetParagraphInsertionStyle(PS paraStyle)If you want to preset the style to be used.voidsetParagraphStyle(int paragraph, PS paragraphStyle)Sets style for the whole paragraph.voidsetPlaceholder(Node value)This Node is shown to the user, centered over the area, when the area has no text content.voidsetPlaceholder(Node value, Pos where)voidsetStyle(int paragraph, int from, int to, S style)Sets style for the given range relative in the given paragraph.voidsetStyle(int from, int to, S style)Sets style for the given character range.voidsetStyle(int paragraph, S style)Sets style for the whole paragraph.voidsetStyleCodecs(Codec<PS> paragraphStyleCodec, Codec<StyledSegment<SEG,S>> styledSegCodec)voidsetStyleSpans(int paragraph, int from, StyleSpans<? extends S> styleSpans)Set multiple style ranges of a paragraph at once.voidsetStyleSpans(int from, StyleSpans<? extends S> styleSpans)Set multiple style ranges at once.voidsetTextInsertionStyle(S txtStyle)If you want to preset the style to be used for inserted text.voidsetUndoManager(UndoManager undoManager)Closes the current area's undo manager before setting it to the given one.voidsetWrapText(boolean value)Sets the value of the property wrapText.voidshowParagraphAtBottom(int paragraphIndex)Lays out the viewport so that the paragraph is the last line (bottom) displayed in the viewport.voidshowParagraphAtCenter(int paragraphIndex)voidshowParagraphAtTop(int paragraphIndex)Lays out the viewport so that the paragraph is the first line (top) displayed in the viewport.voidshowParagraphInViewport(int paragraphIndex)Shows the paragraph somewhere in the viewport.voidshowParagraphRegion(int paragraphIndex, Bounds region)Lays out the viewport so that the given bounds (according to the paragraph's coordinate system) within the given paragraph is visible in the viewport.StyledDocument<PS,SEG,S>subDocument(int paragraphIndex)Returns rich-text content of the given paragraph.StyledDocument<PS,SEG,S>subDocument(int start, int end)Returns rich-text content of the given character range.ObservableValue<String>textProperty()Val<Double>totalHeightEstimateProperty()The estimated height of the entire document.Val<Double>totalWidthEstimateProperty()The estimated width of the entire document.protected voidunfoldParagraphs(int startingFrom, Predicate<PS> isFolded, UnaryOperator<PS> styleMixin)Unfolds paragraphsstartingFromonwards for the currently folded block.BooleanPropertyuseInitialStyleForInsertionProperty()EventStream<?>viewportDirtyEvents()Returns anEventStreamthat emits anullvalue every time the viewport becomes dirty (e.g.intvisibleParToAllParIndex(int visibleParIndex)Maps a paragraph index fromViewActions.getVisibleParagraphs()into the index system ofTextEditingArea.getParagraphs().BooleanPropertywrapTextProperty()-
Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
-
Methods inherited from class javafx.scene.Parent
getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.fxmisc.richtext.ClipboardActions
copy, cut, paste
-
Methods inherited from interface org.fxmisc.richtext.EditActions
append, append, appendText, clear, deleteNextChar, deletePreviousChar, deleteText, deleteText, deleteText, insert, insert, insert, insertText, insertText, moveSelectedText, replace, replaceSelection, replaceSelection, replaceText
-
Methods inherited from interface org.fxmisc.richtext.NavigationActions
deselect, end, moveTo, moveTo, moveTo, moveTo, nextChar, paragraphEnd, paragraphStart, previousChar, selectAll, selectParagraph, selectWord, start, wordBreaksBackwards, wordBreaksForwards
-
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
Methods inherited from interface org.fxmisc.richtext.StyleActions
clearParagraphStyle, clearStyle, clearStyle, clearStyle, getStyleSpans, getStyleSpans, getUseInitialStyleForInsertion, setUseInitialStyleForInsertion
-
Methods inherited from interface org.fxmisc.richtext.TextEditingArea
anchorProperty, caretBoundsProperty, caretColumnProperty, caretPositionProperty, currentParagraphProperty, getAnchor, getCaretBounds, getCaretColumn, getCaretPosition, getCurrentParagraph, getLength, getParagraph, getParagraphLength, getParagraphSelection, getSelectedText, getSelection, getSelectionBounds, getShowCaret, getText, getText, isBeingUpdated, replace, replace, replace, replace, replaceText, replaceText, selectedTextProperty, selectionBoundsProperty, selectionProperty, selectRange, selectRange, setShowCaret, showCaretProperty, subDocument, subDocument
-
Methods inherited from interface org.fxmisc.richtext.UndoActions
isRedoAvailable, isUndoAvailable, redo, redoAvailableProperty, undo, undoAvailableProperty
-
Methods inherited from interface org.fxmisc.richtext.ViewActions
firstVisibleParToAllParIndex, getMouseOverTextDelay, getOnNewSelectionDrag, getOnSelectionDrag, getParagraphGraphicFactory, hideContextMenu, lastVisibleParToAllParIndex, selectLine, setMouseOverTextDelay, setOnNewSelectionDrag, setOnSelectionDrag, setParagraphGraphicFactory
-
Methods inherited from interface org.fxmisc.flowless.Virtualized
getEstimatedScrollX, getEstimatedScrollY, getTotalHeightEstimate, getTotalWidthEstimate, scrollBy, scrollToPixel, scrollToPixel
-
-
-
-
Property Detail
-
editable
public final BooleanProperty editableProperty
- Specified by:
editablePropertyin interfaceViewActions<PS,SEG,S>- See Also:
isEditable(),setEditable(boolean)
-
overwriteMode
public final ReadOnlyBooleanProperty overwriteModeProperty
Indicates weather the area is in overwrite or insert mode.- See Also:
isOverwriteMode()
-
wrapText
public final BooleanProperty wrapTextProperty
- Specified by:
wrapTextPropertyin interfaceViewActions<PS,SEG,S>- See Also:
isWrapText(),setWrapText(boolean)
-
mouseOverTextDelay
public ObjectProperty<Duration> mouseOverTextDelayProperty
- Specified by:
mouseOverTextDelayPropertyin interfaceViewActions<PS,SEG,S>
-
paragraphGraphicFactory
public ObjectProperty<IntFunction<? extends Node>> paragraphGraphicFactoryProperty
- Specified by:
paragraphGraphicFactoryPropertyin interfaceViewActions<PS,SEG,S>
-
placeholder
public final ObjectProperty<Node> placeholderProperty
- See Also:
getPlaceholder(),setPlaceholder(Node)
-
contextMenuObject
public final ObjectProperty<ContextMenu> contextMenuObjectProperty
- Specified by:
contextMenuObjectPropertyin interfaceViewActions<PS,SEG,S>
-
contextMenuXOffset
public final DoubleProperty contextMenuXOffsetProperty
- Specified by:
contextMenuXOffsetPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getContextMenuXOffset(),setContextMenuXOffset(double)
-
contextMenuYOffset
public final DoubleProperty contextMenuYOffsetProperty
- Specified by:
contextMenuYOffsetPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getContextMenuYOffset(),setContextMenuYOffset(double)
-
useInitialStyleForInsertion
public BooleanProperty useInitialStyleForInsertionProperty
- Specified by:
useInitialStyleForInsertionPropertyin interfaceStyleActions<PS,SEG>
-
estimatedScrollX
public Var<Double> estimatedScrollXProperty
- Specified by:
estimatedScrollXPropertyin interfaceViewActions<PS,SEG,S>- Specified by:
estimatedScrollXPropertyin interfaceVirtualized
-
estimatedScrollY
public Var<Double> estimatedScrollYProperty
- Specified by:
estimatedScrollYPropertyin interfaceViewActions<PS,SEG,S>- Specified by:
estimatedScrollYPropertyin interfaceVirtualized
-
onOutsideSelectionMousePressed
public final ObjectProperty<EventHandler<MouseEvent>> onOutsideSelectionMousePressedProperty
- Specified by:
onOutsideSelectionMousePressedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnOutsideSelectionMousePressed(),setOnOutsideSelectionMousePressed(EventHandler)
-
onInsideSelectionMousePressReleased
public final ObjectProperty<EventHandler<MouseEvent>> onInsideSelectionMousePressReleasedProperty
- Specified by:
onInsideSelectionMousePressReleasedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnInsideSelectionMousePressReleased(),setOnInsideSelectionMousePressReleased(EventHandler)
-
onNewSelectionDrag
public final ObjectProperty<Consumer<Point2D>> onNewSelectionDragProperty
- Specified by:
onNewSelectionDragPropertyin interfaceViewActions<PS,SEG,S>
-
onNewSelectionDragFinished
public final ObjectProperty<EventHandler<MouseEvent>> onNewSelectionDragFinishedProperty
- Specified by:
onNewSelectionDragFinishedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnNewSelectionDragFinished(),setOnNewSelectionDragFinished(EventHandler)
-
onSelectionDrag
public final ObjectProperty<Consumer<Point2D>> onSelectionDragProperty
- Specified by:
onSelectionDragPropertyin interfaceViewActions<PS,SEG,S>
-
onSelectionDropped
public final ObjectProperty<EventHandler<MouseEvent>> onSelectionDroppedProperty
- Specified by:
onSelectionDroppedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnSelectionDropped(),setOnSelectionDropped(EventHandler)
-
autoScrollOnDragDesired
public final BooleanProperty autoScrollOnDragDesiredProperty
- Specified by:
autoScrollOnDragDesiredPropertyin interfaceViewActions<PS,SEG,S>- See Also:
isAutoScrollOnDragDesired(),setAutoScrollOnDragDesired(boolean)
-
text
public final ObservableValue<String> textProperty
- Specified by:
textPropertyin interfaceTextEditingArea<PS,SEG,S>
-
length
public final ObservableValue<Integer> lengthProperty
- Specified by:
lengthPropertyin interfaceTextEditingArea<PS,SEG,S>
-
beingUpdated
public final SuspendableNo beingUpdatedProperty
- Specified by:
beingUpdatedPropertyin interfaceTextEditingArea<PS,SEG,S>
-
totalWidthEstimate
public Val<Double> totalWidthEstimateProperty
- Specified by:
totalWidthEstimatePropertyin interfaceViewActions<PS,SEG,S>- Specified by:
totalWidthEstimatePropertyin interfaceVirtualized
-
totalHeightEstimate
public Val<Double> totalHeightEstimateProperty
- Specified by:
totalHeightEstimatePropertyin interfaceViewActions<PS,SEG,S>- Specified by:
totalHeightEstimatePropertyin interfaceVirtualized
-
autoHeight
public BooleanProperty autoHeightProperty
- See Also:
isAutoHeight(),setAutoHeight(boolean)
-
-
Field Detail
-
EMPTY_RANGE
public static final IndexRange EMPTY_RANGE
Index range [0, 0).
-
foldCheck
protected boolean foldCheck
-
-
Constructor Detail
-
GenericStyledArea
public GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, TextOps<SEG,S> segmentOps, Function<StyledSegment<SEG,S>,Node> nodeFactory)
Creates a text area with empty text content.- Parameters:
initialParagraphStyle- style to use in places where no other style is specified (yet).applyParagraphStyle- function that, given aTextFlownode and a style, applies the style to the paragraph node. This function is used by the default skin to apply style to paragraph nodes.initialTextStyle- style to use in places where no other style is specified (yet).segmentOps- The operations which are defined on the text segment objects.nodeFactory- A function which is used to create the JavaFX scene nodes for a particular segment.
-
GenericStyledArea
public GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, TextOps<SEG,S> segmentOps, boolean preserveStyle, Function<StyledSegment<SEG,S>,Node> nodeFactory)
Same asGenericStyledArea(Object, BiConsumer, Object, TextOps, Function)but also allows one to specify whether the undo manager should be a plain or rich undo manager viapreserveStyle.- Parameters:
initialParagraphStyle- style to use in places where no other style is specified (yet).applyParagraphStyle- function that, given aTextFlownode and a style, applies the style to the paragraph node. This function is used by the default skin to apply style to paragraph nodes.initialTextStyle- style to use in places where no other style is specified (yet).segmentOps- The operations which are defined on the text segment objects.preserveStyle- whether to use an undo manager that can undo/redoRichTextChanges orPlainTextChangesnodeFactory- A function which is used to create the JavaFX scene node for a particular segment.
-
GenericStyledArea
public GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, EditableStyledDocument<PS,SEG,S> document, TextOps<SEG,S> segmentOps, Function<StyledSegment<SEG,S>,Node> nodeFactory)
The same asGenericStyledArea(Object, BiConsumer, Object, TextOps, Function)except that this constructor can be used to create anotherGenericStyledAreathat renders and edits the sameEditableStyledDocumentor when one wants to use a customEditableStyledDocumentimplementation.
-
GenericStyledArea
public GenericStyledArea(PS initialParagraphStyle, BiConsumer<TextFlow,PS> applyParagraphStyle, S initialTextStyle, EditableStyledDocument<PS,SEG,S> document, TextOps<SEG,S> segmentOps, boolean preserveStyle, Function<StyledSegment<SEG,S>,Node> nodeFactory)
Creates an area with flexibility in all of its options.- Parameters:
initialParagraphStyle- style to use in places where no other style is specified (yet).applyParagraphStyle- function that, given aTextFlownode and a style, applies the style to the paragraph node. This function is used by the default skin to apply style to paragraph nodes.initialTextStyle- style to use in places where no other style is specified (yet).document- the document to render and editsegmentOps- The operations which are defined on the text segment objects.preserveStyle- whether to use an undo manager that can undo/redoRichTextChanges orPlainTextChangesnodeFactory- A function which is used to create the JavaFX scene node for a particular segment.
-
-
Method Detail
-
editableProperty
public final BooleanProperty editableProperty()
- Specified by:
editablePropertyin interfaceViewActions<PS,SEG,S>- See Also:
isEditable(),setEditable(boolean)
-
setEditable
public void setEditable(boolean value)
Sets the value of the property editable.- Specified by:
setEditablein interfaceViewActions<PS,SEG,S>- Property description:
-
isEditable
public boolean isEditable()
Gets the value of the property editable.- Specified by:
isEditablein interfaceViewActions<PS,SEG,S>- Property description:
-
overwriteModeProperty
public final ReadOnlyBooleanProperty overwriteModeProperty()
Indicates weather the area is in overwrite or insert mode.- See Also:
isOverwriteMode()
-
isOverwriteMode
public boolean isOverwriteMode()
Gets the value of the property overwriteMode.- Property description:
- Indicates weather the area is in overwrite or insert mode.
-
wrapTextProperty
public final BooleanProperty wrapTextProperty()
- Specified by:
wrapTextPropertyin interfaceViewActions<PS,SEG,S>- See Also:
isWrapText(),setWrapText(boolean)
-
setWrapText
public void setWrapText(boolean value)
Sets the value of the property wrapText.- Specified by:
setWrapTextin interfaceViewActions<PS,SEG,S>- Property description:
-
isWrapText
public boolean isWrapText()
Gets the value of the property wrapText.- Specified by:
isWrapTextin interfaceViewActions<PS,SEG,S>- Property description:
-
getUndoManager
public UndoManager getUndoManager()
Description copied from interface:UndoActionsUndo manager of this text area.- Specified by:
getUndoManagerin interfaceUndoActions
-
setUndoManager
public void setUndoManager(UndoManager undoManager)
Description copied from interface:UndoActionsCloses the current area's undo manager before setting it to the given one. Note: to create your ownUndoManager, see the convenient factory methods inUndoUtils.- Specified by:
setUndoManagerin interfaceUndoActions- Parameters:
undoManager- may be null in which case a no op undo manager will be set.
-
getLocale
public Locale getLocale()
This is used to determine word and sentence breaks while navigating or selecting. Override this method if your paragraph or text style accommodates Locales as well.- Specified by:
getLocalein interfaceTextEditingArea<PS,SEG,S>- Returns:
- Locale.getDefault() by default
-
setLocale
public void setLocale(Locale editorLocale)
-
mouseOverTextDelayProperty
public ObjectProperty<Duration> mouseOverTextDelayProperty()
- Specified by:
mouseOverTextDelayPropertyin interfaceViewActions<PS,SEG,S>
-
paragraphGraphicFactoryProperty
public ObjectProperty<IntFunction<? extends Node>> paragraphGraphicFactoryProperty()
- Specified by:
paragraphGraphicFactoryPropertyin interfaceViewActions<PS,SEG,S>
-
recreateParagraphGraphic
public void recreateParagraphGraphic(int parNdx)
-
getParagraphGraphic
public Node getParagraphGraphic(int parNdx)
-
setPlaceholder
public final void setPlaceholder(Node value)
This Node is shown to the user, centered over the area, when the area has no text content.
To customize the placeholder's layout overrideconfigurePlaceholder( Node )
-
placeholderProperty
public final ObjectProperty<Node> placeholderProperty()
- See Also:
getPlaceholder(),setPlaceholder(Node)
-
getPlaceholder
public final Node getPlaceholder()
Gets the value of the property placeholder.- Property description:
-
contextMenuObjectProperty
public final ObjectProperty<ContextMenu> contextMenuObjectProperty()
- Specified by:
contextMenuObjectPropertyin interfaceViewActions<PS,SEG,S>
-
setContextMenu
public void setContextMenu(ContextMenu menu)
- Specified by:
setContextMenuin interfaceViewActions<PS,SEG,S>
-
getContextMenu
public ContextMenu getContextMenu()
Description copied from interface:ViewActionsGets theContextMenufor the area, which is by default null.- Specified by:
getContextMenuin interfaceViewActions<PS,SEG,S>
-
isContextMenuPresent
protected final boolean isContextMenuPresent()
-
contextMenuXOffsetProperty
public final DoubleProperty contextMenuXOffsetProperty()
- Specified by:
contextMenuXOffsetPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getContextMenuXOffset(),setContextMenuXOffset(double)
-
setContextMenuXOffset
public void setContextMenuXOffset(double offset)
Sets the value of the property contextMenuXOffset.- Specified by:
setContextMenuXOffsetin interfaceViewActions<PS,SEG,S>- Property description:
-
getContextMenuXOffset
public double getContextMenuXOffset()
Gets the value of the property contextMenuXOffset.- Specified by:
getContextMenuXOffsetin interfaceViewActions<PS,SEG,S>- Property description:
-
contextMenuYOffsetProperty
public final DoubleProperty contextMenuYOffsetProperty()
- Specified by:
contextMenuYOffsetPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getContextMenuYOffset(),setContextMenuYOffset(double)
-
setContextMenuYOffset
public void setContextMenuYOffset(double offset)
Sets the value of the property contextMenuYOffset.- Specified by:
setContextMenuYOffsetin interfaceViewActions<PS,SEG,S>- Property description:
-
getContextMenuYOffset
public double getContextMenuYOffset()
Gets the value of the property contextMenuYOffset.- Specified by:
getContextMenuYOffsetin interfaceViewActions<PS,SEG,S>- Property description:
-
useInitialStyleForInsertionProperty
public BooleanProperty useInitialStyleForInsertionProperty()
- Specified by:
useInitialStyleForInsertionPropertyin interfaceStyleActions<PS,SEG>
-
setStyleCodecs
public void setStyleCodecs(Codec<PS> paragraphStyleCodec, Codec<StyledSegment<SEG,S>> styledSegCodec)
- Specified by:
setStyleCodecsin interfaceClipboardActions<PS,SEG,S>
-
getStyleCodecs
public Optional<Tuple2<Codec<PS>,Codec<StyledSegment<SEG,S>>>> getStyleCodecs()
Description copied from interface:ClipboardActionsGets codecs to encode/decode style information to/from binary format. Providing codecs enables clipboard actions to retain the style information.- Specified by:
getStyleCodecsin interfaceClipboardActions<PS,SEG,S>
-
estimatedScrollXProperty
public Var<Double> estimatedScrollXProperty()
Description copied from interface:ViewActionsThe estimated scrollX value. This can be set in order to scroll the content. Value is only accurate when area does not wrap lines and uses the same font size throughout the entire area.- Specified by:
estimatedScrollXPropertyin interfaceViewActions<PS,SEG,S>- Specified by:
estimatedScrollXPropertyin interfaceVirtualized
-
estimatedScrollYProperty
public Var<Double> estimatedScrollYProperty()
Description copied from interface:ViewActionsThe estimated scrollY value. This can be set in order to scroll the content. Value is only accurate when area does not wrap lines and uses the same font size throughout the entire area.- Specified by:
estimatedScrollYPropertyin interfaceViewActions<PS,SEG,S>- Specified by:
estimatedScrollYPropertyin interfaceVirtualized
-
addCaret
public final boolean addCaret(CaretNode caret)
-
removeCaret
public final boolean removeCaret(CaretNode caret)
-
getOnOutsideSelectionMousePressed
public final EventHandler<MouseEvent> getOnOutsideSelectionMousePressed()
Gets the value of the property onOutsideSelectionMousePressed.- Specified by:
getOnOutsideSelectionMousePressedin interfaceViewActions<PS,SEG,S>- Property description:
-
setOnOutsideSelectionMousePressed
public final void setOnOutsideSelectionMousePressed(EventHandler<MouseEvent> handler)
Sets the value of the property onOutsideSelectionMousePressed.- Specified by:
setOnOutsideSelectionMousePressedin interfaceViewActions<PS,SEG,S>- Property description:
-
onOutsideSelectionMousePressedProperty
public final ObjectProperty<EventHandler<MouseEvent>> onOutsideSelectionMousePressedProperty()
- Specified by:
onOutsideSelectionMousePressedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnOutsideSelectionMousePressed(),setOnOutsideSelectionMousePressed(EventHandler)
-
getOnInsideSelectionMousePressReleased
public final EventHandler<MouseEvent> getOnInsideSelectionMousePressReleased()
Gets the value of the property onInsideSelectionMousePressReleased.- Specified by:
getOnInsideSelectionMousePressReleasedin interfaceViewActions<PS,SEG,S>- Property description:
-
setOnInsideSelectionMousePressReleased
public final void setOnInsideSelectionMousePressReleased(EventHandler<MouseEvent> handler)
Sets the value of the property onInsideSelectionMousePressReleased.- Specified by:
setOnInsideSelectionMousePressReleasedin interfaceViewActions<PS,SEG,S>- Property description:
-
onInsideSelectionMousePressReleasedProperty
public final ObjectProperty<EventHandler<MouseEvent>> onInsideSelectionMousePressReleasedProperty()
- Specified by:
onInsideSelectionMousePressReleasedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnInsideSelectionMousePressReleased(),setOnInsideSelectionMousePressReleased(EventHandler)
-
onNewSelectionDragProperty
public final ObjectProperty<Consumer<Point2D>> onNewSelectionDragProperty()
- Specified by:
onNewSelectionDragPropertyin interfaceViewActions<PS,SEG,S>
-
getOnNewSelectionDragFinished
public final EventHandler<MouseEvent> getOnNewSelectionDragFinished()
Gets the value of the property onNewSelectionDragFinished.- Specified by:
getOnNewSelectionDragFinishedin interfaceViewActions<PS,SEG,S>- Property description:
-
setOnNewSelectionDragFinished
public final void setOnNewSelectionDragFinished(EventHandler<MouseEvent> handler)
Sets the value of the property onNewSelectionDragFinished.- Specified by:
setOnNewSelectionDragFinishedin interfaceViewActions<PS,SEG,S>- Property description:
-
onNewSelectionDragFinishedProperty
public final ObjectProperty<EventHandler<MouseEvent>> onNewSelectionDragFinishedProperty()
- Specified by:
onNewSelectionDragFinishedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnNewSelectionDragFinished(),setOnNewSelectionDragFinished(EventHandler)
-
onSelectionDragProperty
public final ObjectProperty<Consumer<Point2D>> onSelectionDragProperty()
- Specified by:
onSelectionDragPropertyin interfaceViewActions<PS,SEG,S>
-
getOnSelectionDropped
public final EventHandler<MouseEvent> getOnSelectionDropped()
Gets the value of the property onSelectionDropped.- Specified by:
getOnSelectionDroppedin interfaceViewActions<PS,SEG,S>- Property description:
-
setOnSelectionDropped
public final void setOnSelectionDropped(EventHandler<MouseEvent> handler)
Sets the value of the property onSelectionDropped.- Specified by:
setOnSelectionDroppedin interfaceViewActions<PS,SEG,S>- Property description:
-
onSelectionDroppedProperty
public final ObjectProperty<EventHandler<MouseEvent>> onSelectionDroppedProperty()
- Specified by:
onSelectionDroppedPropertyin interfaceViewActions<PS,SEG,S>- See Also:
getOnSelectionDropped(),setOnSelectionDropped(EventHandler)
-
autoScrollOnDragDesiredProperty
public final BooleanProperty autoScrollOnDragDesiredProperty()
- Specified by:
autoScrollOnDragDesiredPropertyin interfaceViewActions<PS,SEG,S>- See Also:
isAutoScrollOnDragDesired(),setAutoScrollOnDragDesired(boolean)
-
setAutoScrollOnDragDesired
public void setAutoScrollOnDragDesired(boolean val)
Sets the value of the property autoScrollOnDragDesired.- Specified by:
setAutoScrollOnDragDesiredin interfaceViewActions<PS,SEG,S>- Property description:
-
isAutoScrollOnDragDesired
public boolean isAutoScrollOnDragDesired()
Gets the value of the property autoScrollOnDragDesired.- Specified by:
isAutoScrollOnDragDesiredin interfaceViewActions<PS,SEG,S>- Property description:
-
textProperty
public final ObservableValue<String> textProperty()
- Specified by:
textPropertyin interfaceTextEditingArea<PS,SEG,S>
-
getDocument
public final StyledDocument<PS,SEG,S> getDocument()
Description copied from interface:TextEditingAreaRich-text content of this text-editing area. The returned document is immutable, it does not reflect subsequent edits of this text-editing area.- Specified by:
getDocumentin interfaceTextEditingArea<PS,SEG,S>
-
getCaretSelectionBind
public final CaretSelectionBind<PS,SEG,S> getCaretSelectionBind()
Description copied from interface:TextEditingAreaGets the area's mainCaretSelectionBind.- Specified by:
getCaretSelectionBindin interfaceTextEditingArea<PS,SEG,S>
-
lengthProperty
public final ObservableValue<Integer> lengthProperty()
- Specified by:
lengthPropertyin interfaceTextEditingArea<PS,SEG,S>
-
getParagraphs
public LiveList<Paragraph<PS,SEG,S>> getParagraphs()
Description copied from interface:TextEditingAreaUnmodifiable observable list of paragraphs in this text area.- Specified by:
getParagraphsin interfaceTextEditingArea<PS,SEG,S>
-
getVisibleParagraphs
public final LiveList<Paragraph<PS,SEG,S>> getVisibleParagraphs()
Description copied from interface:ViewActionsGets the visible paragraphs, even the ones that are barely displayed.- Specified by:
getVisibleParagraphsin interfaceViewActions<PS,SEG,S>
-
beingUpdatedProperty
public final SuspendableNo beingUpdatedProperty()
Description copied from interface:TextEditingAreaTrue when an update to the area'sunderling editable documentis still occurring or the viewport is being updated.- Specified by:
beingUpdatedPropertyin interfaceTextEditingArea<PS,SEG,S>
-
totalWidthEstimateProperty
public Val<Double> totalWidthEstimateProperty()
Description copied from interface:ViewActionsThe estimated width of the entire document. Accurate when area does not wrap lines and uses the same font size throughout the entire area. Value is only supposed to be set by the skin, not the user.- Specified by:
totalWidthEstimatePropertyin interfaceViewActions<PS,SEG,S>- Specified by:
totalWidthEstimatePropertyin interfaceVirtualized
-
totalHeightEstimateProperty
public Val<Double> totalHeightEstimateProperty()
Description copied from interface:ViewActionsThe estimated height of the entire document. Accurate when area does not wrap lines and uses the same font size throughout the entire area. Value is only supposed to be set by the skin, not the user.- Specified by:
totalHeightEstimatePropertyin interfaceViewActions<PS,SEG,S>- Specified by:
totalHeightEstimatePropertyin interfaceVirtualized
-
multiRichChanges
public EventStream<List<RichTextChange<PS,SEG,S>>> multiRichChanges()
Description copied from interface:TextEditingArea- Specified by:
multiRichChangesin interfaceTextEditingArea<PS,SEG,S>
-
multiPlainChanges
public EventStream<List<PlainTextChange>> multiPlainChanges()
Description copied from interface:TextEditingArea- Specified by:
multiPlainChangesin interfaceTextEditingArea<PS,SEG,S>
-
plainTextChanges
public final EventStream<PlainTextChange> plainTextChanges()
Description copied from interface:TextEditingArea- Specified by:
plainTextChangesin interfaceTextEditingArea<PS,SEG,S>
-
richChanges
public final EventStream<RichTextChange<PS,SEG,S>> richChanges()
Description copied from interface:TextEditingArea- Specified by:
richChangesin interfaceTextEditingArea<PS,SEG,S>
-
viewportDirtyEvents
public final EventStream<?> viewportDirtyEvents()
Description copied from interface:ViewActionsReturns anEventStreamthat emits anullvalue every time the viewport becomes dirty (e.g. the viewport's width, height, scaleX, scaleY, estimatedScrollX, or estimatedScrollY values change)- Specified by:
viewportDirtyEventsin interfaceViewActions<PS,SEG,S>
-
getContent
public final EditableStyledDocument<PS,SEG,S> getContent()
Description copied from interface:TextEditingAreaThe underlying document of this area that can be displayed by multipleStyledTextAreas.- Specified by:
getContentin interfaceTextEditingArea<PS,SEG,S>
-
getInitialTextStyle
public final S getInitialTextStyle()
Description copied from interface:StyleActionsStyle used by default when no other style is provided.- Specified by:
getInitialTextStylein interfaceStyleActions<PS,SEG>
-
getInitialParagraphStyle
public final PS getInitialParagraphStyle()
Description copied from interface:StyleActionsStyle used by default when no other style is provided.- Specified by:
getInitialParagraphStylein interfaceStyleActions<PS,SEG>
-
getApplyParagraphStyle
public final BiConsumer<TextFlow,PS> getApplyParagraphStyle()
Description copied from interface:ViewActionsGets the style applicator.- Specified by:
getApplyParagraphStylein interfaceViewActions<PS,SEG,S>
-
isPreserveStyle
public final boolean isPreserveStyle()
Description copied from interface:StyleActionsIndicates whether style should be preserved on undo/redo (and in the future copy/paste and text move).- Specified by:
isPreserveStylein interfaceStyleActions<PS,SEG>
-
getSegOps
public final TextOps<SEG,S> getSegOps()
Description copied from interface:TextEditingAreaReturns the object used for operating oversegmentsand their styles- Specified by:
getSegOpsin interfaceClipboardActions<PS,SEG,S>- Specified by:
getSegOpsin interfaceTextEditingArea<PS,SEG,S>
-
handleInputMethodEvent
protected void handleInputMethodEvent(InputMethodEvent event)
-
configurePlaceholder
protected void configurePlaceholder(Node placeholder)
Override this to customize the placeholder's layout.
The default position is centered over the area.
-
getViewportHeight
public final double getViewportHeight()
Description copied from interface:ViewActionsGets the height of the viewport and ignores the padding values added to the area.- Specified by:
getViewportHeightin interfaceViewActions<PS,SEG,S>
-
allParToVisibleParIndex
public final Optional<Integer> allParToVisibleParIndex(int allParIndex)
Description copied from interface:ViewActionsMaps a paragraph index fromTextEditingArea.getParagraphs()into the index system ofViewActions.getVisibleParagraphs().- Specified by:
allParToVisibleParIndexin interfaceViewActions<PS,SEG,S>
-
visibleParToAllParIndex
public final int visibleParToAllParIndex(int visibleParIndex)
Description copied from interface:ViewActionsMaps a paragraph index fromViewActions.getVisibleParagraphs()into the index system ofTextEditingArea.getParagraphs().- Specified by:
visibleParToAllParIndexin interfaceViewActions<PS,SEG,S>
-
hit
public CharacterHit hit(double x, double y)
Description copied from interface:ViewActionsHelpful for determining which letter is at point x, y:StyledTextArea area = // creation code area.addEventHandler(MouseEvent.MOUSE_PRESSED, (MouseEvent e) -> { CharacterHit hit = area.hit(e.getX(), e.getY()); int characterPosition = hit.getInsertionIndex(); // move the caret to that character's position area.moveTo(characterPosition, SelectionPolicy.CLEAR); }- Specified by:
hitin interfaceViewActions<PS,SEG,S>
-
lineIndex
public final int lineIndex(int paragraphIndex, int columnPosition)Description copied from interface:ViewActionsReturns 0 if the given paragraph displays its content across only one line, or returns the index of the line on which the given column position appears if the paragraph spans multiple lines.- Specified by:
lineIndexin interfaceViewActions<PS,SEG,S>
-
getParagraphLinesCount
public int getParagraphLinesCount(int paragraphIndex)
Description copied from interface:ViewActionsGets the number of lines a paragraph spans whenViewActions.isWrapText()is true, or otherwise returns 1. CAUTION: the underlying TextFlow does not immediately account for changes in the stage's width when the paragraph in question is a multi-line paragraph andtext wrap is on. After callingWindow.setWidth(double), it may take anywhere between 150-300 milliseconds for TextFlow to account for this and return the correct line count for the given paragraph. Otherwise, it may return a skewed number, such as the total number of characters on the line.- Specified by:
getParagraphLinesCountin interfaceViewActions<PS,SEG,S>
-
getCharacterBoundsOnScreen
public Optional<Bounds> getCharacterBoundsOnScreen(int from, int to)
Description copied from interface:ViewActionsGets the character bounds on screen- Specified by:
getCharacterBoundsOnScreenin interfaceViewActions<PS,SEG,S>- Parameters:
from- the start positionto- the end position- Returns:
- the bounds or
Optional.empty()if line is not visible or the range is only a newline character.
-
getText
public final String getText(int start, int end)
Description copied from interface:TextEditingAreaReturns text content of the given character range.- Specified by:
getTextin interfaceTextEditingArea<PS,SEG,S>
-
getText
public String getText(int paragraph)
Description copied from interface:TextEditingAreaReturns text content of the given paragraph.- Specified by:
getTextin interfaceTextEditingArea<PS,SEG,S>
-
getText
public String getText(IndexRange range)
Description copied from interface:TextEditingAreaReturns text content of the given character range.- Specified by:
getTextin interfaceTextEditingArea<PS,SEG,S>
-
subDocument
public StyledDocument<PS,SEG,S> subDocument(int start, int end)
Description copied from interface:TextEditingAreaReturns rich-text content of the given character range.- Specified by:
subDocumentin interfaceTextEditingArea<PS,SEG,S>
-
subDocument
public StyledDocument<PS,SEG,S> subDocument(int paragraphIndex)
Description copied from interface:TextEditingAreaReturns rich-text content of the given paragraph.- Specified by:
subDocumentin interfaceTextEditingArea<PS,SEG,S>
-
getParagraphSelection
public IndexRange getParagraphSelection(Selection selection, int paragraph)
- Specified by:
getParagraphSelectionin interfaceTextEditingArea<PS,SEG,S>
-
getStyleOfChar
public S getStyleOfChar(int index)
Description copied from interface:StyleActionsReturns the style of the character with the given index. Ifindexpoints to a line terminator character, the last style used in the paragraph terminated by that line terminator is returned.- Specified by:
getStyleOfCharin interfaceStyleActions<PS,SEG>
-
getStyleAtPosition
public S getStyleAtPosition(int position)
Description copied from interface:StyleActionsReturns the style at the given position. That is the style of the character immediately precedingposition, except whenpositionpoints to a paragraph boundary, in which case it is the style at the beginning of the latter paragraph.In other words, most of the time
getStyleAtPosition(p)is equivalent togetStyleOfChar(p-1), except whenppoints to a paragraph boundary, in which case it is equivalent togetStyleOfChar(p).- Specified by:
getStyleAtPositionin interfaceStyleActions<PS,SEG>
-
getStyleRangeAtPosition
public IndexRange getStyleRangeAtPosition(int position)
Description copied from interface:StyleActionsReturns the range of homogeneous style that includes the given position. Ifpositionpoints to a boundary between two styled ranges, then the range precedingpositionis returned. Ifpositionpoints to a boundary between two paragraphs, then the first styled range of the latter paragraph is returned. Note that the returned IndexRange is relative to the paragraph (NOT the document).- Specified by:
getStyleRangeAtPositionin interfaceStyleActions<PS,SEG>
-
getStyleSpans
public StyleSpans<S> getStyleSpans(int from, int to)
Description copied from interface:StyleActionsReturns the styles in the given character range.- Specified by:
getStyleSpansin interfaceStyleActions<PS,SEG>
-
getStyleOfChar
public S getStyleOfChar(int paragraph, int index)
Description copied from interface:StyleActionsReturns the style of the character with the given index in the given paragraph. Ifindexis beyond the end of the paragraph, the style at the end of line is returned. Ifindexis negative, it is the same as if it was 0.- Specified by:
getStyleOfCharin interfaceStyleActions<PS,SEG>
-
getStyleAtPosition
public S getStyleAtPosition(int paragraph, int position)
Description copied from interface:StyleActionsReturns the style at the given position in the given paragraph. This is equivalent togetStyleOfChar(paragraph, position-1).- Specified by:
getStyleAtPositionin interfaceStyleActions<PS,SEG>
-
getStyleRangeAtPosition
public IndexRange getStyleRangeAtPosition(int paragraph, int position)
Description copied from interface:StyleActionsReturns the range of homogeneous style that includes the given position in the given paragraph. Ifpositionpoints to a boundary between two styled ranges, then the range precedingpositionis returned. The returned IndexRange is relative to the paragraph.- Specified by:
getStyleRangeAtPositionin interfaceStyleActions<PS,SEG>
-
getStyleSpans
public StyleSpans<S> getStyleSpans(int paragraph)
Description copied from interface:StyleActionsReturns styles of the whole paragraph.- Specified by:
getStyleSpansin interfaceStyleActions<PS,SEG>
-
getStyleSpans
public StyleSpans<S> getStyleSpans(int paragraph, int from, int to)
Description copied from interface:StyleActionsReturns the styles in the given character range of the given paragraph.- Specified by:
getStyleSpansin interfaceStyleActions<PS,SEG>
-
getAbsolutePosition
public int getAbsolutePosition(int paragraphIndex, int columnIndex)Description copied from interface:TextEditingAreaReturns the absolute position (i.e. the spot in-between characters) to the left of the given column in the given paragraph.For example, given a text with only one line
"text"and the columnIndex value of1, "position 1" would be returned:┌ character index 0 | ┌ character index 1 | | ┌ character index 3 | | | v v v |t|e|x|t| ^ ^ ^ | | | | | └ position 4 | └ position 1 └ position 0
Warning: Off-By-One errors can easily occur
If the column index spans outside of the given paragraph's length, the returned value will pass on to the previous/next paragraph. In other words, given a document with two paragraphs (where the first paragraph's text is "some" and the second "thing"), then the following statements are true:
getAbsolutePosition(0, "some".length()) == 4 == getAbsolutePosition(1, -1)getAbsolutePosition(0, "some".length() + 1) == 5 == getAbsolutePosition(1, 0)
- Specified by:
getAbsolutePositionin interfaceTextEditingArea<PS,SEG,S>- Parameters:
paragraphIndex- The index of the paragraph from which to start.columnIndex- If positive, the index going forward (the given paragraph's line or the next one(s)). If negative, the index going backward (the previous paragraph's line(s)
-
position
public TwoDimensional.Position position(int row, int col)
Description copied from interface:TwoDimensionalCreates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where themajorvalue is the index within the outer list) and theminorvalue is either the index within the inner list or some amount of length in a list of objects that have length.- Specified by:
positionin interfaceTwoDimensional
-
offsetToPosition
public TwoDimensional.Position offsetToPosition(int charOffset, TwoDimensional.Bias bias)
Description copied from interface:TwoDimensionalCreates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where theoffsetvalue is an absolute position in that entity.- Specified by:
offsetToPositionin interfaceTwoDimensional
-
getVisibleParagraphBoundsOnScreen
public Bounds getVisibleParagraphBoundsOnScreen(int visibleParagraphIndex)
Description copied from interface:ViewActionsReturns the bounds of the paragraph if it is visible orOptional.empty()if it's not. The returned bounds object will always be within the bounds of the area. In other words, it takes scrolling into account. Note: the bound's width will always equal the area's width, not necessarily the paragraph's real width (if it's short and doesn't take up all of the area's provided horizontal space or if it's long and spans outside of the area's width).- Specified by:
getVisibleParagraphBoundsOnScreenin interfaceViewActions<PS,SEG,S>- Parameters:
visibleParagraphIndex- the index in area's list of visible paragraphs.
-
getParagraphBoundsOnScreen
public Optional<Bounds> getParagraphBoundsOnScreen(int paragraphIndex)
Description copied from interface:ViewActionsReturns the bounds of the paragraph if it is visible orOptional.empty()if it's not. The returned bounds object will always be within the bounds of the area. In other words, it takes scrolling into account. Note: the bound's width will always equal the area's width, not necessarily the paragraph's real width (if it's short and doesn't take up all of the area's provided horizontal space or if it's long and spans outside of the area's width).- Specified by:
getParagraphBoundsOnScreenin interfaceViewActions<PS,SEG,S>- Parameters:
paragraphIndex- the index in area's list of paragraphs (visible and invisible).
-
getCaretBoundsOnScreen
public final <T extends Node & Caret> Optional<Bounds> getCaretBoundsOnScreen(T caret)
Description copied from interface:ViewActionsUsing the paragraph index of the "all paragraph" index system, returns the bounds of a caret on the given paragraph orOptional.empty()if no caret is on that paragraph or the pragraph is not visible.- Specified by:
getCaretBoundsOnScreenin interfaceViewActions<PS,SEG,S>
-
scrollXToPixel
public void scrollXToPixel(double pixel)
- Specified by:
scrollXToPixelin interfaceVirtualized
-
scrollYToPixel
public void scrollYToPixel(double pixel)
- Specified by:
scrollYToPixelin interfaceVirtualized
-
scrollXBy
public void scrollXBy(double deltaX)
- Specified by:
scrollXByin interfaceVirtualized
-
scrollYBy
public void scrollYBy(double deltaY)
- Specified by:
scrollYByin interfaceVirtualized
-
scrollBy
public void scrollBy(Point2D deltas)
- Specified by:
scrollByin interfaceVirtualized
-
showParagraphInViewport
public void showParagraphInViewport(int paragraphIndex)
Description copied from interface:ViewActionsShows the paragraph somewhere in the viewport. If the line is already visible, no noticeable change occurs. If line is above the current view, it appears at the top of the viewport. If the line is below the current view, it appears at the bottom of the viewport.- Specified by:
showParagraphInViewportin interfaceViewActions<PS,SEG,S>
-
showParagraphAtTop
public void showParagraphAtTop(int paragraphIndex)
Description copied from interface:ViewActionsLays out the viewport so that the paragraph is the first line (top) displayed in the viewport. Note: if the given area does not have enough lines that follow the given line to span its entire height, the paragraph may not appear at the very top of the viewport. Instead, it may simply be shown in the viewport. For example, given an unwrapped area whose height could show 10 lines but whose content only has 3 lines, callingshowParagraphAtTop(3)would be no different thanshowParagraphAtTop(1).- Specified by:
showParagraphAtTopin interfaceViewActions<PS,SEG,S>
-
showParagraphAtBottom
public void showParagraphAtBottom(int paragraphIndex)
Description copied from interface:ViewActionsLays out the viewport so that the paragraph is the last line (bottom) displayed in the viewport. Note: if the given area does not have enough lines preceding the given line to span its entire height, the paragraph may not appear at the very bottom of the viewport. Instead, it may appear towards the bottom of the viewport with some extra space following it. For example, given an unwrapped area whose height could show 10 lines but whose content only has 7 lines, callingshowParagraphAtBottom(1)would be no different than callingshowParagraphAtBottom(7).- Specified by:
showParagraphAtBottomin interfaceViewActions<PS,SEG,S>
-
showParagraphRegion
public void showParagraphRegion(int paragraphIndex, Bounds region)Description copied from interface:ViewActionsLays out the viewport so that the given bounds (according to the paragraph's coordinate system) within the given paragraph is visible in the viewport.- Specified by:
showParagraphRegionin interfaceViewActions<PS,SEG,S>
-
showParagraphAtCenter
public void showParagraphAtCenter(int paragraphIndex)
-
requestFollowCaret
public void requestFollowCaret()
Description copied from interface:ViewActionsIf the caret is not visible within the area's view, the area will scroll so that caret is visible in the next layout pass. Use this method when you wish to "follow the caret" (i.e. auto-scroll to caret) after making a change (add/remove/modify area's segments).- Specified by:
requestFollowCaretin interfaceViewActions<PS,SEG,S>
-
lineStart
public void lineStart(NavigationActions.SelectionPolicy policy)
Description copied from interface:ViewActionsMove the caret to the start of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraph- Specified by:
lineStartin interfaceViewActions<PS,SEG,S>- Parameters:
policy- useNavigationActions.SelectionPolicy.CLEARwhen no selection is desired anNavigationActions.SelectionPolicy.ADJUSTwhen a selection from starting point to the place to where the caret is moved is desired.
-
lineEnd
public void lineEnd(NavigationActions.SelectionPolicy policy)
Description copied from interface:ViewActionsMove the caret to the end of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraph- Specified by:
lineEndin interfaceViewActions<PS,SEG,S>- Parameters:
policy- useNavigationActions.SelectionPolicy.CLEARwhen no selection is desired anNavigationActions.SelectionPolicy.ADJUSTwhen a selection from starting point to the place to where the caret is moved is desired.
-
getCurrentLineStartInParargraph
public int getCurrentLineStartInParargraph()
-
getCurrentLineEndInParargraph
public int getCurrentLineEndInParargraph()
-
setLineHighlighterFill
public void setLineHighlighterFill(Paint highlight)
The default fill is "highlighter" yellow. It can also be styled using CSS with:
.styled-text-area .line-highlighter { -fx-fill: lime; }
CSS selectors from Path, Shape, and Node can also be used.
-
isLineHighlighterOn
public boolean isLineHighlighterOn()
-
setLineHighlighterOn
public void setLineHighlighterOn(boolean show)
Highlights the line that the main caret is on.
Line highlighting automatically follows the caret.
-
nextLine
public void nextLine(NavigationActions.SelectionPolicy selectionPolicy)
Scrolls the text one line UP while maintaining the caret's position on screen, so that it is now on the NEXT line. Note: If the caret isn't visible then this is a noop.
-
prevLine
public void prevLine(NavigationActions.SelectionPolicy selectionPolicy)
Scrolls the text one line DOWN while maintaining the caret's position on screen, so that it is now on the PREVIOUS line. Note: If the caret isn't visible then this is a noop.
-
prevPage
public void prevPage(NavigationActions.SelectionPolicy selectionPolicy)
Description copied from interface:ViewActionsMoves caret to the previous page (i.e. page up)- Specified by:
prevPagein interfaceViewActions<PS,SEG,S>- Parameters:
selectionPolicy- useNavigationActions.SelectionPolicy.CLEARwhen no selection is desired andNavigationActions.SelectionPolicy.ADJUSTwhen a selection from starting point to the place to where the caret is moved is desired.
-
nextPage
public void nextPage(NavigationActions.SelectionPolicy selectionPolicy)
Description copied from interface:ViewActionsMoves caret to the next page (i.e. page down)- Specified by:
nextPagein interfaceViewActions<PS,SEG,S>- Parameters:
selectionPolicy- useNavigationActions.SelectionPolicy.CLEARwhen no selection is desired andNavigationActions.SelectionPolicy.ADJUSTwhen a selection from starting point to the place to where the caret is moved is desired.
-
displaceCaret
public void displaceCaret(int pos)
Description copied from interface:TextEditingAreaDisplaces the caret from the selection by positioning only the caret to the new location without also affecting the selection'sanchoror theselection. Do not confuse this method withNavigationActions.moveTo(int), which is the normal way of moving the caret. This method can be used to achieve the special case of positioning the caret outside or inside the selection, as opposed to always being at the boundary. Use with care.- Specified by:
displaceCaretin interfaceTextEditingArea<PS,SEG,S>
-
setStyle
public void setStyle(int from, int to, S style)Description copied from interface:StyleActionsSets style for the given character range.- Specified by:
setStylein interfaceStyleActions<PS,SEG>
-
setStyle
public void setStyle(int paragraph, S style)Description copied from interface:StyleActionsSets style for the whole paragraph.- Specified by:
setStylein interfaceStyleActions<PS,SEG>
-
setStyle
public void setStyle(int paragraph, int from, int to, S style)Description copied from interface:StyleActionsSets style for the given range relative in the given paragraph.- Specified by:
setStylein interfaceStyleActions<PS,SEG>
-
setStyleSpans
public void setStyleSpans(int from, StyleSpans<? extends S> styleSpans)Description copied from interface:StyleActionsSet multiple style ranges at once. This is equivalent tofor(StyleSpan
but the actual implementation in<S>span: styleSpans) { setStyle(from, from + span.getLength(), span.getStyle()); from += span.getLength(); }SimpleEditableStyledDocumentis more efficient.- Specified by:
setStyleSpansin interfaceStyleActions<PS,SEG>
-
setStyleSpans
public void setStyleSpans(int paragraph, int from, StyleSpans<? extends S> styleSpans)Description copied from interface:StyleActionsSet multiple style ranges of a paragraph at once. This is equivalent tofor(StyleSpan
but the actual implementation in<S>span: styleSpans) { setStyle(paragraph, from, from + span.getLength(), span.getStyle()); from += span.getLength(); }SimpleEditableStyledDocumentis more efficient.- Specified by:
setStyleSpansin interfaceStyleActions<PS,SEG>
-
setParagraphStyle
public void setParagraphStyle(int paragraph, PS paragraphStyle)Description copied from interface:StyleActionsSets style for the whole paragraph.- Specified by:
setParagraphStylein interfaceStyleActions<PS,SEG>
-
setTextInsertionStyle
public final void setTextInsertionStyle(S txtStyle)
If you want to preset the style to be used for inserted text. Note that useInitialStyleForInsertion overrides this if true.
-
getTextInsertionStyle
public final S getTextInsertionStyle()
-
getTextStyleForInsertionAt
public final S getTextStyleForInsertionAt(int pos)
Description copied from interface:StyleActionsReturnsStyleActions.getInitialTextStyle()ifStyleActions.getUseInitialStyleForInsertion()is true; otherwise, returns the style at the given position.- Specified by:
getTextStyleForInsertionAtin interfaceStyleActions<PS,SEG>
-
setParagraphInsertionStyle
public final void setParagraphInsertionStyle(PS paraStyle)
If you want to preset the style to be used. Note that useInitialStyleForInsertion overrides this if true.
-
getParagraphInsertionStyle
public final PS getParagraphInsertionStyle()
-
getParagraphStyleForInsertionAt
public final PS getParagraphStyleForInsertionAt(int pos)
Description copied from interface:StyleActionsReturnsStyleActions.getInitialParagraphStyle()ifStyleActions.getUseInitialStyleForInsertion()is true; otherwise, returns the paragraph style at the given position.- Specified by:
getParagraphStyleForInsertionAtin interfaceStyleActions<PS,SEG>
-
replaceText
public void replaceText(int start, int end, String text)Description copied from interface:TextEditingAreaReplaces a range of characters with the given text. It must hold0 <= start <= end <= getLength().- Specified by:
replaceTextin interfaceTextEditingArea<PS,SEG,S>- Parameters:
start- Start index of the range to replace, inclusive.end- End index of the range to replace, exclusive.text- The text to put in place of the deleted range. It must not be null.
-
replace
public void replace(int start, int end, SEG seg, S style)Description copied from interface:TextEditingAreaReplaces a range of characters with the given segment. It must hold0 <= start <= end <= getLength().- Specified by:
replacein interfaceTextEditingArea<PS,SEG,S>- Parameters:
start- Start index of the range to replace, inclusive.end- End index of the range to replace, exclusive.seg- The seg to put in place of the deleted range. It must not be null.
-
replace
public void replace(int start, int end, StyledDocument<PS,SEG,S> replacement)Description copied from interface:TextEditingAreaReplaces a range of characters with the given rich-text document.- Specified by:
replacein interfaceTextEditingArea<PS,SEG,S>
-
createMultiChange
public MultiChangeBuilder<PS,SEG,S> createMultiChange()
Description copied from interface:TextEditingAreaStarts building a list of changes to be used to update multiple portions of the underlying document in one call. To execute the changes, callMultiChangeBuilder.commit(). If the number of changes are known at compile time, useTextEditingArea.createMultiChange(int)for better memory efficiency.- Specified by:
createMultiChangein interfaceTextEditingArea<PS,SEG,S>
-
createMultiChange
public MultiChangeBuilder<PS,SEG,S> createMultiChange(int initialNumOfChanges)
Description copied from interface:TextEditingAreaSame asTextEditingArea.createMultiChange()but the number of changes are specified to be more memory efficient.- Specified by:
createMultiChangein interfaceTextEditingArea<PS,SEG,S>
-
foldSelectedParagraphs
protected void foldSelectedParagraphs(UnaryOperator<PS> styleMixin)
Convenience method to fold (hide/collapse) the currently selected paragraphs, into (i.e. excluding) the first paragraph of the range.- Parameters:
styleMixin- Given a paragraph style PS, return a new PS that will activate folding.See
fold(int, int, UnaryOperator)for more info.
-
foldParagraphs
protected void foldParagraphs(int start, int end, UnaryOperator<PS> styleMixin)Folds (hides/collapses) paragraphs fromstarttoend, into (i.e. excluding) the first paragraph of the range.- Parameters:
styleMixin- Given a paragraph style PS, return a new PS that will activate folding.See
fold(int, int, UnaryOperator)for more info.
-
fold
protected void fold(int startPos, int endPos, UnaryOperator<PS> styleMixin)Folds (hides/collapses) paragraphs from character positionstartPostoendPos, into (i.e. excluding) the first paragraph of the range.Folding is achieved with the help of paragraph styling, which is applied to the paragraph's TextFlow object through the applyParagraphStyle BiConsumer (supplied in the constructor to GenericStyledArea). When applyParagraphStyle is to apply fold styling it just needs to set the TextFlow's visibility to collapsed for it to be folded. See
InlineCssTextArea,StyleClassedTextArea, andRichTextDemofor different ways of doing this. Also read the GitHub Wiki.The UnaryOperator
styleMixinmust return a different paragraph style Object to what was submitted.- Parameters:
styleMixin- Given a paragraph style PS, return a new PS that will activate folding.
-
unfoldParagraphs
protected void unfoldParagraphs(int startingFrom, Predicate<PS> isFolded, UnaryOperator<PS> styleMixin)Unfolds paragraphsstartingFromonwards for the currently folded block.The UnaryOperator
styleMixinmust return a different paragraph style Object to what was submitted.- Parameters:
isFolded- Given a paragraph style PS check if it's folded.styleMixin- Given a paragraph style PS, return a new PS that excludes fold styling.
-
dispose
public void dispose()
Description copied from interface:TextEditingAreaDisposes this area, preventing memory leaks.- Specified by:
disposein interfaceTextEditingArea<PS,SEG,S>
-
autoHeightProperty
public BooleanProperty autoHeightProperty()
- See Also:
isAutoHeight(),setAutoHeight(boolean)
-
setAutoHeight
public void setAutoHeight(boolean value)
Sets the value of the property autoHeight.- Property description:
-
isAutoHeight
public boolean isAutoHeight()
Gets the value of the property autoHeight.- Property description:
-
computePrefHeight
protected double computePrefHeight(double width)
- Overrides:
computePrefHeightin classRegion
-
layoutChildren
protected void layoutChildren()
- Overrides:
layoutChildrenin classParent
-
getCssMetaData
public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
- Specified by:
getCssMetaDatain interfaceStyleable- Overrides:
getCssMetaDatain classRegion
-
getClassCssMetaData
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
-
-