-
Notifications
You must be signed in to change notification settings - Fork 6.1k
6955128: Spec for javax.swing.plaf.basic.BasicTextUI.getVisibleEditorRect contains inappropriate wording #25850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1029,10 +1029,9 @@ public Dimension getMaximumSize(JComponent c) { | |||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
/** | ||||||||||||||||
* Gets the allocation to give the root View. Due | ||||||||||||||||
* to an unfortunate set of historical events this | ||||||||||||||||
* method is inappropriately named. The Rectangle | ||||||||||||||||
* returned has nothing to do with visibility. | ||||||||||||||||
* Gets the allocation to give the root View. | ||||||||||||||||
* The Rectangle returned has nothing to do with visibility but | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I suggest going lower case unless you specifically refer to the rectangle as the type in which case, it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "nothing to do with" -> "unrelated to" But what I'd really like to see is an explanation of what the return from this method ACTUALLY means / is used for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getVisibleEditorRect() return the bounds of the text editor and the return value is used to to set-size/paint the
In that regard, probably getAllocatedViewRect() would have been better choice of the method name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The term allocation is commonly used in javax.swing.text.View and its subclasses, for example, The Essentially, the allocation for text view means the size and position of the view. In this case, the returned rectangle is used an allocation for the root view to perform painting. jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java Lines 767 to 771 in 0dce98b
I do not think this method should explain what the allocation means; the javadoc may point to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @prsadhuk @prrace Does this description work? /**
* Gets the allocation for the root view.
* The returned rectangle is unrelated to visibility,
* it is passed as the {@code allocation} parameter to
* the {@link View#paint(Graphics, Shape) View.paint} method.
* The component must have a non-zero positive size for
* this translation to be computed.
*
* @return the bounding box for the root view
*/
protected Rectangle getVisibleEditorRect() { This renders like this:
We can also add @TejeshR13's suggestion: “The method name is preserved for backward compatibility.” There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is passed to Maybe we can mention "The returned rectangle is unrelated to visibility, and is used as an allocation parameter in javax.swing.text.View class to set the size and paint the allocated View" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Right. Both uses cases fall into the same category: the allocation controls the size of the root view. The returned allocation rectangle is also used in handling mutations to the text model. I'd rather leave it without any explanation why it's called allocation. Anyone who dealt with Swing text components and their implementation of the view classes is expected to roughly understand what allocation means. Searching for usages of
Yes, it is an op: it refers to
If we stick to explaining allocation, your suggestion makes sense, I edited it a bit: “The returned rectangle is unrelated to visibility, it is used to set the size of the root view.” This is what it means… without going too deep into the details. We could add |
||||||||||||||||
* the method is thus named to preserve backward compatibility. | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If method name is retained from past then this sentence would be right ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. The above rephrasing sounds clearer. |
||||||||||||||||
* The component must have a non-zero positive size for | ||||||||||||||||
* this translation to be computed. | ||||||||||||||||
* | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.