Skip to content

Commit 208d828

Browse files
committed
8228570: Add various documentation clarifications
Reviewed-by: arapte, kcr
1 parent 7a8708b commit 208d828

File tree

9 files changed

+110
-63
lines changed

9 files changed

+110
-63
lines changed

modules/javafx.base/src/main/java/javafx/beans/value/ObservableValue.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
* this library support lazy evaluation.
4444
* <p>
4545
* An {@code ObservableValue} generates two types of events: change events and
46-
* invalidation events. A change event indicates that the value has changed. An
46+
* invalidation events. A change event indicates that the value has changed.
47+
* Current implementing classes in JavaFX check for a change using reference
48+
* equality (and not object equality, {@code Object#equals(Object)}) of the value. An
4749
* invalidation event is generated if the current value is not valid anymore.
4850
* This distinction becomes important if the {@code ObservableValue} supports
4951
* lazy evaluation, because for a lazily evaluated value one does not know if an

modules/javafx.base/src/main/java/javafx/collections/FXCollections.java

+28-20
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,24 @@ public static <E> ObservableList<E> observableList(List<E> list) {
102102
}
103103

104104
/**
105-
* Constructs an ObservableList that is backed by the specified list.
106-
* Mutation operations on the ObservableList instance will be reported
107-
* to observers that have registered on that instance.<br>
108-
* Note that mutation operations made directly to the underlying list are
109-
* <em>not</em> reported to observers of any ObservableList that
105+
* Constructs an {@code ObservableList} that is backed by the specified list and listens to changes in observables of its items.
106+
* Mutation operations made directly to the underlying list are
107+
* <em>not</em> reported to observers of any {@code ObservableList} that
110108
* wraps it.
111-
* <br>
112-
* This list also reports mutations of the elements in it by using <code>extractor</code>.
113-
* Observable objects returned by extractor (applied to each list element) are listened for changes
114-
* and transformed into "update" change of ListChangeListener.
109+
* <p>
110+
* The {@code extractor} returns observables (usually properties) of the objects in the created list. These observables are
111+
* listened for changes, and the user is notified of these through an
112+
* {@linkplain ListChangeListener.Change#wasUpdated() update} change of an attached {@code ListChangeListener}. These changes
113+
* are unrelated to the changes made to the observable list itself using methods such as {@code add} and {@code remove}.
114+
* <p>
115+
* For example, a list of {@code Shape}s can listen to changes in the shapes' {@code fill} property.
115116
*
116-
* @param <E> The type of List to be wrapped
117-
* @param list a concrete List that backs this ObservableList
118-
* @param extractor element to Observable[] convertor
117+
* @param <E> The type of {@code List} to be wrapped
118+
* @param list a concrete {@code List} that backs this {@code ObservableList}
119+
* @param extractor element to {@code Observable[]} converter
120+
* @return a newly created {@code ObservableList}
121+
* @see #observableArrayList(javafx.util.Callback)
119122
* @since JavaFX 2.1
120-
* @return a newly created ObservableList
121123
*/
122124
public static <E> ObservableList<E> observableList(List<E> list, Callback<E, Observable[]> extractor) {
123125
if (list == null || extractor == null) {
@@ -307,7 +309,7 @@ public static ObservableFloatArray observableFloatArray(ObservableFloatArray arr
307309
}
308310

309311
/**
310-
* Creates a new empty observable list that is backed by an arraylist.
312+
* Creates a new empty observable list that is backed by an array list.
311313
* @see #observableList(java.util.List)
312314
* @param <E> The type of List to be wrapped
313315
* @return a newly created ObservableList
@@ -318,14 +320,20 @@ public static <E> ObservableList<E> observableArrayList() {
318320
}
319321

320322
/**
321-
* Creates a new empty observable list backed by an arraylist.
323+
* Creates a new empty {@code ObservableList} that is backed by an array list and listens to changes in observables of its items.
324+
* <p>
325+
* The {@code extractor} returns observables (usually properties) of the objects in the created list. These observables are
326+
* listened for changes and the user is notified of these through an
327+
* {@linkplain ListChangeListener.Change#wasUpdated() update} change of an attached {@code ListChangeListener}. These changes
328+
* are unrelated to the changes made to the observable list itself using methods such as {@code add} and {@code remove}.
329+
* <p>
330+
* For example, a list of {@code Shape}s can listen to changes in the shapes' {@code fill} property.
322331
*
323-
* This list reports element updates.
324-
* @param <E> The type of List to be wrapped
325-
* @param extractor element to Observable[] convertor. Observable objects are listened for changes on the element.
332+
* @param <E> The type of {@code List} to be wrapped
333+
* @param extractor element to {@code Observable[]} converter
334+
* @return a newly created {@code ObservableList}
326335
* @see #observableList(java.util.List, javafx.util.Callback)
327336
* @since JavaFX 2.1
328-
* @return a newly created ObservableList
329337
*/
330338
public static <E> ObservableList<E> observableArrayList(Callback<E, Observable[]> extractor) {
331339
return observableList(new ArrayList(), extractor);
@@ -369,7 +377,7 @@ public static <K,V> ObservableMap<K,V> observableHashMap() {
369377

370378
/**
371379
* Concatenates more observable lists into one. The resulting list
372-
* would be backed by an arraylist.
380+
* would be backed by an array list.
373381
* @param <E> The type of List to be wrapped
374382
* @param lists lists to concatenate
375383
* @return new observable array list concatenated from the arguments

modules/javafx.base/src/main/java/javafx/collections/ObservableList.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
import javafx.collections.transformation.SortedList;
3737

3838
/**
39-
* A list that allows listeners to track changes when they occur.
39+
* A list that allows listeners to track changes when they occur. Implementations can be created using methods in {@link FXCollections}
40+
* such as {@link FXCollections#observableArrayList() observableArrayList}, or with a
41+
* {@link javafx.beans.property.SimpleListProperty SimpleListProperty}.
4042
*
4143
* @see ListChangeListener
4244
* @see ListChangeListener.Change

modules/javafx.base/src/main/java/javafx/collections/ObservableMap.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@
3030
import javafx.beans.Observable;
3131

3232
/**
33-
* A map that allows observers to track changes when they occur.
33+
* A map that allows observers to track changes when they occur. Implementations can be created using methods in {@link FXCollections}
34+
* such as {@link FXCollections#observableHashMap() observableHashMap}, or with a
35+
* {@link javafx.beans.property.SimpleMapProperty SimpleMapProperty}.
3436
*
3537
* @see MapChangeListener
3638
* @see MapChangeListener.Change
39+
* @param <K> the map key element type
40+
* @param <V> the map value element type
3741
* @since JavaFX 2.0
3842
*/
3943
public interface ObservableMap<K, V> extends Map<K, V>, Observable {

modules/javafx.base/src/main/java/javafx/collections/ObservableSet.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@
2525

2626
package javafx.collections;
2727

28-
2928
import java.util.Set;
3029

3130
import javafx.beans.Observable;
3231

3332
/**
34-
* A set that allows observers to track changes when they occur.
33+
* A set that allows observers to track changes when they occur. Implementations can be created using methods in {@link FXCollections}
34+
* such as {@link FXCollections#observableSet(Object...) observableSet}, or with a
35+
* {@link javafx.beans.property.SimpleSetProperty SimpleSetProperty}.
3536
*
3637
* @see SetChangeListener
3738
* @see SetChangeListener.Change
39+
* @param <E> the set element type
3840
* @since JavaFX 2.1
3941
*/
4042
public interface ObservableSet<E> extends Set<E>, Observable {

modules/javafx.controls/src/main/java/javafx/scene/control/Labeled.java

+30-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
package javafx.scene.control;
2727

28-
2928
import com.sun.javafx.css.StyleManager;
3029
import com.sun.javafx.scene.NodeHelper;
3130
import javafx.css.converter.BooleanConverter;
@@ -68,7 +67,6 @@
6867
import javafx.css.StyleableProperty;
6968
import javafx.css.StyleableStringProperty;
7069

71-
7270
/**
7371
* A Labeled {@link Control} is one which has as part of its user interface
7472
* a textual content associated with it. For example, a {@link Button} displays
@@ -135,7 +133,9 @@ public Labeled(String text, Node graphic) {
135133
**************************************************************************/
136134
/**
137135
* The text to display in the label. The text may be null.
136+
*
138137
* @return the text to display in the label
138+
* @defaultValue empty string
139139
*/
140140
public final StringProperty textProperty() {
141141
if (text == null) {
@@ -150,7 +150,9 @@ public final StringProperty textProperty() {
150150
/**
151151
* Specifies how the text and graphic within the Labeled should be
152152
* aligned when there is empty space within the Labeled.
153+
*
153154
* @return the alignment within this labeled
155+
* @defaultValue {@code Pos.CENTER_LEFT}
154156
*/
155157
public final ObjectProperty<Pos> alignmentProperty() {
156158
if (alignment == null) {
@@ -182,7 +184,9 @@ public String getName() {
182184
* Specifies the behavior for lines of text <em>when text is multiline</em>.
183185
* Unlike {@link #contentDisplayProperty} which affects the graphic and text, this setting
184186
* only affects multiple lines of text relative to the text bounds.
187+
*
185188
* @return the alignment of lines of text within this labeled
189+
* @defaultValue {@code TextAlignment.LEFT}
186190
*/
187191
public final ObjectProperty<TextAlignment> textAlignmentProperty() {
188192
if (textAlignment == null) {
@@ -213,7 +217,9 @@ public String getName() {
213217
/**
214218
* Specifies the behavior to use if the text of the {@code Labeled}
215219
* exceeds the available space for rendering the text.
220+
*
216221
* @return the overrun behavior if the text exceeds the available space
222+
* @defaultValue {@code OverrunStyle.ELLIPSIS}
217223
*/
218224
public final ObjectProperty<OverrunStyle> textOverrunProperty() {
219225
if (textOverrun == null) {
@@ -259,6 +265,7 @@ public String getName() {
259265
* @return the ellipsis property on the string to display for the ellipsis
260266
* when text is truncated
261267
* @see <a href="http://en.wikipedia.org/wiki/Ellipsis#Computer_representations">Wikipedia:ellipsis</a>
268+
* @defaultValue {@code "..."}
262269
* @since JavaFX 2.2
263270
*/
264271
public final StringProperty ellipsisStringProperty() {
@@ -287,7 +294,9 @@ public final StringProperty ellipsisStringProperty() {
287294
/**
288295
* If a run of text exceeds the width of the Labeled, then this variable
289296
* indicates whether the text should wrap onto another line.
297+
*
290298
* @return the wrap property if a run of text exceeds the width of the Labeled
299+
* @defaultValue {@code false}
291300
*/
292301
public final BooleanProperty wrapTextProperty() {
293302
if (wrapText == null) {
@@ -328,7 +337,9 @@ public String getName() {
328337
* rich text then this font may or may not be used depending on the font
329338
* information embedded in the rich text, but in any case where a default
330339
* font is required, this font will be used.
340+
*
331341
* @return the default font to use for text in this labeled
342+
* @defaultValue {@link Font#getDefault()}
332343
*/
333344
public final ObjectProperty<Font> fontProperty() {
334345

@@ -403,8 +414,10 @@ public String getName() {
403414
* text by using {@link #setContentDisplay}. The node specified for this
404415
* variable cannot appear elsewhere in the scene graph, otherwise
405416
* the {@code IllegalArgumentException} is thrown. See the class
406-
* description of {@link javafx.scene.Node Node} for more detail.
417+
* description of {@link Node} for more detail.
418+
*
407419
* @return the optional icon for this labeled
420+
* @defaultValue {@code null}
408421
*/
409422
public final ObjectProperty<Node> graphicProperty() {
410423
if (graphic == null) {
@@ -562,7 +575,9 @@ public CssMetaData<Labeled,String> getCssMetaData() {
562575

563576
/**
564577
* Whether all text should be underlined.
578+
*
565579
* @return the underline property of all text in this labeled
580+
* @defaultValue {@code false}
566581
*/
567582
public final BooleanProperty underlineProperty() {
568583
if (underline == null) {
@@ -592,7 +607,9 @@ public String getName() {
592607

593608
/**
594609
* Specifies the space in pixel between lines.
610+
*
595611
* @return the line spacing property between lines in this labeled
612+
* @defaultValue 0
596613
* @since JavaFX 8.0
597614
*/
598615
public final DoubleProperty lineSpacingProperty() {
@@ -623,7 +640,9 @@ public String getName() {
623640

624641
/**
625642
* Specifies the positioning of the graphic relative to the text.
643+
*
626644
* @return content display property of this labeled
645+
* @defaultValue {@code ContentDisplay.LEFT}
627646
*/
628647
public final ObjectProperty<ContentDisplay> contentDisplayProperty() {
629648
if (contentDisplay == null) {
@@ -657,7 +676,9 @@ public String getName() {
657676
* Subclasses may add nodes outside this padding and inside the Labeled's padding.
658677
*
659678
* This property can only be set from CSS.
660-
* @return the label padding property of this labeled
679+
*
680+
* @return the label padding property of this labeled
681+
* @defaultValue {@code Insets.EMPTY}
661682
*/
662683
public final ReadOnlyObjectProperty<Insets> labelPaddingProperty() {
663684
return labelPaddingPropertyImpl();
@@ -702,7 +723,9 @@ public String getName() {
702723

703724
/**
704725
* The amount of space between the graphic and text
726+
*
705727
* @return the graphics text gap property of this labeled
728+
* @defaultValue 4
706729
*/
707730
public final DoubleProperty graphicTextGapProperty() {
708731
if (graphicTextGap == null) {
@@ -733,6 +756,8 @@ public String getName() {
733756

734757
/**
735758
* The {@link Paint} used to fill the text.
759+
*
760+
* @defaultValue {@code Color.BLACK}
736761
*/
737762
private ObjectProperty<Paint> textFill; // TODO for now change this
738763

@@ -776,10 +801,7 @@ public String getName() {
776801
* be determined based on the succeeding character, and the mnemonic
777802
* added.
778803
*
779-
* <p>
780-
* The default value for Labeled is false, but it
781-
* is enabled by default on some Controls.
782-
* </p>
804+
* @defaultValue {@code false}; {@code true} for some {@code Control}s.
783805
*/
784806
private BooleanProperty mnemonicParsing;
785807
public final void setMnemonicParsing(boolean value) {

modules/javafx.controls/src/main/java/javafx/scene/control/Pagination.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@
5757
* setting the style class {@link #STYLE_CLASS_BULLET}. The
5858
* {@link #maxPageIndicatorCountProperty() maxPageIndicatorCountProperty} can be used to change
5959
* the maximum number of page indicators. The property value can also be changed
60-
* via CSS using -fx-max-page-indicator-count.
60+
* via CSS using {@code -fx-max-page-indicator-count}. By default, page indicator numbering starts from 1 (corresponding to
61+
* page index 0).
6162
*</p>
6263
*
6364
* <h2>Page count</h2>
6465
* <p>
6566
* The {@link #pageCountProperty() pageCountProperty} controls the number of
6667
* pages this pagination control has. If the page count is
67-
* not known {@link #INDETERMINATE} should be used as the page count.
68+
* not known, {@link #INDETERMINATE} should be used as the page count.
6869
* </p>
6970
*
7071
* <h2>Page factory</h2>
@@ -73,7 +74,7 @@
7374
* that is called when a page has been selected by the application or
7475
* the user. The function is required for the functionality of the pagination
7576
* control. The callback function should load and return the contents of the selected page.
76-
* Null should be returned if the selected page index does not exist.
77+
* {@code null} should be returned if the selected page index does not exist.
7778
* </p>
7879
*
7980
* <h2>Creating a Pagination control:</h2>
@@ -86,12 +87,20 @@
8687
* pagination.setPageFactory(new Callback&lt;Integer, Node&gt;() {
8788
* &#064;Override
8889
* public Node call(Integer pageIndex) {
89-
* return new Label(pageIndex+1 + ". Lorem ipsum dolor sit amet,\n"
90+
* return new Label(pageIndex + 1 + ". Lorem ipsum dolor sit amet,\n"
9091
* + "consectetur adipiscing elit,\n"
9192
* + "sed do eiusmod tempor incididunt ut\n"
9293
* + "labore et dolore magna aliqua.");
9394
* }
9495
* });</code></pre>
96+
* or using lambdas
97+
* <pre><code> Pagination pagination = new Pagination(10, 0);
98+
* pagination.setPageFactory(pageIndex -&gt;
99+
* new Label(pageIndex + 1 + ". Lorem ipsum dolor sit amet,\n"
100+
* + "consectetur adipiscing elit,\n"
101+
* + "sed do eiusmod tempor incididunt ut\n"
102+
* + "labore et dolore magna aliqua.");
103+
* );</code></pre>
95104
*
96105
* <img src="doc-files/Pagination.png" alt="Image of the Pagination control">
97106
*

0 commit comments

Comments
 (0)