Skip to content

Commit c41ea98

Browse files
Merge pull request #630 from JordanMartinez/documentProject
Document all classes
2 parents 0a4e3bf + 5713c4a commit c41ea98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+896
-219
lines changed

richtextfx/src/main/java/org/fxmisc/richtext/BackgroundPath.java

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/**
66
* A path which describes a background shape in the Scene graph.
7-
*
87
*/
98
public class BackgroundPath extends Path {
109
}

richtextfx/src/main/java/org/fxmisc/richtext/BorderPath.java

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/**
66
* A path which describes a border in the Scene graph.
7-
*
87
*/
98
public class BorderPath extends Path {
109
}

richtextfx/src/main/java/org/fxmisc/richtext/Caret.java

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
*/
3535
public interface Caret {
3636

37+
/**
38+
* Determines whether the caret is visible. Those who wish to use the default configuartion should use
39+
* {@link #AUTO} while those who want a more custom configuration should make a caret's {@code CaretVisibility}
40+
* value oscilate between {@link #ON} and {@link #OFF}.
41+
*/
3742
public static enum CaretVisibility {
3843
/** Caret is displayed. */
3944
ON,

richtextfx/src/main/java/org/fxmisc/richtext/CaretPath.java

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/**
66
* A path which describes a caret shape in the Scene graph.
7-
*
87
*/
98
public class CaretPath extends Path {
109
}

richtextfx/src/main/java/org/fxmisc/richtext/CharacterHit.java

+32-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@
22

33
import java.util.OptionalInt;
44

5+
/**
6+
* Object that stores information relating to the position in an area's content that corresponds to a given position
7+
* in some visible entity (e.g. the area, a paragraph in the area, a line on a paragraph).
8+
*/
59
public class CharacterHit {
610

11+
/**
12+
* Returns a {@link CharacterHit} for cases where the insertion occurs outside the bounds of some visible entity
13+
* (e.g. the area, the paragraph in an area, the line in a paragraph)
14+
*/
715
public static CharacterHit insertionAt(int insertionIndex) {
816
return new CharacterHit(OptionalInt.empty(), insertionIndex);
917
}
1018

19+
/**
20+
* Returns a {@link CharacterHit} for cases where the hit occurs inside the bounds of some visible entity
21+
* (e.g. the area, the paragraph in an area, the line in a paragraph) and the character is leading.
22+
*/
1123
public static CharacterHit leadingHalfOf(int charIdx) {
1224
return new CharacterHit(OptionalInt.of(charIdx), charIdx);
1325
}
1426

27+
/**
28+
* Returns a {@link CharacterHit} for cases where the hit occurs inside the bounds of some visible entity
29+
* (e.g. the area, the paragraph in an area, the line in a paragraph) and the character is trailing.
30+
*/
1531
public static CharacterHit trailingHalfOf(int charIdx) {
1632
return new CharacterHit(OptionalInt.of(charIdx), charIdx + 1);
1733
}
@@ -25,19 +41,32 @@ private CharacterHit(OptionalInt charIdx, int insertionIndex) {
2541
this.insertionIndex = insertionIndex;
2642
}
2743

44+
/**
45+
* Returns an {@link OptionalInt} whose value is present when the hit occurs within the visible
46+
* entity and is the index of the closest character to the give position on the screen.
47+
*/
2848
public OptionalInt getCharacterIndex() {
2949
return charIdx;
3050
}
3151

52+
/**
53+
* When {@link #getCharacterIndex()} is present, returns either the same value as {@link #getCharacterIndex()} when
54+
* the character index is leading and {@code getCharacterIndex() + 1} when the index is trailing.
55+
* When {@link #getCharacterIndex()} is absent, returns the bounds of that visible entity (either {@code 0} or
56+
* the length of the area, the length of a paragraph, or the character count of a line).
57+
*/
3258
public int getInsertionIndex() {
3359
return insertionIndex;
3460
}
3561

36-
public CharacterHit offset(int offset) {
62+
/**
63+
* Offsets the values stored in this {@link CharacterHit} by the given amount
64+
*/
65+
public CharacterHit offset(int offsetAmount) {
3766
return new CharacterHit(
3867
charIdx.isPresent()
39-
? OptionalInt.of(charIdx.getAsInt() + offset)
68+
? OptionalInt.of(charIdx.getAsInt() + offsetAmount)
4069
: charIdx,
41-
insertionIndex + offset);
70+
insertionIndex + offsetAmount);
4271
}
4372
}

richtextfx/src/main/java/org/fxmisc/richtext/CodeArea.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
import org.fxmisc.richtext.model.EditableStyledDocument;
88

99
/**
10-
* A convenience subclass of {@link StyleClassedTextArea}
11-
* with fixed-width font and an undo manager that observes
12-
* only plain text changes (not styled changes).
10+
* A convenience subclass of {@link StyleClassedTextArea} with fixed-width font and an undo manager that observes
11+
* only plain text changes (not styled changes). It's style class is {@code code-area}.
1312
*/
1413
public class CodeArea extends StyleClassedTextArea {
1514

@@ -23,10 +22,16 @@ public class CodeArea extends StyleClassedTextArea {
2322
setUseInitialStyleForInsertion(true);
2423
}
2524

25+
/**
26+
* Creates an area that can render and edit the same {@link EditableStyledDocument} as another {@link CodeArea}.
27+
*/
2628
public CodeArea(@NamedArg("document") EditableStyledDocument<Collection<String>, String, Collection<String>> document) {
2729
super(document, false);
2830
}
2931

32+
/**
33+
* Creates an area with no text.
34+
*/
3035
public CodeArea() {
3136
super(false);
3237
}

richtextfx/src/main/java/org/fxmisc/richtext/CustomCssMetaData.java

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
import java.util.function.Function;
1010

11+
/**
12+
* Reduces boilerplate when creating a custom {@link CssMetaData} object
13+
*/
1114
public class CustomCssMetaData<S extends Styleable, V> extends CssMetaData<S, V> {
1215

1316
private final Function<S, StyleableObjectProperty<V>> property;

richtextfx/src/main/java/org/fxmisc/richtext/CustomStyleableProperty.java

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import javafx.css.Styleable;
55
import javafx.css.StyleableObjectProperty;
66

7+
/**
8+
* Reduces the boilerplate when creating a custom CSS property (i.e. {@link javafx.css.StyleableProperty}).
9+
*/
710
public class CustomStyleableProperty<T> extends StyleableObjectProperty<T> {
811

912
private final Object bean;

richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java

+110-28
Original file line numberDiff line numberDiff line change
@@ -90,38 +90,53 @@
9090
import org.reactfx.value.Var;
9191

9292
/**
93-
* Text editing control. Accepts user input (keyboard, mouse) and
94-
* provides API to assign style to text ranges. It is suitable for
93+
* Text editing control that renders and edits a {@link EditableStyledDocument}.
94+
*
95+
* Accepts user input (keyboard, mouse) and provides API to assign style to text ranges. It is suitable for
9596
* syntax highlighting and rich-text editors.
9697
*
9798
* <h3>Adding Scrollbars to the Area</h3>
9899
*
99-
* <p>The scroll bars no longer appear when the content spans outside
100-
* of the viewport. To add scroll bars, the area needs to be wrapped in
101-
* a {@link VirtualizedScrollPane}. For example, </p>
102-
* <pre>
103-
* {@code
100+
* <p>By default, scroll bars do not appear when the content spans outside of the viewport.
101+
* To add scroll bars, the area needs to be wrapped in a {@link VirtualizedScrollPane}. For example, </p>
102+
* <pre><code>
104103
* // shows area without scroll bars
105104
* InlineCssTextArea area = new InlineCssTextArea();
106105
*
107106
* // add scroll bars that will display as needed
108-
* VirtualizedScrollPane<InlineCssTextArea> vsPane = new VirtualizedScrollPane(area);
107+
* VirtualizedScrollPane&lt;InlineCssTextArea&gt; vsPane = new VirtualizedScrollPane&lt;&gt;(area);
109108
*
110-
* Parent parent = //;
109+
* Parent parent = // creation code
111110
* parent.getChildren().add(vsPane)
112-
* }
113-
* </pre>
111+
* </code></pre>
114112
*
115113
* <h3>Auto-Scrolling to the Caret</h3>
116114
*
117115
* <p>Every time the underlying {@link EditableStyledDocument} changes via user interaction (e.g. typing) through
118-
* the {@code StyledTextArea}, the area will scroll to insure the caret is kept in view. However, this does not
116+
* the {@code GenericStyledArea}, the area will scroll to insure the caret is kept in view. However, this does not
119117
* occur if changes are done programmatically. For example, let's say the area is displaying the bottom part
120118
* of the area's {@link EditableStyledDocument} and some code changes something in the top part of the document
121119
* that is not currently visible. If there is no call to {@link #requestFollowCaret()} at the end of that code,
122120
* the area will not auto-scroll to that section of the document. The change will occur, and the user will continue
123121
* to see the bottom part of the document as before. If such a call is there, then the area will scroll
124122
* to the top of the document and no longer display the bottom part of it.</p>
123+
* <p>For example...</p>
124+
* <pre><code>
125+
* // assuming the user is currently seeing the top of the area
126+
*
127+
* // then changing the bottom, currently not visible part of the area...
128+
* int startParIdx = 40;
129+
* int startColPosition = 2;
130+
* int endParIdx = 42;
131+
* int endColPosition = 10;
132+
*
133+
* // ...by itself will not scroll the viewport to where the change occurs
134+
* area.replaceText(startParIdx, startColPosition, endParIdx, endColPosition, "replacement text");
135+
*
136+
* // adding this line after the last modification to the area will cause the viewport to scroll to that change
137+
* // leaving the following line out will leave the viewport unaffected and the user will not notice any difference
138+
* area.requestFollowCaret();
139+
* </code></pre>
125140
*
126141
* <p>Additionally, when overriding the default user-interaction behavior, remember to include a call
127142
* to {@link #requestFollowCaret()}.</p>
@@ -136,34 +151,36 @@
136151
*
137152
* <h3>Overriding default keyboard behavior</h3>
138153
*
139-
* {@code StyledTextArea} uses {@code KEY_TYPED} handler to handle ordinary
140-
* character input and {@code KEY_PRESSED} handler to handle control key
154+
* {@code GenericStyledArea} uses {@link javafx.scene.input.KeyEvent#KEY_TYPED KEY_TYPED} to handle ordinary
155+
* character input and {@link javafx.scene.input.KeyEvent#KEY_PRESSED KEY_PRESSED} to handle control key
141156
* combinations (including Enter and Tab). To add or override some keyboard
142157
* shortcuts, while keeping the rest in place, you would combine the default
143158
* event handler with a new one that adds or overrides some of the default
144-
* key combinations. This is how to bind {@code Ctrl+S} to the {@code save()}
145-
* operation:
146-
* <pre>
147-
* {@code
159+
* key combinations.
160+
* <p>
161+
* For example, this is how to bind {@code Ctrl+S} to the {@code save()} operation:
162+
* </p>
163+
* <pre><code>
148164
* import static javafx.scene.input.KeyCode.*;
149165
* import static javafx.scene.input.KeyCombination.*;
150166
* import static org.fxmisc.wellbehaved.event.EventPattern.*;
151167
* import static org.fxmisc.wellbehaved.event.InputMap.*;
152168
*
153169
* import org.fxmisc.wellbehaved.event.Nodes;
154170
*
155-
* Nodes.addInputMap(area, consume(keyPressed(S, CONTROL_DOWN), event -> save()));
156-
* }
157-
* </pre>
171+
* // installs the following consume InputMap,
172+
* // so that a CTRL+S event saves the document and consumes the event
173+
* Nodes.addInputMap(area, consume(keyPressed(S, CONTROL_DOWN), event -&gt; save()));
174+
* </code></pre>
158175
*
159176
* <h3>Overriding default mouse behavior</h3>
160177
*
161178
* The area's default mouse behavior properly handles auto-scrolling and dragging the selected text to a new location.
162179
* As such, some parts cannot be partially overridden without it affecting other behavior.
163180
*
164-
* <p>The following lists either {@link org.fxmisc.wellbehaved.event.EventPattern}s that cannot be overridden without
165-
* negatively affecting the default mouse behavior or describe how to safely override things in a special way without
166-
* disrupting the auto scroll behavior.</p>
181+
* <p>The following lists either {@link org.fxmisc.wellbehaved.event.EventPattern}s that cannot be
182+
* overridden without negatively affecting the default mouse behavior or describe how to safely override things
183+
* in a special way without disrupting the auto scroll behavior.</p>
167184
* <ul>
168185
* <li>
169186
* <em>First (1 click count) Primary Button Mouse Pressed Events:</em>
@@ -227,6 +244,36 @@
227244
* </li>
228245
* </ul>
229246
*
247+
* <h3>CSS, Style Classes, and Pseudo Classes</h3>
248+
* <p>
249+
* Refer to the <a href="https://github.com/FXMisc/RichTextFX/wiki/RichTextFX-CSS-Reference-Guide">
250+
* RichTextFX CSS Reference Guide
251+
* </a>.
252+
* </p>
253+
*
254+
* <h3>Area Actions and Other Operations</h3>
255+
* <p>
256+
* To distinguish the actual operations one can do on this area from the boilerplate methods
257+
* within this area (e.g. properties and their getters/setters, etc.), look at the interfaces
258+
* this area implements. Each lists and documents methods that fall under that category.
259+
* </p>
260+
*
261+
* <h3>Calculating a Position Within the Area</h3>
262+
* <p>
263+
* To calculate a position or index within the area, read through the javadoc of
264+
* {@link org.fxmisc.richtext.model.TwoDimensional} and {@link org.fxmisc.richtext.model.TwoDimensional.Bias}.
265+
* Also, read the difference between "position" and "index" in
266+
* {@link org.fxmisc.richtext.model.StyledDocument#getAbsolutePosition(int, int)}.
267+
* </p>
268+
*
269+
* @see EditableStyledDocument
270+
* @see TwoDimensional
271+
* @see org.fxmisc.richtext.model.TwoDimensional.Bias
272+
* @see VirtualFlow
273+
* @see VirtualizedScrollPane
274+
* @see Caret
275+
* @see Selection
276+
* @see CaretSelectionBind
230277
*
231278
* @param <PS> type of style that can be applied to paragraphs (e.g. {@link TextFlow}.
232279
* @param <SEG> type of segment used in {@link Paragraph}. Can be only text (plain or styled) or
@@ -586,6 +633,20 @@ public GenericStyledArea(@NamedArg("initialParagraphStyle") PS initialParagraphS
586633
this(initialParagraphStyle, applyParagraphStyle, initialTextStyle, segmentOps, true, nodeFactory);
587634
}
588635

636+
/**
637+
* Same as {@link #GenericStyledArea(Object, BiConsumer, Object, TextOps, Function)} but also allows one
638+
* to specify whether the undo manager should be a plain or rich undo manager via {@code preserveStyle}.
639+
*
640+
* @param initialParagraphStyle style to use in places where no other style is specified (yet).
641+
* @param applyParagraphStyle function that, given a {@link TextFlow} node and
642+
* a style, applies the style to the paragraph node. This function is
643+
* used by the default skin to apply style to paragraph nodes.
644+
* @param initialTextStyle style to use in places where no other style is specified (yet).
645+
* @param segmentOps The operations which are defined on the text segment objects.
646+
* @param preserveStyle whether to use an undo manager that can undo/redo {@link RichTextChange}s or
647+
* {@link PlainTextChange}s
648+
* @param nodeFactory A function which is used to create the JavaFX scene node for a particular segment.
649+
*/
589650
public GenericStyledArea(@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
590651
@NamedArg("applyParagraphStyle") BiConsumer<TextFlow, PS> applyParagraphStyle,
591652
@NamedArg("initialTextStyle") S initialTextStyle,
@@ -598,8 +659,8 @@ public GenericStyledArea(@NamedArg("initialParagraphStyle") PS initialParagraphS
598659

599660
/**
600661
* The same as {@link #GenericStyledArea(Object, BiConsumer, Object, TextOps, Function)} except that
601-
* this constructor can be used to create another {@code GenericStyledArea} object that
602-
* shares the same {@link EditableStyledDocument}.
662+
* this constructor can be used to create another {@code GenericStyledArea} that renders and edits the same
663+
* {@link EditableStyledDocument} or when one wants to use a custom {@link EditableStyledDocument} implementation.
603664
*/
604665
public GenericStyledArea(
605666
@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
@@ -612,6 +673,20 @@ public GenericStyledArea(
612673

613674
}
614675

676+
/**
677+
* Creates an area with flexibility in all of its options.
678+
*
679+
* @param initialParagraphStyle style to use in places where no other style is specified (yet).
680+
* @param applyParagraphStyle function that, given a {@link TextFlow} node and
681+
* a style, applies the style to the paragraph node. This function is
682+
* used by the default skin to apply style to paragraph nodes.
683+
* @param initialTextStyle style to use in places where no other style is specified (yet).
684+
* @param document the document to render and edit
685+
* @param segmentOps The operations which are defined on the text segment objects.
686+
* @param preserveStyle whether to use an undo manager that can undo/redo {@link RichTextChange}s or
687+
* {@link PlainTextChange}s
688+
* @param nodeFactory A function which is used to create the JavaFX scene node for a particular segment.
689+
*/
615690
public GenericStyledArea(
616691
@NamedArg("initialParagraphStyle") PS initialParagraphStyle,
617692
@NamedArg("applyParagraphStyle") BiConsumer<TextFlow, PS> applyParagraphStyle,
@@ -835,9 +910,13 @@ TwoDimensional.Position currentLine() {
835910
return _position(parIdx, lineIdx);
836911
}
837912

838-
public final int lineIndex(int paragraphIndex, int column) {
913+
/**
914+
* Returns 0 if the given paragraph displays its content across only one line, or returns the index
915+
* of the line on which the given column position appears if the paragraph spans multiple lines.
916+
*/
917+
public final int lineIndex(int paragraphIndex, int columnPosition) {
839918
Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> cell = virtualFlow.getCell(paragraphIndex);
840-
return cell.getNode().getCurrentLineIndex(column);
919+
return cell.getNode().getCurrentLineIndex(columnPosition);
841920
}
842921

843922
TwoDimensional.Position _position(int par, int line) {
@@ -1211,6 +1290,9 @@ public void replace(int start, int end, StyledDocument<PS, SEG, S> replacement)
12111290
* *
12121291
* ********************************************************************** */
12131292

1293+
/**
1294+
* Disposes this area, preventing memory leaks.
1295+
*/
12141296
public void dispose() {
12151297
subscriptions.unsubscribe();
12161298
virtualFlow.dispose();

0 commit comments

Comments
 (0)