You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2018/06/05 00:14:11 UTC
svn commit: r1832904 [2/3] - in /pivot/trunk:
core/src/org/apache/pivot/beans/ core/src/org/apache/pivot/util/
tests/src/org/apache/pivot/tests/
wtk-terra/src/org/apache/pivot/wtk/skin/terra/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/s...
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java?rev=1832904&r1=1832903&r2=1832904&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Tue Jun 5 00:14:11 2018
@@ -82,7 +82,7 @@ public class TextInput extends Component
private final int index;
private final int count;
- public InsertTextEdit(CharSequence text, int index) {
+ public InsertTextEdit(final CharSequence text, final int index) {
this.index = index;
count = text.length();
}
@@ -97,7 +97,7 @@ public class TextInput extends Component
private final int index;
private final String text;
- public RemoveTextEdit(int index, int count) {
+ public RemoveTextEdit(final int index, final int count) {
this.index = index;
text = getText(index, index + count);
}
@@ -132,7 +132,8 @@ public class TextInput extends Component
private TextInputListener.Listeners textInputListeners = new TextInputListener.Listeners();
private TextInputContentListener.Listeners textInputContentListeners = new TextInputContentListener.Listeners();
- private TextInputSelectionListener.Listeners textInputSelectionListeners = new TextInputSelectionListener.Listeners();
+ private TextInputSelectionListener.Listeners textInputSelectionListeners =
+ new TextInputSelectionListener.Listeners();
private TextInputBindingListener.Listeners textInputBindingListeners = new TextInputBindingListener.Listeners();
public static final int DEFAULT_TEXT_SIZE = 16;
@@ -144,7 +145,7 @@ public class TextInput extends Component
}
@Override
- protected void setSkin(org.apache.pivot.wtk.Skin skin) {
+ protected void setSkin(final org.apache.pivot.wtk.Skin skin) {
checkSkin(skin, TextInput.Skin.class);
super.setSkin(skin);
@@ -166,11 +167,11 @@ public class TextInput extends Component
* @param endIndex The ending index of the text (exclusive).
* @return A string containing a copy of the text area's text content.
*/
- public String getText(int beginIndex, int endIndex) {
+ public String getText(final int beginIndex, final int endIndex) {
return characters.substring(beginIndex, endIndex);
}
- public void setText(String text) {
+ public void setText(final String text) {
Utils.checkNull(text, "text");
if (text.length() > maximumLength) {
@@ -204,11 +205,11 @@ public class TextInput extends Component
}
}
- public void insertText(CharSequence text, int index) {
+ public void insertText(final CharSequence text, final int index) {
insertText(text, index, true);
}
- private void insertText(CharSequence text, int index, boolean addToEditHistory) {
+ private void insertText(final CharSequence text, final int index, final boolean addToEditHistory) {
Utils.checkNull(text, "text");
if (characters.length() + text.length() > maximumLength) {
@@ -256,11 +257,11 @@ public class TextInput extends Component
}
}
- public void removeText(int index, int count) {
+ public void removeText(final int index, final int count) {
removeText(index, count, true);
}
- private void removeText(int index, int count, boolean addToEditHistory) {
+ private void removeText(final int index, final int count, final boolean addToEditHistory) {
if (count > 0) {
Vote vote = textInputContentListeners.previewRemoveText(this, index, count);
@@ -324,7 +325,7 @@ public class TextInput extends Component
* @param composedText The current composed text (which can be {@code null}
* for many different reasons).
*/
- public void setComposedText(AttributedStringCharacterIterator composedText) {
+ public void setComposedText(final AttributedStringCharacterIterator composedText) {
this.composedText = composedText;
}
@@ -341,7 +342,7 @@ public class TextInput extends Component
* @param start The start of the sequence (inclusive).
* @param end The end of the sequence (exclusive).
*/
- public CharSequence getCharacters(int start, int end) {
+ public CharSequence getCharacters(final int start, final int end) {
return characters.subSequence(start, end);
}
@@ -350,7 +351,7 @@ public class TextInput extends Component
*
* @param index Location of the character to retrieve.
*/
- public char getCharacterAt(int index) {
+ public char getCharacterAt(final int index) {
return characters.charAt(index);
}
@@ -419,14 +420,14 @@ public class TextInput extends Component
/**
* @return The starting index of the selection.
*/
- public int getSelectionStart() {
+ public final int getSelectionStart() {
return selectionStart;
}
/**
* @return The length of the selection; may be <tt>0</tt>.
*/
- public int getSelectionLength() {
+ public final int getSelectionLength() {
return selectionLength;
}
@@ -437,9 +438,8 @@ public class TextInput extends Component
* points are inclusive. Returns <tt>null</tt> if the selection length is
* <tt>0</tt>.
*/
- public Span getSelection() {
- return (selectionLength == 0) ? null :
- new Span(selectionStart, selectionStart + selectionLength - 1);
+ public final Span getSelection() {
+ return (selectionLength == 0) ? null : new Span(selectionStart, selectionStart + selectionLength - 1);
}
/**
@@ -447,7 +447,7 @@ public class TextInput extends Component
*
* @return A char span with the start and length values.
*/
- public CharSpan getCharSelection() {
+ public final CharSpan getCharSelection() {
return new CharSpan(selectionStart, selectionLength);
}
@@ -458,7 +458,7 @@ public class TextInput extends Component
* @param selectionStart The starting index of the selection.
* @param selectionLength The length of the selection.
*/
- public void setSelection(int selectionStart, int selectionLength) {
+ public final void setSelection(final int selectionStart, final int selectionLength) {
Utils.checkNonNegative(selectionLength, "selectionLength");
int composedTextLength = composedText != null ? (composedText.getEndIndex() - composedText.getBeginIndex()) : 0;
@@ -485,7 +485,7 @@ public class TextInput extends Component
* @see #setSelection(int, int)
* @throws IllegalArgumentException if the selection span is {@code null}.
*/
- public final void setSelection(Span selection) {
+ public final void setSelection(final Span selection) {
Utils.checkNull(selection, "selection");
setSelection(Math.min(selection.start, selection.end), (int) selection.getLength());
@@ -498,7 +498,7 @@ public class TextInput extends Component
* @see #setSelection(int, int)
* @throws IllegalArgumentException if the character span is {@code null}.
*/
- public final void setSelection(CharSpan selection) {
+ public final void setSelection(final CharSpan selection) {
Utils.checkNull(selection, "selection");
setSelection(selection.start, selection.length);
@@ -507,14 +507,14 @@ public class TextInput extends Component
/**
* Selects all text.
*/
- public void selectAll() {
+ public final void selectAll() {
setSelection(0, characters.length());
}
/**
* Clears the selection.
*/
- public void clearSelection() {
+ public final void clearSelection() {
setSelection(0, 0);
}
@@ -523,7 +523,7 @@ public class TextInput extends Component
*
* @return A new string containing a copy of the text in the selected range.
*/
- public String getSelectedText() {
+ public final String getSelectedText() {
return getText(selectionStart, selectionStart + selectionLength);
}
@@ -532,7 +532,7 @@ public class TextInput extends Component
*
* @return The number of characters to display in the text input.
*/
- public int getTextSize() {
+ public final int getTextSize() {
return textSize;
}
@@ -542,7 +542,7 @@ public class TextInput extends Component
* @param textSize The number of characters to display in the text input.
* @throws IllegalArgumentException if the size value is negative.
*/
- public void setTextSize(int textSize) {
+ public final void setTextSize(final int textSize) {
Utils.checkNonNegative(textSize, "textSize");
int previousTextSize = this.textSize;
@@ -558,7 +558,7 @@ public class TextInput extends Component
*
* @return The maximum length of the text input's text content.
*/
- public int getMaximumLength() {
+ public final int getMaximumLength() {
return maximumLength;
}
@@ -568,7 +568,7 @@ public class TextInput extends Component
* @param maximumLength The maximum length of the text input's text content.
* @throws IllegalArgumentException if the length value is negative.
*/
- public void setMaximumLength(int maximumLength) {
+ public final void setMaximumLength(final int maximumLength) {
Utils.checkNonNegative(maximumLength, "maximumLength");
int previousMaximumLength = this.maximumLength;
@@ -576,8 +576,7 @@ public class TextInput extends Component
if (previousMaximumLength != maximumLength) {
this.maximumLength = maximumLength;
- // Truncate the text, if necessary (do not allow listeners to vote
- // on this change)
+ // Truncate the text, if necessary (do not allow listeners to vote on this change)
int length = characters.length();
if (length > maximumLength) {
@@ -597,7 +596,7 @@ public class TextInput extends Component
* @return <tt>true</tt> if this is a password text input; <tt>false</tt>,
* otherwise.
*/
- public boolean isPassword() {
+ public final boolean isPassword() {
return password;
}
@@ -608,7 +607,7 @@ public class TextInput extends Component
* @param password <tt>true</tt> if this is a password text input;
* <tt>false</tt>, otherwise.
*/
- public void setPassword(boolean password) {
+ public final void setPassword(final boolean password) {
if (this.password != password) {
this.password = password;
textInputListeners.passwordChanged(this);
@@ -618,7 +617,7 @@ public class TextInput extends Component
/**
* @return The text input's prompt.
*/
- public String getPrompt() {
+ public final String getPrompt() {
return prompt;
}
@@ -627,7 +626,7 @@ public class TextInput extends Component
*
* @param prompt The prompt text, or <tt>null</tt> for no prompt.
*/
- public void setPrompt(String prompt) {
+ public final void setPrompt(final String prompt) {
String previousPrompt = this.prompt;
if (previousPrompt != prompt) {
@@ -641,7 +640,7 @@ public class TextInput extends Component
*
* @return The text key, or <tt>null</tt> if no text key is set.
*/
- public String getTextKey() {
+ public final String getTextKey() {
return textKey;
}
@@ -650,7 +649,7 @@ public class TextInput extends Component
*
* @param textKey The text key, or <tt>null</tt> to clear the binding.
*/
- public void setTextKey(String textKey) {
+ public final void setTextKey(final String textKey) {
String previousTextKey = this.textKey;
if (previousTextKey != textKey) {
@@ -659,11 +658,11 @@ public class TextInput extends Component
}
}
- public BindType getTextBindType() {
+ public final BindType getTextBindType() {
return textBindType;
}
- public void setTextBindType(BindType textBindType) {
+ public final void setTextBindType(final BindType textBindType) {
Utils.checkNull(textBindType, "textBindType");
BindType previousTextBindType = this.textBindType;
@@ -674,11 +673,11 @@ public class TextInput extends Component
}
}
- public TextBindMapping getTextBindMapping() {
+ public final TextBindMapping getTextBindMapping() {
return textBindMapping;
}
- public void setTextBindMapping(TextBindMapping textBindMapping) {
+ public final void setTextBindMapping(final TextBindMapping textBindMapping) {
TextBindMapping previousTextBindMapping = this.textBindMapping;
if (previousTextBindMapping != textBindMapping) {
@@ -688,7 +687,7 @@ public class TextInput extends Component
}
@Override
- public void load(Object context) {
+ public void load(final Object context) {
if (textKey != null && JSON.containsKey(context, textKey) && textBindType != BindType.STORE) {
Object value = JSON.get(context, textKey);
@@ -703,7 +702,7 @@ public class TextInput extends Component
}
@Override
- public void store(Object context) {
+ public void store(final Object context) {
if (textKey != null && textBindType != BindType.LOAD) {
String text = getText();
JSON.put(context, textKey,
@@ -718,12 +717,12 @@ public class TextInput extends Component
}
}
- public int getInsertionPoint(int x) {
+ public final int getInsertionPoint(final int x) {
TextInput.Skin textInputSkin = (TextInput.Skin) getSkin();
return textInputSkin.getInsertionPoint(x);
}
- public Bounds getCharacterBounds(int index) {
+ public final Bounds getCharacterBounds(final int index) {
TextInput.Skin textInputSkin = (TextInput.Skin) getSkin();
return textInputSkin.getCharacterBounds(index);
}
@@ -731,7 +730,7 @@ public class TextInput extends Component
/**
* @return The validator associated with this text input.
*/
- public Validator getValidator() {
+ public final Validator getValidator() {
return validator;
}
@@ -741,7 +740,7 @@ public class TextInput extends Component
* @param validator The validator to use, or <tt>null</tt> to use no
* validator.
*/
- public void setValidator(Validator validator) {
+ public final void setValidator(final Validator validator) {
Validator previousValidator = this.validator;
if (validator != previousValidator) {
@@ -765,7 +764,7 @@ public class TextInput extends Component
/**
* @return The text input's strict validation flag.
*/
- public boolean isStrictValidation() {
+ public final boolean isStrictValidation() {
return strictValidation;
}
@@ -775,7 +774,7 @@ public class TextInput extends Component
*
* @param strictValidation The new flag setting.
*/
- public void setStrictValidation(boolean strictValidation) {
+ public final void setStrictValidation(final boolean strictValidation) {
if (this.strictValidation != strictValidation) {
this.strictValidation = strictValidation;
textInputListeners.strictValidationChanged(this);
@@ -789,14 +788,14 @@ public class TextInput extends Component
* @return <tt>true</tt> if the text is valid or no validator is installed;
* <tt>false</tt>, otherwise.
*/
- public boolean isTextValid() {
+ public final boolean isTextValid() {
return textValid;
}
/**
* @return The text area's editable flag.
*/
- public boolean isEditable() {
+ public final boolean isEditable() {
return editable;
}
@@ -805,7 +804,7 @@ public class TextInput extends Component
*
* @param editable The new flag setting.
*/
- public void setEditable(boolean editable) {
+ public final void setEditable(final boolean editable) {
if (this.editable != editable) {
if (!editable) {
if (isFocused()) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ImageViewSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ImageViewSkin.java?rev=1832904&r1=1832903&r2=1832904&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ImageViewSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ImageViewSkin.java Tue Jun 5 00:14:11 2018
@@ -53,17 +53,17 @@ public class ImageViewSkin extends Compo
private ImageListener imageListener = new ImageListener() {
@Override
- public void sizeChanged(Image image, int previousWidth, int previousHeight) {
+ public void sizeChanged(final Image image, final int previousWidth, final int previousHeight) {
invalidateComponent();
}
@Override
- public void baselineChanged(Image image, int previousBaseline) {
+ public void baselineChanged(final Image image, final int previousBaseline) {
invalidateComponent();
}
@Override
- public void regionUpdated(Image image, int x, int y, int width, int height) {
+ public void regionUpdated(final Image image, final int x, final int y, final int width, final int height) {
// TODO A rounding error is causing an off-by-one error; we're
// accounting for it here by adding 1 to width and height
Bounds bounds = new Bounds(
@@ -76,7 +76,7 @@ public class ImageViewSkin extends Compo
};
@Override
- public void install(Component component) {
+ public void install(final Component component) {
super.install(component);
ImageView imageView = (ImageView) component;
@@ -89,7 +89,7 @@ public class ImageViewSkin extends Compo
}
@Override
- public int getPreferredWidth(int height) {
+ public int getPreferredWidth(final int height) {
ImageView imageView = (ImageView) getComponent();
Image image = imageView.getImage();
@@ -97,7 +97,7 @@ public class ImageViewSkin extends Compo
}
@Override
- public int getPreferredHeight(int width) {
+ public int getPreferredHeight(final int width) {
ImageView imageView = (ImageView) getComponent();
Image image = imageView.getImage();
@@ -109,12 +109,12 @@ public class ImageViewSkin extends Compo
ImageView imageView = (ImageView) getComponent();
Image image = imageView.getImage();
- return (image == null) ? Dimensions.ZERO :
- new Dimensions(image.getWidth(), image.getHeight());
+ return (image == null)
+ ? Dimensions.ZERO : new Dimensions(image.getWidth(), image.getHeight());
}
@Override
- public int getBaseline(int width, int height) {
+ public int getBaseline(final int width, final int height) {
ImageView imageView = (ImageView) getComponent();
Image image = imageView.getImage();
@@ -217,7 +217,7 @@ public class ImageViewSkin extends Compo
}
@Override
- public void paint(Graphics2D graphics) {
+ public void paint(final Graphics2D graphics) {
ImageView imageView = (ImageView) getComponent();
Image image = imageView.getImage();
@@ -234,8 +234,7 @@ public class ImageViewSkin extends Compo
imageGraphics.translate(imageX, imageY);
imageGraphics.scale(scaleX, scaleY);
- // Apply an alpha composite if the opacity value is less than
- // the current alpha
+ // Apply an alpha composite if the opacity value is less than the current alpha
float alpha = 1.0f;
Composite composite = imageGraphics.getComposite();
@@ -258,19 +257,19 @@ public class ImageViewSkin extends Compo
* @return <tt>false</tt>; image views are not focusable.
*/
@Override
- public boolean isFocusable() {
+ public final boolean isFocusable() {
return false;
}
@Override
- public boolean isOpaque() {
+ public final boolean isOpaque() {
return (backgroundColor != null && backgroundColor.getTransparency() == Transparency.OPAQUE);
}
/**
* @return The color that is painted behind the image.
*/
- public Color getBackgroundColor() {
+ public final Color getBackgroundColor() {
return backgroundColor;
}
@@ -279,7 +278,7 @@ public class ImageViewSkin extends Compo
*
* @param backgroundColor The new color for behind the image.
*/
- public void setBackgroundColor(Color backgroundColor) {
+ public final void setBackgroundColor(final Color backgroundColor) {
// A null background is acceptable
this.backgroundColor = backgroundColor;
repaintComponent();
@@ -292,14 +291,14 @@ public class ImageViewSkin extends Compo
* {@linkplain GraphicsUtilities#decodeColor color values recognized by
* Pivot}.
*/
- public final void setBackgroundColor(String backgroundColor) {
+ public final void setBackgroundColor(final String backgroundColor) {
setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor, "backgroundColor"));
}
/**
* @return The opacity of the image, in [0,1].
*/
- public float getOpacity() {
+ public final float getOpacity() {
return opacity;
}
@@ -308,7 +307,7 @@ public class ImageViewSkin extends Compo
*
* @param opacity A number between 0 (transparent) and 1 (opaque), inclusive.
*/
- public void setOpacity(float opacity) {
+ public final void setOpacity(final float opacity) {
if (opacity < 0 || opacity > 1) {
throw new IllegalArgumentException("Opacity out of range [0,1].");
}
@@ -322,7 +321,7 @@ public class ImageViewSkin extends Compo
*
* @param opacity A number between 0 (transparent) and 1 (opaque), inclusive.
*/
- public final void setOpacity(Number opacity) {
+ public final void setOpacity(final Number opacity) {
Utils.checkNull(opacity, "opacity");
setOpacity(opacity.floatValue());
@@ -331,7 +330,7 @@ public class ImageViewSkin extends Compo
/**
* @return The horizontal alignment of the image.
*/
- public HorizontalAlignment getHorizontalAlignment() {
+ public final HorizontalAlignment getHorizontalAlignment() {
return horizontalAlignment;
}
@@ -341,7 +340,7 @@ public class ImageViewSkin extends Compo
*
* @param horizontalAlignment The new alignment value.
*/
- public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment) {
+ public final void setHorizontalAlignment(final HorizontalAlignment horizontalAlignment) {
Utils.checkNull(horizontalAlignment, "horizontalAlignment");
this.horizontalAlignment = horizontalAlignment;
@@ -352,7 +351,7 @@ public class ImageViewSkin extends Compo
/**
* @return The vertical alignment of the image.
*/
- public VerticalAlignment getVerticalAlignment() {
+ public final VerticalAlignment getVerticalAlignment() {
return verticalAlignment;
}
@@ -362,7 +361,7 @@ public class ImageViewSkin extends Compo
*
* @param verticalAlignment The new alignment value.
*/
- public void setVerticalAlignment(VerticalAlignment verticalAlignment) {
+ public final void setVerticalAlignment(final VerticalAlignment verticalAlignment) {
Utils.checkNull(verticalAlignment, "verticalAlignment");
this.verticalAlignment = verticalAlignment;
@@ -374,7 +373,7 @@ public class ImageViewSkin extends Compo
* @return A boolean indicating whether the image will be scaled to fit the
* space in which it is placed.
*/
- public boolean getFill() {
+ public final boolean getFill() {
return fill;
}
@@ -386,7 +385,7 @@ public class ImageViewSkin extends Compo
*
* @param fill The new fill flag value.
*/
- public void setFill(boolean fill) {
+ public final void setFill(final boolean fill) {
this.fill = fill;
layout();
repaintComponent();
@@ -396,7 +395,7 @@ public class ImageViewSkin extends Compo
* @return A boolean indicating whether, when the image is scaled, its
* aspect ratio is preserved.
*/
- public boolean getPreserveAspectRatio() {
+ public final boolean getPreserveAspectRatio() {
return preserveAspectRatio;
}
@@ -406,7 +405,7 @@ public class ImageViewSkin extends Compo
*
* @param preserveAspectRatio The new flag value.
*/
- public void setPreserveAspectRatio(boolean preserveAspectRatio) {
+ public final void setPreserveAspectRatio(final boolean preserveAspectRatio) {
this.preserveAspectRatio = preserveAspectRatio;
layout();
repaintComponent();
@@ -414,7 +413,7 @@ public class ImageViewSkin extends Compo
// Image view events
@Override
- public void imageChanged(ImageView imageView, Image previousImage) {
+ public void imageChanged(final ImageView imageView, final Image previousImage) {
if (previousImage != null) {
previousImage.getImageListeners().remove(imageListener);
}
@@ -428,7 +427,7 @@ public class ImageViewSkin extends Compo
}
@Override
- public void asynchronousChanged(ImageView imageView) {
+ public void asynchronousChanged(final ImageView imageView) {
// No-op
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java?rev=1832904&r1=1832903&r2=1832904&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MovieViewSkin.java Tue Jun 5 00:14:11 2018
@@ -45,12 +45,12 @@ public class MovieViewSkin extends Compo
private MovieListener movieListener = new MovieListener() {
@Override
- public void sizeChanged(Movie movie, int previousWidth, int previousHeight) {
+ public void sizeChanged(final Movie movie, final int previousWidth, final int previousHeight) {
invalidateComponent();
}
@Override
- public void regionUpdated(Movie movie, int x, int y, int width, int height) {
+ public void regionUpdated(final Movie movie, final int x, final int y, final int width, final int height) {
repaintComponent(
movieX + (int) Math.floor(x * scale),
movieY + (int) Math.floor(y * scale),
@@ -60,7 +60,7 @@ public class MovieViewSkin extends Compo
};
@Override
- public void install(Component component) {
+ public void install(final Component component) {
super.install(component);
MovieView movieView = (MovieView) component;
@@ -73,7 +73,7 @@ public class MovieViewSkin extends Compo
}
@Override
- public int getPreferredWidth(int height) {
+ public int getPreferredWidth(final int height) {
MovieView movieView = (MovieView) getComponent();
Movie movie = movieView.getMovie();
@@ -81,7 +81,7 @@ public class MovieViewSkin extends Compo
}
@Override
- public int getPreferredHeight(int width) {
+ public int getPreferredHeight(final int width) {
MovieView movieView = (MovieView) getComponent();
Movie movie = movieView.getMovie();
@@ -93,9 +93,9 @@ public class MovieViewSkin extends Compo
MovieView movieView = (MovieView) getComponent();
Movie movie = movieView.getMovie();
- return (movie == null) ? Dimensions.ZERO :
- new Dimensions(Math.round(movie.getWidth() * scale),
- Math.round(movie.getHeight() * scale));
+ return (movie == null) ? Dimensions.ZERO
+ : new Dimensions(Math.round(movie.getWidth() * scale),
+ Math.round(movie.getHeight() * scale));
}
@Override
@@ -137,7 +137,7 @@ public class MovieViewSkin extends Compo
}
@Override
- public void paint(Graphics2D graphics) {
+ public void paint(final Graphics2D graphics) {
MovieView movieView = (MovieView) getComponent();
Movie movie = movieView.getMovie();
@@ -163,34 +163,34 @@ public class MovieViewSkin extends Compo
* @return <tt>false</tt>; movie views are not focusable.
*/
@Override
- public boolean isFocusable() {
+ public final boolean isFocusable() {
return false;
}
@Override
- public boolean isOpaque() {
+ public final boolean isOpaque() {
return (backgroundColor != null && backgroundColor.getTransparency() == Transparency.OPAQUE);
}
- public Color getBackgroundColor() {
+ public final Color getBackgroundColor() {
return backgroundColor;
}
- public void setBackgroundColor(Color backgroundColor) {
+ public final void setBackgroundColor(final Color backgroundColor) {
// Note: null background allowed here
this.backgroundColor = backgroundColor;
repaintComponent();
}
- public final void setBackgroundColor(String backgroundColor) {
+ public final void setBackgroundColor(final String backgroundColor) {
setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor, "backgroundColor"));
}
- public float getScale() {
+ public final float getScale() {
return scale;
}
- public void setScale(float scale) {
+ public final void setScale(final float scale) {
if (scale <= 0) {
throw new IllegalArgumentException("scale must be positive.");
}
@@ -199,11 +199,11 @@ public class MovieViewSkin extends Compo
invalidateComponent();
}
- public HorizontalAlignment getHorizontalAlignment() {
+ public final HorizontalAlignment getHorizontalAlignment() {
return horizontalAlignment;
}
- public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment) {
+ public final void setHorizontalAlignment(final HorizontalAlignment horizontalAlignment) {
Utils.checkNull(horizontalAlignment, "horizontalAlignment");
if (this.horizontalAlignment != horizontalAlignment) {
@@ -214,11 +214,11 @@ public class MovieViewSkin extends Compo
}
}
- public VerticalAlignment getVerticalAlignment() {
+ public final VerticalAlignment getVerticalAlignment() {
return verticalAlignment;
}
- public void setVerticalAlignment(VerticalAlignment verticalAlignment) {
+ public final void setVerticalAlignment(final VerticalAlignment verticalAlignment) {
Utils.checkNull(verticalAlignment, "verticalAlignment");
if (this.verticalAlignment != verticalAlignment) {
@@ -232,7 +232,7 @@ public class MovieViewSkin extends Compo
// MovieViewListener methods
@Override
- public void movieChanged(MovieView movieView, Movie previousMovie) {
+ public void movieChanged(final MovieView movieView, final Movie previousMovie) {
if (previousMovie != null) {
previousMovie.getMovieListeners().remove(movieListener);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=1832904&r1=1832903&r2=1832904&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Tue Jun 5 00:14:11 2018
@@ -44,6 +44,7 @@ import org.apache.pivot.wtk.Insets;
import org.apache.pivot.wtk.Keyboard;
import org.apache.pivot.wtk.Mouse;
import org.apache.pivot.wtk.Platform;
+import org.apache.pivot.wtk.SelectDirection;
import org.apache.pivot.wtk.TextArea;
import org.apache.pivot.wtk.TextAreaContentListener;
import org.apache.pivot.wtk.TextAreaListener;
@@ -74,11 +75,12 @@ public class TextAreaSkin extends Compon
int selectionStart = textArea.getSelectionStart();
int selectionLength = textArea.getSelectionLength();
int selectionEnd = selectionStart + selectionLength - 1;
+ int index;
switch (scrollDirection) {
- case UP: {
+ case UP:
// Get previous offset
- int index = getNextInsertionPoint(mouseX, selectionStart, scrollDirection);
+ index = getNextInsertionPoint(mouseX, selectionStart, scrollDirection);
if (index != -1) {
textArea.setSelection(index, selectionEnd - index + 1);
@@ -86,16 +88,13 @@ public class TextAreaSkin extends Compon
}
break;
- }
- case DOWN: {
+ case DOWN:
// Get next offset
- int index = getNextInsertionPoint(mouseX, selectionEnd, scrollDirection);
+ index = getNextInsertionPoint(mouseX, selectionEnd, scrollDirection);
if (index != -1) {
- // If the next character is a paragraph terminator,
- // increment
- // the selection
+ // If the next character is a paragraph terminator, increment the selection
if (index < textArea.getCharacterCount()
&& textArea.getCharacterAt(index) == '\n') {
index++;
@@ -106,11 +105,9 @@ public class TextAreaSkin extends Compon
}
break;
- }
- default: {
+ default:
break;
- }
}
}
}
@@ -123,6 +120,7 @@ public class TextAreaSkin extends Compon
private int anchor = -1;
private TextArea.ScrollDirection scrollDirection = null;
+ private SelectDirection selectDirection = null;
private int mouseX = -1;
private BlinkCaretCallback blinkCaretCallback = new BlinkCaretCallback();
@@ -173,7 +171,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public void install(Component component) {
+ public void install(final Component component) {
super.install(component);
Theme theme = currentTheme();
@@ -188,7 +186,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getPreferredWidth(int height) {
+ public int getPreferredWidth(final int height) {
int preferredWidth = 0;
if (lineWidth <= 0) {
@@ -206,12 +204,12 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getPreferredHeight(int width) {
+ public int getPreferredHeight(final int width) {
int preferredHeight = 0;
// Include margin in constraint
- int breakWidth = (wrapText && width != -1) ?
- Math.max(width - margin.getWidth(), 0) : Integer.MAX_VALUE;
+ int breakWidth = (wrapText && width != -1)
+ ? Math.max(width - margin.getWidth(), 0) : Integer.MAX_VALUE;
for (TextAreaSkinParagraphView paragraphView : paragraphViews) {
paragraphView.setBreakWidth(breakWidth);
@@ -280,7 +278,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getBaseline(int width, int height) {
+ public int getBaseline(final int width, final int height) {
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
LineMetrics lm = font.getLineMetrics("", fontRenderContext);
@@ -288,7 +286,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public void paint(Graphics2D graphics) {
+ public void paint(final Graphics2D graphics) {
TextArea textArea = (TextArea) getComponent();
int width = getWidth();
int height = getHeight();
@@ -338,7 +336,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getInsertionPoint(int x, int y) {
+ public int getInsertionPoint(final int x, final int y) {
int index = -1;
if (paragraphViews.getLength() > 0) {
@@ -372,7 +370,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getNextInsertionPoint(int x, int from, TextArea.ScrollDirection direction) {
+ public int getNextInsertionPoint(final int x, final int from, final TextArea.ScrollDirection direction) {
int index = -1;
if (paragraphViews.getLength() > 0) {
if (from == -1) {
@@ -418,7 +416,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getRowAt(int index) {
+ public int getRowAt(final int index) {
int rowIndex = -1;
if (paragraphViews.getLength() > 0) {
@@ -433,7 +431,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getRowOffset(int index) {
+ public int getRowOffset(final int index) {
int rowOffset = -1;
if (paragraphViews.getLength() > 0) {
@@ -448,7 +446,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public int getRowLength(int index) {
+ public int getRowLength(final int index) {
int rowLength = -1;
if (paragraphViews.getLength() > 0) {
@@ -473,7 +471,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public Bounds getCharacterBounds(int index) {
+ public Bounds getCharacterBounds(final int index) {
Bounds characterBounds = null;
if (paragraphViews.getLength() > 0) {
@@ -494,7 +492,7 @@ public class TextAreaSkin extends Compon
return selection;
}
- private void scrollCharacterToVisible(int index) {
+ private void scrollCharacterToVisible(final int index) {
Bounds characterBounds = getCharacterBounds(index);
if (characterBounds != null) {
@@ -507,7 +505,7 @@ public class TextAreaSkin extends Compon
/**
* @return The font of the text.
*/
- public Font getFont() {
+ public final Font getFont() {
return font;
}
@@ -516,7 +514,7 @@ public class TextAreaSkin extends Compon
*
* @param font The new font for the text.
*/
- public void setFont(Font font) {
+ public final void setFont(final Font font) {
Utils.checkNull(font, "font");
this.font = font;
@@ -531,7 +529,7 @@ public class TextAreaSkin extends Compon
*
* @param font A {@link ComponentSkin#decodeFont(String) font specification}
*/
- public final void setFont(String font) {
+ public final void setFont(final String font) {
setFont(decodeFont(font));
}
@@ -540,14 +538,14 @@ public class TextAreaSkin extends Compon
*
* @param font A dictionary {@link Theme#deriveFont describing a font}
*/
- public final void setFont(Dictionary<String, ?> font) {
+ public final void setFont(final Dictionary<String, ?> font) {
setFont(Theme.deriveFont(font));
}
/**
* @return The foreground color of the text.
*/
- public Color getColor() {
+ public final Color getColor() {
return color;
}
@@ -556,7 +554,7 @@ public class TextAreaSkin extends Compon
*
* @param color The new foreground text color.
*/
- public void setColor(Color color) {
+ public final void setColor(final Color color) {
Utils.checkNull(color, "color");
this.color = color;
@@ -569,98 +567,98 @@ public class TextAreaSkin extends Compon
* @param color Any of the {@linkplain GraphicsUtilities#decodeColor color
* values recognized by Pivot}.
*/
- public final void setColor(String color) {
+ public final void setColor(final String color) {
setColor(GraphicsUtilities.decodeColor(color, "color"));
}
- public Color getBackgroundColor() {
+ public final Color getBackgroundColor() {
return backgroundColor;
}
- public void setBackgroundColor(Color backgroundColor) {
+ public final void setBackgroundColor(final Color backgroundColor) {
// Null background is allowed here
this.backgroundColor = backgroundColor;
repaintComponent();
}
- public final void setBackgroundColor(String backgroundColor) {
+ public final void setBackgroundColor(final String backgroundColor) {
setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor, "backgroundColor"));
}
- public Color getInactiveColor() {
+ public final Color getInactiveColor() {
return inactiveColor;
}
- public void setInactiveColor(Color inactiveColor) {
+ public final void setInactiveColor(final Color inactiveColor) {
Utils.checkNull(inactiveColor, "inactiveColor");
this.inactiveColor = inactiveColor;
repaintComponent();
}
- public final void setInactiveColor(String inactiveColor) {
+ public final void setInactiveColor(final String inactiveColor) {
setColor(GraphicsUtilities.decodeColor(inactiveColor, "inactiveColor"));
}
- public Color getSelectionColor() {
+ public final Color getSelectionColor() {
return selectionColor;
}
- public void setSelectionColor(Color selectionColor) {
+ public final void setSelectionColor(final Color selectionColor) {
Utils.checkNull(selectionColor, "selectionColor");
this.selectionColor = selectionColor;
repaintComponent();
}
- public final void setSelectionColor(String selectionColor) {
+ public final void setSelectionColor(final String selectionColor) {
setSelectionColor(GraphicsUtilities.decodeColor(selectionColor, "selectionColor"));
}
- public Color getSelectionBackgroundColor() {
+ public final Color getSelectionBackgroundColor() {
return selectionBackgroundColor;
}
- public void setSelectionBackgroundColor(Color selectionBackgroundColor) {
+ public final void setSelectionBackgroundColor(final Color selectionBackgroundColor) {
Utils.checkNull(selectionBackgroundColor, "selectionBackgroundColor");
this.selectionBackgroundColor = selectionBackgroundColor;
repaintComponent();
}
- public final void setSelectionBackgroundColor(String selectionBackgroundColor) {
+ public final void setSelectionBackgroundColor(final String selectionBackgroundColor) {
setSelectionBackgroundColor(GraphicsUtilities.decodeColor(selectionBackgroundColor,
"selectionBackgroundColor"));
}
- public Color getInactiveSelectionColor() {
+ public final Color getInactiveSelectionColor() {
return inactiveSelectionColor;
}
- public void setInactiveSelectionColor(Color inactiveSelectionColor) {
+ public final void setInactiveSelectionColor(final Color inactiveSelectionColor) {
Utils.checkNull(inactiveSelectionColor, "inactiveSelectionColor");
this.inactiveSelectionColor = inactiveSelectionColor;
repaintComponent();
}
- public final void setInactiveSelectionColor(String inactiveSelectionColor) {
+ public final void setInactiveSelectionColor(final String inactiveSelectionColor) {
setInactiveSelectionColor(GraphicsUtilities.decodeColor(inactiveSelectionColor,
"inactiveSelectionColor"));
}
- public Color getInactiveSelectionBackgroundColor() {
+ public final Color getInactiveSelectionBackgroundColor() {
return inactiveSelectionBackgroundColor;
}
- public void setInactiveSelectionBackgroundColor(Color inactiveSelectionBackgroundColor) {
+ public final void setInactiveSelectionBackgroundColor(final Color inactiveSelectionBackgroundColor) {
Utils.checkNull(inactiveSelectionBackgroundColor, "inactiveSelectionBackgroundColor");
this.inactiveSelectionBackgroundColor = inactiveSelectionBackgroundColor;
repaintComponent();
}
- public final void setInactiveSelectionBackgroundColor(String inactiveSelectionBackgroundColor) {
+ public final void setInactiveSelectionBackgroundColor(final String inactiveSelectionBackgroundColor) {
setInactiveSelectionBackgroundColor(GraphicsUtilities.decodeColor(inactiveSelectionBackgroundColor,
"inactiveSelectionBackgroundColor"));
}
@@ -668,7 +666,7 @@ public class TextAreaSkin extends Compon
/**
* @return The amount of space between the edge of the TextArea and its text.
*/
- public Insets getMargin() {
+ public final Insets getMargin() {
return margin;
}
@@ -677,7 +675,7 @@ public class TextAreaSkin extends Compon
*
* @param margin The individual margin values for all edges.
*/
- public void setMargin(Insets margin) {
+ public final void setMargin(final Insets margin) {
Utils.checkNull(margin, "margin");
this.margin = margin;
@@ -689,7 +687,7 @@ public class TextAreaSkin extends Compon
*
* @param margin A dictionary with keys in the set {top, left, bottom, right}.
*/
- public final void setMargin(Dictionary<String, ?> margin) {
+ public final void setMargin(final Dictionary<String, ?> margin) {
setMargin(new Insets(margin));
}
@@ -698,7 +696,7 @@ public class TextAreaSkin extends Compon
*
* @param margin A sequence with values in the order [top, left, bottom, right].
*/
- public final void setMargin(Sequence<?> margin) {
+ public final void setMargin(final Sequence<?> margin) {
setMargin(new Insets(margin));
}
@@ -707,7 +705,7 @@ public class TextAreaSkin extends Compon
*
* @param margin The single value to use for all the margins.
*/
- public final void setMargin(int margin) {
+ public final void setMargin(final int margin) {
setMargin(new Insets(margin));
}
@@ -716,34 +714,34 @@ public class TextAreaSkin extends Compon
*
* @param margin The single value to use for all the margins.
*/
- public final void setMargin(Number margin) {
+ public final void setMargin(final Number margin) {
setMargin(new Insets(margin));
}
/**
* Sets the amount of space between the edge of the TextArea and its text.
*
- * @param margin A string containing an integer or a JSON dictionary with
- * keys left, top, bottom, and/or right.
+ * @param margin A string containing an integer or a JSON dictionary or list with
+ * keys top, left, bottom, and/or right.
*/
- public final void setMargin(String margin) {
+ public final void setMargin(final String margin) {
setMargin(Insets.decode(margin));
}
- public boolean getWrapText() {
+ public final boolean getWrapText() {
return wrapText;
}
- public void setWrapText(boolean wrapText) {
+ public final void setWrapText(final boolean wrapText) {
this.wrapText = wrapText;
invalidateComponent();
}
- public boolean getAcceptsEnter() {
+ public final boolean getAcceptsEnter() {
return acceptsEnter;
}
- public void setAcceptsEnter(boolean acceptsEnter) {
+ public final void setAcceptsEnter(final boolean acceptsEnter) {
this.acceptsEnter = acceptsEnter;
}
@@ -756,7 +754,7 @@ public class TextAreaSkin extends Compon
* <tt>false</tt> (default) means <tt>TAB</tt> shifts focus and
* <tt>Ctrl-TAB</tt> inserts spaces.
*/
- public boolean getAcceptsTab() {
+ public final boolean getAcceptsTab() {
return acceptsTab;
}
@@ -769,26 +767,26 @@ public class TextAreaSkin extends Compon
* <tt>false</tt> (default) means <tt>TAB</tt> shifts focus and
* <tt>Ctrl-TAB</tt> inserts spaces.
*/
- public void setAcceptsTab(boolean acceptsTab) {
+ public final void setAcceptsTab(final boolean acceptsTab) {
this.acceptsTab = acceptsTab;
}
@Override
- public int getTabWidth() {
+ public final int getTabWidth() {
return tabWidth;
}
- public void setTabWidth(int tabWidth) {
+ public final void setTabWidth(final int tabWidth) {
Utils.checkNonNegative(tabWidth, "tabWidth");
this.tabWidth = tabWidth;
}
- public int getLineWidth() {
+ public final int getLineWidth() {
return lineWidth;
}
- public void setLineWidth(int lineWidth) {
+ public final void setLineWidth(final int lineWidth) {
if (this.lineWidth != lineWidth) {
this.lineWidth = lineWidth;
@@ -796,7 +794,7 @@ public class TextAreaSkin extends Compon
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext,
- new int[] { missingGlyphCode });
+ new int[] {missingGlyphCode});
Rectangle2D textBounds = missingGlyphVector.getLogicalBounds();
Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext);
@@ -808,7 +806,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public boolean mouseMove(Component component, int x, int y) {
+ public boolean mouseMove(final Component component, final int x, final int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
@@ -846,8 +844,10 @@ public class TextAreaSkin extends Compon
// Select the range
if (index > anchor) {
textArea.setSelection(anchor, index - anchor);
+ selectDirection = SelectDirection.DOWN;
} else {
textArea.setSelection(index, anchor - index);
+ selectDirection = SelectDirection.UP;
}
}
@@ -863,7 +863,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ public boolean mouseDown(final Component component, final Mouse.Button button, final int x, final int y) {
boolean consumed = super.mouseDown(component, button, x, y);
TextArea textArea = (TextArea) component;
@@ -878,8 +878,10 @@ public class TextAreaSkin extends Compon
if (anchor > selectionStart) {
textArea.setSelection(selectionStart, anchor - selectionStart);
+ selectDirection = SelectDirection.RIGHT;
} else {
textArea.setSelection(anchor, selectionStart - anchor);
+ selectDirection = SelectDirection.LEFT;
}
} else {
// Move the caret to the insertion point
@@ -898,7 +900,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+ public boolean mouseUp(final Component component, final Mouse.Button button, final int x, final int y) {
boolean consumed = super.mouseUp(component, button, x, y);
if (Mouse.getCapturer() == component) {
@@ -918,7 +920,8 @@ public class TextAreaSkin extends Compon
}
@Override
- public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
+ public boolean mouseClick(final Component component, final Mouse.Button button,
+ final int x, final int y, final int count) {
boolean consumed = super.mouseClick(component, button, x, y, count);
TextArea textArea = (TextArea) component;
@@ -927,9 +930,10 @@ public class TextAreaSkin extends Compon
int index = getInsertionPoint(x, y);
if (index != -1) {
if (count == 2) {
- CharSpan charSpan = CharUtils.selectWord(textArea.getRowCharacters(index), index);
+ int offset = getRowOffset(index);
+ CharSpan charSpan = CharUtils.selectWord(textArea.getRowCharacters(index), index - offset);
if (charSpan != null) {
- textArea.setSelection(charSpan);
+ textArea.setSelection(charSpan.offset(offset));
}
} else if (count == 3) {
textArea.setSelection(textArea.getRowOffset(index),
@@ -941,7 +945,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public boolean keyTyped(Component component, char character) {
+ public boolean keyTyped(final Component component, final char character) {
boolean consumed = super.keyTyped(component, character);
if (paragraphViews.getLength() > 0) {
@@ -971,7 +975,7 @@ public class TextAreaSkin extends Compon
}
@Override
- public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
+ public boolean keyPressed(final Component component, final int keyCode, final Keyboard.KeyLocation keyLocation) {
boolean consumed = false;
if (paragraphViews.getLength() > 0) {
@@ -983,39 +987,32 @@ public class TextAreaSkin extends Compon
boolean metaPressed = Keyboard.isPressed(Keyboard.Modifier.META);
boolean isEditable = textArea.isEditable();
+ int selectionStart = textArea.getSelectionStart();
+ int selectionLength = textArea.getSelectionLength();
+ int count = textArea.getCharacterCount();
+
if (keyCode == Keyboard.KeyCode.ENTER && acceptsEnter && isEditable
&& Keyboard.getModifiers() == 0) {
- int index = textArea.getSelectionStart();
- textArea.removeText(index, textArea.getSelectionLength());
- textArea.insertText("\n", index);
+ textArea.removeText(selectionStart, selectionLength);
+ textArea.insertText("\n", selectionStart);
consumed = true;
} else if (keyCode == Keyboard.KeyCode.DELETE && isEditable) {
- int index = textArea.getSelectionStart();
-
- if (index < textArea.getCharacterCount()) {
- int count = Math.max(textArea.getSelectionLength(), 1);
- textArea.removeText(index, count);
-
+ if (selectionStart < count) {
+ textArea.removeText(selectionStart, Math.max(selectionLength, 1));
anchor = -1;
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.BACKSPACE && isEditable) {
- int index = textArea.getSelectionStart();
- int count = textArea.getSelectionLength();
-
- if (count == 0 && index > 0) {
- textArea.removeText(index - 1, 1);
+ if (selectionLength == 0 && selectionStart > 0) {
+ textArea.removeText(selectionStart - 1, 1);
consumed = true;
} else {
- textArea.removeText(index, count);
+ textArea.removeText(selectionStart, selectionLength);
consumed = true;
}
anchor = -1;
} else if (keyCode == Keyboard.KeyCode.TAB && (acceptsTab != ctrlPressed) && isEditable) {
- int selectionStart = textArea.getSelectionStart();
- int selectionLength = textArea.getSelectionLength();
-
int rowOffset = textArea.getRowOffset(selectionStart);
int linePos = selectionStart - rowOffset;
StringBuilder tabBuilder = new StringBuilder(tabWidth);
@@ -1023,7 +1020,7 @@ public class TextAreaSkin extends Compon
tabBuilder.append(" ");
}
- if (textArea.getCharacterCount() - selectionLength + tabWidth > textArea.getMaximumLength()) {
+ if (count - selectionLength + tabBuilder.length() > textArea.getMaximumLength()) {
Toolkit.getDefaultToolkit().beep();
} else {
textArea.removeText(selectionStart, selectionLength);
@@ -1036,23 +1033,29 @@ public class TextAreaSkin extends Compon
} else if (keyCode == Keyboard.KeyCode.HOME
|| (keyCode == Keyboard.KeyCode.LEFT && metaPressed)) {
int start;
- int selectionStart = textArea.getSelectionStart();
- int selectionLength = textArea.getSelectionLength();
+
if (commandPressed) {
- // Move the caret to the beginning of the text
+ // Find the very beginning of the text
start = 0;
} else {
- // Move the caret to the beginning of the line
+ // Find the start of the current line
start = getRowOffset(selectionStart);
}
if (shiftPressed) {
- selectionLength += selectionStart - start;
+ // Select from the beginning of the text to the current pivot position
+ if (selectDirection == SelectDirection.UP || selectDirection == SelectDirection.LEFT) {
+ selectionLength += selectionStart - start;
+ } else {
+ selectionLength = selectionStart - start;
+ }
+ selectDirection = SelectDirection.LEFT;
} else {
selectionLength = 0;
+ selectDirection = null;
}
- if (selectionStart >= 0) {
+ if (start >= 0) {
textArea.setSelection(start, selectionLength);
scrollCharacterToVisible(start);
@@ -1063,33 +1066,37 @@ public class TextAreaSkin extends Compon
} else if (keyCode == Keyboard.KeyCode.END
|| (keyCode == Keyboard.KeyCode.RIGHT && metaPressed)) {
int end;
- int selectionStart = textArea.getSelectionStart();
- int selectionLength = textArea.getSelectionLength();
int index = selectionStart + selectionLength;
if (commandPressed) {
- // Move the caret to end of the text
- end = textArea.getCharacterCount();
+ // Find the very end of the text
+ end = count;
} else {
- // Move the caret to the end of the line
+ // Find the end of the current line
int rowOffset = getRowOffset(index);
int rowLength = getRowLength(index);
end = rowOffset + rowLength;
}
if (shiftPressed) {
- selectionLength += end - index;
+ // Select from current pivot position to the end of the text
+ if (selectDirection == SelectDirection.UP || selectDirection == SelectDirection.LEFT) {
+ selectionStart += selectionLength;
+ }
+ selectionLength = end - selectionStart;
+ selectDirection = SelectDirection.RIGHT;
} else {
selectionStart = end;
- if (selectionStart < textArea.getCharacterCount()
+ if (selectionStart < count
&& textArea.getCharacterAt(selectionStart) != '\n') {
selectionStart--;
}
selectionLength = 0;
+ selectDirection = null;
}
- if (selectionStart + selectionLength <= textArea.getCharacterCount()) {
+ if (selectionStart + selectionLength <= count) {
textArea.setSelection(selectionStart, selectionLength);
scrollCharacterToVisible(selectionStart + selectionLength);
@@ -1101,29 +1108,20 @@ public class TextAreaSkin extends Compon
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.LEFT) {
- int selectionStart = textArea.getSelectionStart();
- int selectionLength = textArea.getSelectionLength();
-
if (wordNavPressed) {
+ int wordStart = (selectDirection == SelectDirection.RIGHT)
+ ? selectionStart + selectionLength : selectionStart;
// Move the caret to the start of the next word to the left
- if (selectionStart > 0) {
- // Skip over any space immediately to the left
- int index = selectionStart;
- while (index > 0
- && Character.isWhitespace(textArea.getCharacterAt(index - 1))) {
- index--;
- }
-
- // Skip over any word-letters to the left
- while (index > 0
- && !Character.isWhitespace(textArea.getCharacterAt(index - 1))) {
- index--;
- }
+ if (wordStart > 0) {
+ int index = CharUtils.findPriorWord(textArea.getCharacters(), wordStart);
if (shiftPressed) {
+ // TODO: depending on prior selectDirection, may just reduce previous right selection
selectionLength += selectionStart - index;
+ selectDirection = SelectDirection.LEFT;
} else {
selectionLength = 0;
+ selectDirection = null;
}
selectionStart = index;
@@ -1135,12 +1133,14 @@ public class TextAreaSkin extends Compon
selectionStart--;
selectionLength++;
}
+ selectDirection = SelectDirection.LEFT;
} else {
if (selectionLength > 0) {
selectionLength--;
} else {
selectionStart--;
selectionLength++;
+ selectDirection = SelectDirection.LEFT;
}
}
} else {
@@ -1150,6 +1150,7 @@ public class TextAreaSkin extends Compon
selectionStart--;
selectionLength++;
}
+ selectDirection = SelectDirection.LEFT;
}
} else {
// Move the caret back by one character
@@ -1160,6 +1161,7 @@ public class TextAreaSkin extends Compon
// Clear the selection
anchor = -1;
selectionLength = 0;
+ selectDirection = null;
}
if (selectionStart >= 0) {
@@ -1171,27 +1173,15 @@ public class TextAreaSkin extends Compon
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.RIGHT) {
- int selectionStart = textArea.getSelectionStart();
- int selectionLength = textArea.getSelectionLength();
-
if (wordNavPressed) {
+ int wordStart = (selectDirection == SelectDirection.LEFT)
+ ? selectionStart : selectionStart + selectionLength;
// Move the caret to the start of the next word to the right
- if (selectionStart < textArea.getCharacterCount()) {
- int index = selectionStart + selectionLength;
-
- // Skip over any space immediately to the right
- while (index < textArea.getCharacterCount()
- && Character.isWhitespace(textArea.getCharacterAt(index))) {
- index++;
- }
-
- // Skip over any word-letters to the right
- while (index < textArea.getCharacterCount()
- && !Character.isWhitespace(textArea.getCharacterAt(index))) {
- index++;
- }
+ if (wordStart < count) {
+ int index = CharUtils.findNextWord(textArea.getCharacters(), wordStart);
if (shiftPressed) {
+ // TODO: depending on prior selectDirection, may just reduce previous left selection
selectionLength = index - selectionStart;
} else {
selectionStart = index;
@@ -1205,11 +1195,13 @@ public class TextAreaSkin extends Compon
selectionLength--;
} else {
selectionLength++;
+ selectDirection = SelectDirection.RIGHT;
}
} else {
// Add the next character to the selection
anchor = selectionStart;
selectionLength++;
+ selectDirection = SelectDirection.RIGHT;
}
} else {
// Move the caret forward by one character
@@ -1222,9 +1214,10 @@ public class TextAreaSkin extends Compon
// Clear the selection
anchor = -1;
selectionLength = 0;
+ selectDirection = null;
}
- if (selectionStart + selectionLength <= textArea.getCharacterCount()) {
+ if (selectionStart + selectionLength <= count) {
textArea.setSelection(selectionStart, selectionLength);
scrollCharacterToVisible(selectionStart + selectionLength);
@@ -1236,9 +1229,6 @@ public class TextAreaSkin extends Compon
consumed = true;
}
} else if (keyCode == Keyboard.KeyCode.UP) {
- int selectionStart = textArea.getSelectionStart();
- int selectionLength = textArea.getSelectionLength();
-
int index = -1;
if (shiftPressed) {
if (anchor == -1) {
@@ -1290,9 +1280,6 @@ public class TextAreaSkin extends Compon
consumed = true;
} else if (keyCode == Keyboard.KeyCode.DOWN) {
- int selectionStart = textArea.getSelectionStart();
- int selectionLength = textArea.getSelectionLength();
-
if (shiftPressed) {
int from;
int x;
@@ -1308,8 +1295,7 @@ public class TextAreaSkin extends Compon
} else {
if (selectionStart < anchor) {
// Reducing upward size
- // Get next insertion point from leading selection
- // character
+ // Get next insertion point from leading selection character
from = selectionStart;
x = caretX;
@@ -1329,8 +1315,7 @@ public class TextAreaSkin extends Compon
}
} else {
// Increasing downward size
- // Get next insertion point from right edge of
- // trailing selection
+ // Get next insertion point from right edge of trailing selection
// character
from = selectionStart + selectionLength - 1;
@@ -1340,11 +1325,10 @@ public class TextAreaSkin extends Compon
index = getNextInsertionPoint(x, from, TextArea.ScrollDirection.DOWN);
if (index != -1) {
- // If the next character is a paragraph
- // terminator and is
+ // If the next character is a paragraph terminator and is
// not the final terminator character, increment
// the selection
- if (index < textArea.getCharacterCount() - 1
+ if (index < count - 1
&& textArea.getCharacterAt(index) == '\n') {
index++;
}
@@ -1357,12 +1341,10 @@ public class TextAreaSkin extends Compon
} else {
int from;
if (selectionLength == 0) {
- // Get next insertion point from leading selection
- // character
+ // Get next insertion point from leading selection character
from = selectionStart;
} else {
- // Get next insertion point from trailing selection
- // character
+ // Get next insertion point from trailing selection character
from = selectionStart + selectionLength - 1;
}
@@ -1379,7 +1361,7 @@ public class TextAreaSkin extends Compon
consumed = true;
} else if (commandPressed) {
if (keyCode == Keyboard.KeyCode.A) {
- textArea.setSelection(0, textArea.getCharacterCount());
+ textArea.setSelection(0, count);
consumed = true;
} else if (keyCode == Keyboard.KeyCode.X && isEditable) {
textArea.cut();
@@ -1413,13 +1395,13 @@ public class TextAreaSkin extends Compon
}
@Override
- public void enabledChanged(Component component) {
+ public void enabledChanged(final Component component) {
super.enabledChanged(component);
repaintComponent();
}
@Override
- public void focusedChanged(Component component, Component obverseComponent) {
+ public void focusedChanged(final Component component, final Component obverseComponent) {
super.focusedChanged(component, obverseComponent);
TextArea textArea = (TextArea) getComponent();
@@ -1437,17 +1419,17 @@ public class TextAreaSkin extends Compon
}
@Override
- public void maximumLengthChanged(TextArea textArea, int previousMaximumLength) {
+ public void maximumLengthChanged(final TextArea textArea, final int previousMaximumLength) {
// No-op
}
@Override
- public void editableChanged(TextArea textArea) {
+ public void editableChanged(final TextArea textArea) {
// No-op
}
@Override
- public void paragraphInserted(TextArea textArea, int index) {
+ public void paragraphInserted(final TextArea textArea, final int index) {
// Create paragraph view and add as paragraph listener
TextArea.Paragraph paragraph = textArea.getParagraphs().get(index);
TextAreaSkinParagraphView paragraphView = new TextAreaSkinParagraphView(this, paragraph);
@@ -1460,7 +1442,8 @@ public class TextAreaSkin extends Compon
}
@Override
- public void paragraphsRemoved(TextArea textArea, int index, Sequence<TextArea.Paragraph> removed) {
+ public void paragraphsRemoved(final TextArea textArea, final int index,
+ final Sequence<TextArea.Paragraph> removed) {
// Remove paragraph views as paragraph listeners
int count = removed.getLength();
@@ -1477,13 +1460,13 @@ public class TextAreaSkin extends Compon
}
@Override
- public void textChanged(TextArea textArea) {
+ public void textChanged(final TextArea textArea) {
// No-op
}
@Override
- public void selectionChanged(TextArea textArea, int previousSelectionStart,
- int previousSelectionLength) {
+ public void selectionChanged(final TextArea textArea, final int previousSelectionStart,
+ final int previousSelectionLength) {
// If the text area is valid, repaint the selection state; otherwise,
// the selection will be updated in layout()
if (textArea.isValid()) {
@@ -1566,7 +1549,7 @@ public class TextAreaSkin extends Compon
}
}
- private void showCaret(boolean show) {
+ private void showCaret(final boolean show) {
if (scheduledBlinkCaretCallback != null) {
scheduledBlinkCaretCallback.cancel();
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java?rev=1832904&r1=1832903&r2=1832904&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java Tue Jun 5 00:14:11 2018
@@ -53,11 +53,11 @@ class TextPaneSkinTextNodeView extends T
private TextLayout textLayout = null;
private TextPaneSkinTextNodeView next = null;
- public TextPaneSkinTextNodeView(TextPaneSkin textPaneSkin, TextNode textNode) {
+ public TextPaneSkinTextNodeView(final TextPaneSkin textPaneSkin, final TextNode textNode) {
this(textPaneSkin, textNode, 0);
}
- public TextPaneSkinTextNodeView(TextPaneSkin textPaneSkin, TextNode textNode, int start) {
+ public TextPaneSkinTextNodeView(final TextPaneSkin textPaneSkin, final TextNode textNode, final int start) {
super(textPaneSkin, textNode);
this.start = start;
}
@@ -97,16 +97,18 @@ class TextPaneSkinTextNodeView extends T
* @return The dimensions of the text in pixel amounts, or 0,0 if
* there is no text currently.
*/
- private static Dimensions getTextSize(TextLayout textLayout) {
+ private static Dimensions getTextSize(final TextLayout textLayout) {
if (textLayout != null) {
- int lineHeight = (int)Math.ceil(textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading());
- return new Dimensions((int)Math.ceil(textLayout.getAdvance()), lineHeight);
+ int lineHeight = (int) Math.ceil(textLayout.getAscent() + textLayout.getDescent()
+ + textLayout.getLeading());
+ return new Dimensions((int) Math.ceil(textLayout.getAdvance()), lineHeight);
}
// TODO: should this be 0 height? Maybe use average character height
return Dimensions.ZERO;
}
- private AttributedStringCharacterIterator getCharIterator(TextNode textNode, int start, int end, Font font) {
+ private AttributedStringCharacterIterator getCharIterator(final TextNode textNode, final int start,
+ final int end, final Font font) {
CharSequence characters;
int num = end - start;
if (num == textNode.getCharacterCount()) {
@@ -118,7 +120,7 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- protected void childLayout(int breakWidth) {
+ protected void childLayout(final int breakWidth) {
TextNode textNode = (TextNode) getNode();
textLayout = null;
@@ -157,7 +159,8 @@ class TextPaneSkinTextNodeView extends T
} else {
ourSpan = new Span(documentOffset + start, documentOffset + charCount - 1);
}
- // The "composed span" just encompasses the start position, because this is "phantom" text, so it exists between any two other "real" text positions.
+ // The "composed span" just encompasses the start position, because this is "phantom" text,
+ // so it exists between any two other "real" text positions.
Span composedSpan = new Span(selectionStart + composedTextBegin);
composedIntersects = composedSpan.intersects(ourSpan);
}
@@ -178,7 +181,8 @@ class TextPaneSkinTextNodeView extends T
if (charCount - start == 0) {
text = composedText;
} else {
- AttributedStringCharacterIterator fullText = getCharIterator(textNode, start, charCount, effectiveFont);
+ AttributedStringCharacterIterator fullText =
+ getCharIterator(textNode, start, charCount, effectiveFont);
// Note: only apply the underline and strikethrough to our text, not the composed text
fullText.addUnderlineAttribute(underlined);
fullText.addStrikethroughAttribute(struckthrough);
@@ -186,23 +190,27 @@ class TextPaneSkinTextNodeView extends T
}
} else if (composedPos == charCount) {
// Composed text is at the end
- AttributedStringCharacterIterator fullText = getCharIterator(textNode, start, charCount, effectiveFont);
+ AttributedStringCharacterIterator fullText =
+ getCharIterator(textNode, start, charCount, effectiveFont);
// Note: only apply the underline and strikethrough to our text, not the composed text
fullText.addUnderlineAttribute(underlined);
fullText.addStrikethroughAttribute(struckthrough);
text = new CompositeIterator(fullText, composedText);
} else {
// Composed text is somewhere in the middle
- AttributedStringCharacterIterator leadingText = getCharIterator(textNode, start, composedPos, effectiveFont);
+ AttributedStringCharacterIterator leadingText =
+ getCharIterator(textNode, start, composedPos, effectiveFont);
leadingText.addUnderlineAttribute(underlined);
leadingText.addStrikethroughAttribute(struckthrough);
- AttributedStringCharacterIterator trailingText = getCharIterator(textNode, composedPos, charCount, effectiveFont);
+ AttributedStringCharacterIterator trailingText =
+ getCharIterator(textNode, composedPos, charCount, effectiveFont);
trailingText.addUnderlineAttribute(underlined);
trailingText.addStrikethroughAttribute(struckthrough);
text = new CompositeIterator(leadingText, composedText, trailingText);
}
} else {
- AttributedStringCharacterIterator fullText = getCharIterator(textNode, start, charCount, effectiveFont);
+ AttributedStringCharacterIterator fullText =
+ getCharIterator(textNode, start, charCount, effectiveFont);
fullText.addUnderlineAttribute(underlined);
fullText.addStrikethroughAttribute(struckthrough);
text = fullText;
@@ -210,7 +218,7 @@ class TextPaneSkinTextNodeView extends T
if (getTextPaneSkin().getWrapText()) {
LineBreakMeasurer measurer = new LineBreakMeasurer(text, fontRenderContext);
- float wrappingWidth = (float)breakWidth;
+ float wrappingWidth = (float) breakWidth;
textLayout = measurer.nextLayout(wrappingWidth);
length = textLayout.getCharacterCount();
Dimensions size = getTextSize(textLayout);
@@ -229,15 +237,14 @@ class TextPaneSkinTextNodeView extends T
Dimensions size = getTextSize(textLayout);
float advance = textLayout.getAdvance();
setSize(size);
- // set to null in case this node used to be broken across multiple,
- // but is no longer
+ // set to null in case this node used to be broken across multiple, but is no longer
next = null;
}
}
}
@Override
- public Dimensions getPreferredSize(int breakWidth) {
+ public Dimensions getPreferredSize(final int breakWidth) {
TextNode textNode = (TextNode) getNode();
Font effectiveFont = getEffectiveFont();
@@ -245,7 +252,7 @@ class TextPaneSkinTextNodeView extends T
// TODO: figure out if the composedText impinges on this node or not
// and construct an iterator based on that
// For now, just get the committed text
- if (textNode.getCharacterCount() == 0 /* && composedText == null || composedText doesn't impinge on this node */) {
+ if (textNode.getCharacterCount() == 0 /* && composedText == null || doesn't impinge on this node */) {
Dimensions charSize = GraphicsUtilities.getAverageCharacterSize(effectiveFont);
return new Dimensions(0, charSize.height);
} else {
@@ -261,7 +268,7 @@ class TextPaneSkinTextNodeView extends T
TextLayout currentTextLayout;
if (getTextPaneSkin().getWrapText()) {
LineBreakMeasurer measurer = new LineBreakMeasurer(text, fontRenderContext);
- float wrappingWidth = (float)breakWidth;
+ float wrappingWidth = (float) breakWidth;
currentTextLayout = measurer.nextLayout(wrappingWidth);
} else {
// Not wrapping the text, then the width is of the whole thing
@@ -281,12 +288,12 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- protected void setSkinLocation(int skinX, int skinY) {
+ protected void setSkinLocation(final int skinX, final int skinY) {
// empty block
}
@Override
- public void paint(Graphics2D graphics) {
+ public void paint(final Graphics2D graphics) {
if (textLayout != null) {
TextPane textPane = (TextPane) getTextPaneSkin().getComponent();
@@ -364,12 +371,12 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- public int getOffset() {
+ public final int getOffset() {
return super.getOffset() + start;
}
@Override
- public int getCharacterCount() {
+ public final int getCharacterCount() {
return length;
}
@@ -379,7 +386,7 @@ class TextPaneSkinTextNodeView extends T
*
* @return The next node view in the document.
*/
- public TextPaneSkinNodeView getNext() {
+ public final TextPaneSkinNodeView getNext() {
return next;
}
@@ -435,7 +442,7 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- public int getInsertionPoint(int x, int y) {
+ public int getInsertionPoint(final int x, final int y) {
int offset = 0;
if (textLayout != null) {
@@ -444,8 +451,8 @@ class TextPaneSkinTextNodeView extends T
float ascent = lm.getAscent();
// Translate to glyph coordinates
- float fx = (float)x;
- float fy = (float)y - ascent;
+ float fx = (float) x;
+ float fy = (float) y - ascent;
TextHitInfo hitInfo = textLayout.hitTestChar(fx, fy);
offset = hitInfo.getInsertionIndex();
@@ -455,7 +462,7 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- public int getNextInsertionPoint(int x, int from, TextPane.ScrollDirection direction) {
+ public int getNextInsertionPoint(final int x, final int from, final TextPane.ScrollDirection direction) {
int offset = -1;
if (from == -1) {
@@ -464,7 +471,7 @@ class TextPaneSkinTextNodeView extends T
// "hitTestChar" will map out-of-bounds points to the beginning or end of the text
// but we need to know if the given x is inside or not, so test that first.
if (textBounds.contains(x, 0)) {
- TextHitInfo hitInfo = textLayout.hitTestChar((float)x, 0f);
+ TextHitInfo hitInfo = textLayout.hitTestChar((float) x, 0f);
offset = hitInfo.getInsertionIndex();
}
}
@@ -473,7 +480,7 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- public int getRowAt(int offset) {
+ public int getRowAt(final int offset) {
return -1;
}
@@ -483,7 +490,7 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- public Bounds getCharacterBounds(int offset) {
+ public Bounds getCharacterBounds(final int offset) {
Bounds characterBounds = null;
if (textLayout != null) {
// If the offest == length, then use the right hand edge of the previous
@@ -506,12 +513,12 @@ class TextPaneSkinTextNodeView extends T
}
@Override
- public void charactersInserted(TextNode textNode, int index, int count) {
+ public void charactersInserted(final TextNode textNode, final int index, final int count) {
invalidateUpTree();
}
@Override
- public void charactersRemoved(TextNode textNode, int index, int count) {
+ public void charactersRemoved(final TextNode textNode, final int index, final int count) {
invalidateUpTree();
}
@@ -526,8 +533,8 @@ class TextPaneSkinTextNodeView extends T
} else {
textSubString = text.substring(start, start + length);
}
- return ClassUtils.simpleToString(this) +
- " start=" + start + ",length=" + length + " [" + textSubString + "]";
+ return ClassUtils.simpleToString(this)
+ + " start=" + start + ",length=" + length + " [" + textSubString + "]";
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java?rev=1832904&r1=1832903&r2=1832904&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java Tue Jun 5 00:14:11 2018
@@ -24,25 +24,25 @@ public class Document extends Block {
super();
}
- public Document(Document document, boolean recursive) {
+ public Document(final Document document, final boolean recursive) {
super(document, recursive);
}
@Override
- protected void setParent(Element parent) {
+ protected void setParent(final Element parent) {
throw new UnsupportedOperationException();
}
@Override
- public Document duplicate(boolean recursive) {
+ public Document duplicate(final boolean recursive) {
return new Document(this, recursive);
}
@Override
- public void insert(Node node, int index) {
+ public void insert(final Node node, final int index) {
if (!(node instanceof Block)) {
- throw new IllegalArgumentException("Child node (" +
- node.getClass().getSimpleName() + ") must be an instance of "
+ throw new IllegalArgumentException("Child node ("
+ + node.getClass().getSimpleName() + ") must be an instance of "
+ Block.class.getName());
}