Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java?rev=1838293&r1=1838292&r2=1838293&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java Fri Aug 17 22:27:05 2018 @@ -49,7 +49,8 @@ public abstract class ListButtonSkin ext private ComponentMouseButtonListener listViewPopupMouseButtonListener = new ComponentMouseButtonListener() { @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) { ListButton listButton = (ListButton) getComponent(); listViewPopup.close(); @@ -75,44 +76,39 @@ public abstract class ListButtonSkin ext * and transfer focus backwards. */ @Override - public boolean keyPressed(Component component, int keyCode, KeyLocation keyLocation) { + public boolean keyPressed(final Component component, final int keyCode, final KeyLocation keyLocation) { ListButton listButton = (ListButton) getComponent(); + int index; switch (keyCode) { - case KeyCode.ENTER: { + case KeyCode.ENTER: listViewPopup.close(); - int index = listView.getSelectedIndex(); + index = listView.getSelectedIndex(); listButton.setSelectedIndex(index); if (listButton.isRepeatable()) { listButton.press(); } - break; - } - case KeyCode.TAB: { + case KeyCode.TAB: listViewPopup.close(); - int index = listView.getSelectedIndex(); + index = listView.getSelectedIndex(); listButton.setSelectedIndex(index); - FocusTraversalDirection direction = (Keyboard.isPressed(Modifier.SHIFT)) ? FocusTraversalDirection.BACKWARD - : FocusTraversalDirection.FORWARD; + FocusTraversalDirection direction = (Keyboard.isPressed(Modifier.SHIFT)) + ? FocusTraversalDirection.BACKWARD : FocusTraversalDirection.FORWARD; listButton.transferFocus(direction); - break; - } - case KeyCode.ESCAPE: { + case KeyCode.ESCAPE: listViewPopup.close(); break; - } - default: { + default: break; - } } return false; @@ -121,7 +117,7 @@ public abstract class ListButtonSkin ext private WindowStateListener listViewPopupWindowStateListener = new WindowStateListener() { @Override - public void windowOpened(Window window) { + public void windowOpened(final Window window) { Display display = window.getDisplay(); display.getContainerMouseListeners().add(displayMouseListener); @@ -129,7 +125,7 @@ public abstract class ListButtonSkin ext } @Override - public Vote previewWindowClose(Window window) { + public Vote previewWindowClose(final Window window) { if (window.containsFocus()) { getComponent().requestFocus(); } @@ -138,14 +134,14 @@ public abstract class ListButtonSkin ext } @Override - public void windowCloseVetoed(Window window, Vote reason) { + public void windowCloseVetoed(final Window window, final Vote reason) { if (reason == Vote.DENY) { window.requestFocus(); } } @Override - public void windowClosed(Window window, Display display, Window owner) { + public void windowClosed(final Window window, final Display display, final Window owner) { display.getContainerMouseListeners().remove(displayMouseListener); Window componentWindow = getComponent().getWindow(); @@ -157,7 +153,7 @@ public abstract class ListButtonSkin ext private ContainerMouseListener displayMouseListener = new ContainerMouseListener() { @Override - public boolean mouseDown(Container container, Mouse.Button button, int x, int y) { + public boolean mouseDown(final Container container, final Mouse.Button button, final int x, final int y) { Display display = (Display) container; Component descendant = display.getDescendantAt(x, y); @@ -170,8 +166,8 @@ public abstract class ListButtonSkin ext } @Override - public boolean mouseWheel(Container container, Mouse.ScrollType scrollType, - int scrollAmount, int wheelRotation, int x, int y) { + public boolean mouseWheel(final Container container, final Mouse.ScrollType scrollType, + final int scrollAmount, final int wheelRotation, final int x, final int y) { boolean consumed = false; Display display = (Display) container; @@ -197,7 +193,7 @@ public abstract class ListButtonSkin ext } @Override - public void install(Component component) { + public void install(final Component component) { super.install(component); ListButton listButton = (ListButton) component; @@ -218,7 +214,7 @@ public abstract class ListButtonSkin ext // Component state events @Override - public void enabledChanged(Component component) { + public void enabledChanged(final Component component) { super.enabledChanged(component); if (!component.isEnabled()) { @@ -231,13 +227,12 @@ public abstract class ListButtonSkin ext } @Override - public void focusedChanged(Component component, Component obverseComponent) { + public void focusedChanged(final Component component, final Component obverseComponent) { super.focusedChanged(component, obverseComponent); repaintComponent(); - // Close the popup if focus was transferred to a component whose - // window is not the popup + // Close the popup if focus was transferred to a component whose window is not the popup if (!component.isFocused()) { pressed = false; @@ -249,7 +244,7 @@ public abstract class ListButtonSkin ext // Component mouse events @Override - public void mouseOut(Component component) { + public void mouseOut(final Component component) { super.mouseOut(component); pressed = false; @@ -257,7 +252,7 @@ public abstract class ListButtonSkin ext } @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); pressed = true; @@ -277,7 +272,7 @@ public abstract class ListButtonSkin ext } @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) { pressed = false; repaintComponent(); @@ -285,7 +280,8 @@ public abstract class ListButtonSkin ext } @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); ListButton listButton = (ListButton) getComponent(); @@ -305,7 +301,7 @@ public abstract class ListButtonSkin ext * @see #keyReleased(Component, int, Keyboard.KeyLocation) */ @Override - public boolean keyPressed(Component component, int keyCode, KeyLocation keyLocation) { + public boolean keyPressed(final Component component, final int keyCode, final KeyLocation keyLocation) { boolean consumed = false; ListButton listButton = (ListButton) getComponent(); @@ -359,7 +355,7 @@ public abstract class ListButtonSkin ext * {@link KeyCode#SPACE SPACE} 'presses' the button. */ @Override - public boolean keyReleased(Component component, int keyCode, KeyLocation keyLocation) { + public boolean keyReleased(final Component component, final int keyCode, final KeyLocation keyLocation) { boolean consumed = false; ListButton listButton = (ListButton) getComponent(); @@ -383,7 +379,7 @@ public abstract class ListButtonSkin ext * rendered text matches the typed key (case insensitive). */ @Override - public boolean keyTyped(Component component, char character) { + public boolean keyTyped(final Component component, final char character) { boolean consumed = super.keyTyped(component, character); ListButton listButton = (ListButton) getComponent(); @@ -414,37 +410,37 @@ public abstract class ListButtonSkin ext // List button events @Override - public void listDataChanged(ListButton listButton, List<?> previousListData) { + public void listDataChanged(final ListButton listButton, final List<?> previousListData) { listButton.setButtonData(null); listView.setListData(listButton.getListData()); invalidateComponent(); } @Override - public void itemRendererChanged(ListButton listButton, - ListView.ItemRenderer previousItemRenderer) { + public void itemRendererChanged(final ListButton listButton, + final ListView.ItemRenderer previousItemRenderer) { listView.setItemRenderer(listButton.getItemRenderer()); } @Override - public void repeatableChanged(ListButton listButton) { + public void repeatableChanged(final ListButton listButton) { // No-op } @Override - public void disabledItemFilterChanged(ListButton listButton, - Filter<?> previousDisabledItemFilter) { + public void disabledItemFilterChanged(final ListButton listButton, + final Filter<?> previousDisabledItemFilter) { listView.setDisabledItemFilter(listButton.getDisabledItemFilter()); } @Override - public void listSizeChanged(ListButton listButton, int previousListSize) { + public void listSizeChanged(final ListButton listButton, final int previousListSize) { // No-op } // List button selection events @Override - public void selectedIndexChanged(ListButton listButton, int previousSelectedIndex) { + public void selectedIndexChanged(final ListButton listButton, final int previousSelectedIndex) { int selectedIndex = listButton.getSelectedIndex(); if (selectedIndex != previousSelectedIndex) { @@ -458,7 +454,7 @@ public abstract class ListButtonSkin ext } @Override - public void selectedItemChanged(ListButton listButton, Object previousSelectedItem) { + public void selectedItemChanged(final ListButton listButton, final Object previousSelectedItem) { // No-op } }
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/NumberRulerSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/NumberRulerSkin.java?rev=1838293&r1=1838292&r2=1838293&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/NumberRulerSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/NumberRulerSkin.java Fri Aug 17 22:27:05 2018 @@ -39,6 +39,10 @@ import org.apache.pivot.wtk.Orientation; import org.apache.pivot.wtk.Platform; import org.apache.pivot.wtk.Theme; +/** + * Skin for the {@link NumberRuler} component, which can be used as a horizontal or + * vertical header for viewports. + */ public class NumberRulerSkin extends ComponentSkin implements NumberRulerListener { private static final int MAJOR_SIZE = 10; private static final int MINOR_SIZE = 8; @@ -59,7 +63,7 @@ public class NumberRulerSkin extends Com private int lineHeight; @Override - public void install(Component component) { + public void install(final Component component) { super.install(component); Theme theme = Theme.getTheme(); @@ -90,7 +94,7 @@ public class NumberRulerSkin extends Com } @Override - public int getPreferredHeight(int width) { + public int getPreferredHeight(final int width) { NumberRuler ruler = (NumberRuler) getComponent(); Orientation orientation = ruler.getOrientation(); @@ -101,7 +105,7 @@ public class NumberRulerSkin extends Com } @Override - public int getPreferredWidth(int height) { + public int getPreferredWidth(final int height) { NumberRuler ruler = (NumberRuler) getComponent(); Orientation orientation = ruler.getOrientation(); @@ -120,8 +124,8 @@ public class NumberRulerSkin extends Com return 0; } - private void showNumber(Graphics2D graphics, FontRenderContext fontRenderContext, - int number, int x, int y) { + private void showNumber(final Graphics2D graphics, final FontRenderContext fontRenderContext, + final int number, final int x, final int y) { String num = Integer.toString(number); StringCharacterIterator line; @@ -142,7 +146,7 @@ public class NumberRulerSkin extends Com } @Override - public void paint(Graphics2D graphics) { + public void paint(final Graphics2D graphics) { int width = getWidth(); int height = getHeight(); int bottom = height - markerInsets.bottom; @@ -164,15 +168,17 @@ public class NumberRulerSkin extends Com Rectangle fullRect = new Rectangle(width, height); Rectangle clippedRect = fullRect.intersection(clipRect); + Rectangle lineRect, clippedLineRect; + switch (orientation) { - case HORIZONTAL: { + case HORIZONTAL: int start = bottom - 1; int end2 = start - (MAJOR_SIZE - 1); int end3 = start - (MINOR_SIZE - 1); int end4 = start - (REGULAR_SIZE - 1); - Rectangle lineRect = new Rectangle(0, height - 1, width - 1, 0); - Rectangle clippedLineRect = lineRect.intersection(clipRect); + lineRect = new Rectangle(0, height - 1, width - 1, 0); + clippedLineRect = lineRect.intersection(clipRect); graphics.drawLine(clippedLineRect.x, clippedLineRect.y, clippedLineRect.x + clippedLineRect.width, clippedLineRect.y); @@ -196,11 +202,10 @@ public class NumberRulerSkin extends Com } } break; - } - case VERTICAL: { - Rectangle lineRect = new Rectangle(width - 1, 0, 0, height - 1); - Rectangle clippedLineRect = lineRect.intersection(clipRect); + case VERTICAL: + lineRect = new Rectangle(width - 1, 0, 0, height - 1); + clippedLineRect = lineRect.intersection(clipRect); graphics.drawLine(clippedLineRect.x, clippedLineRect.y, clippedLineRect.x, clippedLineRect.y + clippedLineRect.height); @@ -226,7 +231,6 @@ public class NumberRulerSkin extends Com lineGraphics.drawGlyphVector(glyphVector, x, y); } break; - } default: break; @@ -234,51 +238,50 @@ public class NumberRulerSkin extends Com } @Override - public void orientationChanged(NumberRuler ruler) { + public void orientationChanged(final NumberRuler ruler) { invalidateComponent(); } @Override - public void textSizeChanged(NumberRuler ruler, int previousSize) { + public void textSizeChanged(final NumberRuler ruler, final int previousSize) { invalidateComponent(); } /** - * @return The insets for the markers (only applicable for horizontal - * orientation). + * @return The insets for the markers (only applicable for horizontal orientation). */ public Insets getMarkerInsets() { return markerInsets; } - public final void setMarkerInsets(Insets insets) { + public final void setMarkerInsets(final Insets insets) { Utils.checkNull(insets, "markerInsets"); this.markerInsets = insets; repaintComponent(); } - public final void setMarkerInsets(Dictionary<String, ?> insets) { + public final void setMarkerInsets(final Dictionary<String, ?> insets) { setMarkerInsets(new Insets(insets)); } - public final void setMarkerInsets(Sequence<?> insets) { + public final void setMarkerInsets(final Sequence<?> insets) { setMarkerInsets(new Insets(insets)); } - public final void setMarkerInsets(int insets) { + public final void setMarkerInsets(final int insets) { setMarkerInsets(new Insets(insets)); } - public final void setMarkerInsets(Number insets) { + public final void setMarkerInsets(final Number insets) { setMarkerInsets(new Insets(insets)); } - public final void setMarkerInsets(String insets) { + public final void setMarkerInsets(final String insets) { setMarkerInsets(Insets.decode(insets)); } - public final void setRowPadding(Insets padding) { + public final void setRowPadding(final Insets padding) { Utils.checkNull(padding, "rowPadding"); this.rowPadding = padding; @@ -291,23 +294,23 @@ public class NumberRulerSkin extends Com } } - public final void setRowPadding(Dictionary<String, ?> padding) { + public final void setRowPadding(final Dictionary<String, ?> padding) { setRowPadding(new Insets(padding)); } - public final void setRowPadding(Sequence<?> padding) { + public final void setRowPadding(final Sequence<?> padding) { setRowPadding(new Insets(padding)); } - public final void setRowPadding(int padding) { + public final void setRowPadding(final int padding) { setRowPadding(new Insets(padding)); } - public final void setRowPadding(Number padding) { + public final void setRowPadding(final Number padding) { setRowPadding(new Insets(padding)); } - public final void setRowPadding(String padding) { + public final void setRowPadding(final String padding) { setRowPadding(Insets.decode(padding)); } @@ -324,14 +327,14 @@ public class NumberRulerSkin extends Com * * @param spacing The number of pixels between markers (must be >= 1). */ - public final void setMarkerSpacing(int spacing) { + public final void setMarkerSpacing(final int spacing) { Utils.checkPositive(spacing, "markerSpacing"); this.markerSpacing = spacing; invalidateComponent(); } - public final void setMarkerSpacing(Number spacing) { + public final void setMarkerSpacing(final Number spacing) { Utils.checkNull(spacing, "markerSpacing"); setMarkerSpacing(spacing.intValue()); @@ -351,7 +354,7 @@ public class NumberRulerSkin extends Com * * @param showMajorNumbers Whether numbers should be shown for major divisions. */ - public final void setShowMajorNumbers(boolean showMajorNumbers) { + public final void setShowMajorNumbers(final boolean showMajorNumbers) { this.showMajorNumbers = showMajorNumbers; NumberRuler ruler = (NumberRuler) getComponent(); @@ -374,7 +377,7 @@ public class NumberRulerSkin extends Com * * @param showMinorNumbers Whether numbers should be shown for minor divisions. */ - public final void setShowMinorNumbers(boolean showMinorNumbers) { + public final void setShowMinorNumbers(final boolean showMinorNumbers) { this.showMinorNumbers = showMinorNumbers; NumberRuler ruler = (NumberRuler) getComponent(); @@ -392,7 +395,7 @@ public class NumberRulerSkin extends Com * * @param font The new font to use. */ - public void setFont(Font font) { + public void setFont(final Font font) { Utils.checkNull(font, "font"); this.font = font; @@ -413,7 +416,7 @@ public class NumberRulerSkin extends Com * * @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)); } @@ -422,7 +425,7 @@ public class NumberRulerSkin extends Com * * @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)); } @@ -440,7 +443,7 @@ public class NumberRulerSkin extends Com * * @param color The foreground (that is, the text) color. */ - public void setColor(Color color) { + public void setColor(final Color color) { Utils.checkNull(color, "color"); this.color = color; @@ -453,11 +456,11 @@ public class NumberRulerSkin extends Com * @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 final void setColor(int color) { + public final void setColor(final int color) { Theme theme = currentTheme(); setColor(theme.getColor(color)); } @@ -476,7 +479,7 @@ public class NumberRulerSkin extends Com * * @param backgroundColor New background color value. */ - public void setBackgroundColor(Color backgroundColor) { + public void setBackgroundColor(final Color backgroundColor) { this.backgroundColor = backgroundColor; repaintComponent(); } @@ -485,14 +488,13 @@ public class NumberRulerSkin extends Com * Sets the background color of the ruler. * * @param backgroundColor Any of the - * {@linkplain GraphicsUtilities#decodeColor color values recognized by - * Pivot}. + * {@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")); } - public final void setBackgroundColor(int backgroundColor) { + public final void setBackgroundColor(final int backgroundColor) { Theme theme = currentTheme(); setBackgroundColor(theme.getColor(backgroundColor)); } Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java?rev=1838293&r1=1838292&r2=1838293&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java Fri Aug 17 22:27:05 2018 @@ -75,7 +75,7 @@ public class ScrollPaneSkin extends Cont } @Override - public void install(Component component) { + public void install(final Component component) { super.install(component); ScrollPane scrollPane = (ScrollPane) component; @@ -95,7 +95,7 @@ public class ScrollPaneSkin extends Cont } @Override - public int getPreferredWidth(int height) { + public int getPreferredWidth(final int height) { int preferredWidth = 0; ScrollPane scrollPane = (ScrollPane) getComponent(); @@ -182,7 +182,7 @@ public class ScrollPaneSkin extends Cont } @Override - public int getPreferredHeight(int width) { + public int getPreferredHeight(final int width) { int preferredHeight = 0; ScrollPane scrollPane = (ScrollPane) getComponent(); @@ -304,7 +304,7 @@ public class ScrollPaneSkin extends Cont } @Override - public int getBaseline(int width, int height) { + public int getBaseline(final int width, final int height) { ScrollPane scrollPane = (ScrollPane) getComponent(); Component view = scrollPane.getView(); @@ -350,8 +350,8 @@ public class ScrollPaneSkin extends Cont } @Override - public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, - int wheelRotation, int x, int y) { + public boolean mouseWheel(final Component component, final Mouse.ScrollType scrollType, final int scrollAmount, + final int wheelRotation, final int x, final int y) { boolean consumed = false; ScrollPane scrollPane = (ScrollPane) getComponent(); @@ -423,7 +423,7 @@ public class ScrollPaneSkin extends Cont * @see ScrollBar#getUnitIncrement() */ @Override - public boolean keyPressed(Component component, int keyCode, KeyLocation keyLocation) { + public boolean keyPressed(final Component component, final int keyCode, final KeyLocation keyLocation) { boolean consumed = super.keyPressed(component, keyCode, keyLocation); if (!consumed) { @@ -624,7 +624,7 @@ public class ScrollPaneSkin extends Cont * @param verticalPolicy The assumed vertical scroll policy; musn't be * <tt>FILL_TO_CAPACITY</tt> */ - private void layoutHelper(ScrollBarPolicy horizontalPolicy, ScrollBarPolicy verticalPolicy) { + private void layoutHelper(final ScrollBarPolicy horizontalPolicy, final ScrollBarPolicy verticalPolicy) { ScrollPane scrollPane = (ScrollPane) getComponent(); int width = getWidth(); @@ -824,7 +824,7 @@ public class ScrollPaneSkin extends Cont } @Override - public void setBackgroundPaint(Paint backgroundPaint) { + public void setBackgroundPaint(final Paint backgroundPaint) { super.setBackgroundPaint(backgroundPaint); optimizeScrolling = (backgroundPaint != null && backgroundPaint.getTransparency() == Transparency.OPAQUE); @@ -834,7 +834,7 @@ public class ScrollPaneSkin extends Cont return horizontalScrollBar.getUnitIncrement(); } - public void setHorizontalIncrement(int horizontalIncrement) { + public void setHorizontalIncrement(final int horizontalIncrement) { horizontalScrollBar.setUnitIncrement(horizontalIncrement); } @@ -842,7 +842,7 @@ public class ScrollPaneSkin extends Cont return verticalScrollBar.getUnitIncrement(); } - public void setVerticalIncrement(int verticalIncrement) { + public void setVerticalIncrement(final int verticalIncrement) { verticalScrollBar.setUnitIncrement(verticalIncrement); } @@ -850,7 +850,7 @@ public class ScrollPaneSkin extends Cont return horizontalReveal; } - public void setHorizontalReveal(int horizontalReveal) { + public void setHorizontalReveal(final int horizontalReveal) { this.horizontalReveal = horizontalReveal; } @@ -858,7 +858,7 @@ public class ScrollPaneSkin extends Cont return verticalReveal; } - public void setVerticalReveal(int verticalReveal) { + public void setVerticalReveal(final int verticalReveal) { this.verticalReveal = verticalReveal; } @@ -876,7 +876,8 @@ public class ScrollPaneSkin extends Cont ScrollPane scrollPane = (ScrollPane) getComponent(); ApplicationContext.DisplayHost displayHost = scrollPane.getDisplay().getDisplayHost(); - optimizeScrollingLocal = (displayHost.getScale() == 1 && (DesktopApplicationContext.isActive() && displayHost.isDisplayable())); + optimizeScrollingLocal = (displayHost.getScale() == 1 + && (DesktopApplicationContext.isActive() && displayHost.isDisplayable())); } return optimizeScrollingLocal; @@ -923,36 +924,36 @@ public class ScrollPaneSkin extends Cont // ScrollPaneListener methods @Override - public void horizontalScrollBarPolicyChanged(ScrollPane scrollPane, - ScrollBarPolicy previousHorizontalScrollBarPolicy) { + public void horizontalScrollBarPolicyChanged(final ScrollPane scrollPane, + final ScrollBarPolicy previousHorizontalScrollBarPolicy) { invalidateComponent(); } @Override - public void verticalScrollBarPolicyChanged(ScrollPane scrollPane, - ScrollBarPolicy previousVerticalScrollBarPolicy) { + public void verticalScrollBarPolicyChanged(final ScrollPane scrollPane, + final ScrollBarPolicy previousVerticalScrollBarPolicy) { invalidateComponent(); } @Override - public void rowHeaderChanged(ScrollPane scrollPane, Component previousRowHeader) { + public void rowHeaderChanged(final ScrollPane scrollPane, final Component previousRowHeader) { invalidateComponent(); } @Override - public void columnHeaderChanged(ScrollPane scrollPane, Component previousColumnHeader) { + public void columnHeaderChanged(final ScrollPane scrollPane, final Component previousColumnHeader) { invalidateComponent(); } @Override - public void cornerChanged(ScrollPane scrollPane, Component previousCorner) { + public void cornerChanged(final ScrollPane scrollPane, final Component previousCorner) { invalidateComponent(); } // ViewportListener methods @Override - public void scrollTopChanged(Viewport viewport, int previousScrollTop) { + public void scrollTopChanged(final Viewport viewport, final int previousScrollTop) { // NOTE we don't invalidate the component here because we need only // reposition the view and row header. Invalidating would yield // the correct positioning, but it would do much more work than needed. @@ -1029,7 +1030,7 @@ public class ScrollPaneSkin extends Cont } @Override - public void scrollLeftChanged(Viewport viewport, int previousScrollLeft) { + public void scrollLeftChanged(final Viewport viewport, final int previousScrollLeft) { // NOTE we don't invalidate the component here because we need only // reposition the view and column header. Invalidating would yield // the correct positioning, but it would do much more work than needed. @@ -1104,14 +1105,14 @@ public class ScrollPaneSkin extends Cont } @Override - public void viewChanged(Viewport viewport, Component previousView) { + public void viewChanged(final Viewport viewport, final Component previousView) { invalidateComponent(); } // ScrollBarValueListener methods @Override - public void valueChanged(ScrollBar scrollBar, int previousValue) { + public void valueChanged(final ScrollBar scrollBar, final int previousValue) { ScrollPane scrollPane = (ScrollPane) getComponent(); int value = scrollBar.getValue(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java?rev=1838293&r1=1838292&r2=1838293&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java Fri Aug 17 22:27:05 2018 @@ -85,22 +85,21 @@ public class TextPaneSkin extends Contai int selectionLength = textPane.getSelectionLength(); int selectionEnd = selectionStart + selectionLength - 1; + int offset; switch (scrollDirection) { - case UP: { + case UP: // Get previous offset - int offset = getNextInsertionPoint(mouseX, selectionStart, scrollDirection); + offset = getNextInsertionPoint(mouseX, selectionStart, scrollDirection); if (offset != -1) { textPane.setSelection(offset, selectionEnd - offset + 1); scrollCharacterToVisible(offset + 1); } - break; - } - case DOWN: { + case DOWN: // Get next offset - int offset = getNextInsertionPoint(mouseX, selectionEnd, scrollDirection); + offset = getNextInsertionPoint(mouseX, selectionEnd, scrollDirection); if (offset != -1) { // If the next character is a paragraph terminator and is not the @@ -114,13 +113,10 @@ public class TextPaneSkin extends Contai textPane.setSelection(selectionStart, offset - selectionStart); scrollCharacterToVisible(offset - 1); } - break; - } - default: { + default: throw new RuntimeException(); - } } } } @@ -129,7 +125,7 @@ public class TextPaneSkin extends Contai return (TextPane) getComponent(); } - private Rectangle getCaretRectangle(TextHitInfo textCaret) { + private Rectangle getCaretRectangle(final TextHitInfo textCaret) { TextPane textPane = getTextPane(); AttributedStringCharacterIterator composedText = textPane.getComposedText(); @@ -144,7 +140,8 @@ public class TextPaneSkin extends Contai // without the "doingCaretCalculations" flag to get back something non-null if (selectionStartBounds == null) { selectionStartBounds = getCharacterBounds(selectionStart); -org.apache.pivot.util.Console.getDefault().logMethod("****", "null selection bounds: selectionStart=%1$d, updated bounds=%2$s", selectionStart, selectionStartBounds); +org.apache.pivot.util.Console.getDefault().logMethod("****", + "null selection bounds: selectionStart=%1$d, updated bounds=%2$s", selectionStart, selectionStartBounds); } return GraphicsUtilities.getCaretRectangle(textCaret, composedText, @@ -158,7 +155,8 @@ org.apache.pivot.util.Console.getDefault private class TextInputMethodHandler implements TextInputMethodListener { @Override - public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, AttributedCharacterIterator.Attribute[] attributes) { + public AttributedCharacterIterator getCommittedText(final int beginIndex, final int endIndex, + final AttributedCharacterIterator.Attribute[] attributes) { return new AttributedStringCharacterIterator(getTextPane().getText(), beginIndex, endIndex, attributes); } @@ -173,12 +171,12 @@ org.apache.pivot.util.Console.getDefault } @Override - public TextHitInfo getLocationOffset(int x, int y) { + public TextHitInfo getLocationOffset(final int x, final int y) { return null; } @Override - public AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes) { + public AttributedCharacterIterator getSelectedText(final AttributedCharacterIterator.Attribute[] attributes) { String selectedText = getTextPane().getSelectedText(); if (selectedText != null && !selectedText.isEmpty()) { return new AttributedStringCharacterIterator(selectedText, attributes); @@ -186,12 +184,12 @@ org.apache.pivot.util.Console.getDefault return null; } - private Rectangle offsetToScreen(Rectangle clientRectangle) { + private Rectangle offsetToScreen(final Rectangle clientRectangle) { return getTextPane().offsetToScreen(clientRectangle); } @Override - public Rectangle getTextLocation(TextHitInfo offset) { + public Rectangle getTextLocation(final TextHitInfo offset) { AttributedStringCharacterIterator composedText = getTextPane().getComposedText(); if (composedText == null) { @@ -203,7 +201,7 @@ org.apache.pivot.util.Console.getDefault } } - private String getCommittedText(AttributedCharacterIterator fullTextIter, int count) { + private String getCommittedText(final AttributedCharacterIterator fullTextIter, final int count) { StringBuilder buf = new StringBuilder(count); buf.setLength(count); if (fullTextIter != null) { @@ -216,7 +214,8 @@ org.apache.pivot.util.Console.getDefault return buf.toString(); } - private AttributedStringCharacterIterator getComposedText(AttributedCharacterIterator fullTextIter, int start) { + private AttributedStringCharacterIterator getComposedText(final AttributedCharacterIterator fullTextIter, + final int start) { if (fullTextIter != null) { if (start < fullTextIter.getEndIndex()) { return new AttributedStringCharacterIterator(fullTextIter, start, fullTextIter.getEndIndex()); @@ -226,7 +225,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public void inputMethodTextChanged(InputMethodEvent event) { + public void inputMethodTextChanged(final InputMethodEvent event) { TextPane textPane = getTextPane(); AttributedCharacterIterator iter = event.getText(); AttributedStringCharacterIterator composedIter = null; @@ -258,7 +257,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public void caretPositionChanged(InputMethodEvent event) { + public void caretPositionChanged(final InputMethodEvent event) { // TODO: so far I have not seen this called, so ??? } @@ -325,7 +324,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public void install(Component component) { + public void install(final Component component) { super.install(component); TextPane textPane = (TextPane) component; @@ -348,7 +347,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public int getPreferredWidth(int height) { + public int getPreferredWidth(final int height) { int preferredWidth; if (documentView == null) { @@ -363,7 +362,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public int getPreferredHeight(int width) { + public int getPreferredHeight(final int width) { int preferredHeight; if (documentView == null || width == -1) { @@ -403,7 +402,7 @@ org.apache.pivot.util.Console.getDefault } @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); float ascent = lm.getAscent(); @@ -437,7 +436,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public void paint(Graphics2D graphics) { + public void paint(final Graphics2D graphics) { super.paint(graphics); TextPane textPane = getTextPane(); @@ -445,8 +444,8 @@ org.apache.pivot.util.Console.getDefault if (documentView != null) { // Draw the selection highlight if (selection != null) { - graphics.setColor(textPane.isFocused() && textPane.isEditable() ? selectionBackgroundColor - : inactiveSelectionBackgroundColor); + graphics.setColor(textPane.isFocused() && textPane.isEditable() + ? selectionBackgroundColor : inactiveSelectionBackgroundColor); graphics.fill(selection); } @@ -473,7 +472,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public int getInsertionPoint(int x, int y) { + public int getInsertionPoint(final int x, final int y) { int offset; if (documentView == null) { @@ -496,7 +495,7 @@ org.apache.pivot.util.Console.getDefault } @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; if (documentView == null) { @@ -509,7 +508,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public int getRowAt(int offset) { + public int getRowAt(final int offset) { int rowIndex; if (documentView == null) { @@ -535,7 +534,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public Bounds getCharacterBounds(int offset) { + public Bounds getCharacterBounds(final int offset) { Bounds characterBounds; if (documentView == null) { @@ -573,7 +572,7 @@ org.apache.pivot.util.Console.getDefault * <tt>false</tt> (default) means <tt>TAB</tt> shifts focus and * <tt>Ctrl-TAB</tt> inserts spaces. */ - public void setAcceptsTab(boolean acceptsTab) { + public void setAcceptsTab(final boolean acceptsTab) { this.acceptsTab = acceptsTab; } @@ -582,13 +581,13 @@ org.apache.pivot.util.Console.getDefault return tabWidth; } - public void setTabWidth(int tabWidth) { + public void setTabWidth(final int tabWidth) { Utils.checkNonNegative(tabWidth, "tabWidth"); this.tabWidth = tabWidth; } - private void scrollCharacterToVisible(int offset) { + private void scrollCharacterToVisible(final int offset) { Bounds characterBounds = getCharacterBounds(offset); if (characterBounds != null) { @@ -609,7 +608,7 @@ org.apache.pivot.util.Console.getDefault * * @param font The new font for all the text. */ - public void setFont(Font font) { + public void setFont(final Font font) { Utils.checkNull(font, "font"); this.font = font; @@ -621,7 +620,7 @@ org.apache.pivot.util.Console.getDefault * * @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)); } @@ -630,7 +629,7 @@ org.apache.pivot.util.Console.getDefault * * @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)); } @@ -646,7 +645,7 @@ org.apache.pivot.util.Console.getDefault * * @param color The new text color. */ - public void setColor(Color color) { + public void setColor(final Color color) { Utils.checkNull(color, "color"); this.color = color; @@ -659,7 +658,7 @@ org.apache.pivot.util.Console.getDefault * @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")); } @@ -667,14 +666,14 @@ org.apache.pivot.util.Console.getDefault return inactiveColor; } - public void setInactiveColor(Color inactiveColor) { + public 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")); } @@ -682,14 +681,14 @@ org.apache.pivot.util.Console.getDefault return selectionColor; } - public void setSelectionColor(Color selectionColor) { + public 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")); } @@ -697,14 +696,14 @@ org.apache.pivot.util.Console.getDefault return selectionBackgroundColor; } - public void setSelectionBackgroundColor(Color selectionBackgroundColor) { + public 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")); } @@ -713,14 +712,14 @@ org.apache.pivot.util.Console.getDefault return inactiveSelectionColor; } - public void setInactiveSelectionColor(Color inactiveSelectionColor) { + public 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")); } @@ -729,14 +728,14 @@ org.apache.pivot.util.Console.getDefault return inactiveSelectionBackgroundColor; } - public void setInactiveSelectionBackgroundColor(Color inactiveSelectionBackgroundColor) { + public 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")); } @@ -753,7 +752,7 @@ org.apache.pivot.util.Console.getDefault * * @param margin The new set of margin values. */ - public void setMargin(Insets margin) { + public void setMargin(final Insets margin) { Utils.checkNull(margin, "margin"); this.margin = margin; @@ -765,7 +764,7 @@ org.apache.pivot.util.Console.getDefault * * @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)); } @@ -774,7 +773,7 @@ org.apache.pivot.util.Console.getDefault * * @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)); } @@ -783,7 +782,7 @@ org.apache.pivot.util.Console.getDefault * * @param margin The single margin value for all edges. */ - public final void setMargin(int margin) { + public final void setMargin(final int margin) { setMargin(new Insets(margin)); } @@ -792,7 +791,7 @@ org.apache.pivot.util.Console.getDefault * * @param margin The new single margin value for all the edges. */ - public final void setMargin(Number margin) { + public final void setMargin(final Number margin) { setMargin(new Insets(margin)); } @@ -802,7 +801,7 @@ org.apache.pivot.util.Console.getDefault * @param margin A string containing an integer or a JSON dictionary with * keys left, top, bottom, and/or right. */ - public final void setMargin(String margin) { + public final void setMargin(final String margin) { setMargin(Insets.decode(margin)); } @@ -810,7 +809,7 @@ org.apache.pivot.util.Console.getDefault return wrapText; } - public void setWrapText(boolean wrapText) { + public void setWrapText(final boolean wrapText) { if (this.wrapText != wrapText) { this.wrapText = wrapText; @@ -821,7 +820,7 @@ org.apache.pivot.util.Console.getDefault } @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) { @@ -871,7 +870,7 @@ org.apache.pivot.util.Console.getDefault } @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); if (button == Mouse.Button.LEFT) { @@ -906,7 +905,7 @@ org.apache.pivot.util.Console.getDefault } @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) { @@ -927,7 +926,8 @@ org.apache.pivot.util.Console.getDefault } @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); TextPane textPane = (TextPane) component; @@ -951,7 +951,7 @@ org.apache.pivot.util.Console.getDefault } @Override - public boolean keyTyped(final Component component, char character) { + public boolean keyTyped(final Component component, final char character) { boolean consumed = super.keyTyped(component, character); final TextPane textPane = getTextPane(); @@ -973,7 +973,7 @@ org.apache.pivot.util.Console.getDefault return consumed; } - private Node getParagraphAt(Document document, int index) { + private Node getParagraphAt(final Document document, final int index) { if (document != null) { Node node = document.getDescendantAt(index); while (node != null && !(node instanceof Paragraph)) { @@ -984,7 +984,7 @@ org.apache.pivot.util.Console.getDefault return null; } - private int getRowOffset(Document document, int index) { + private int getRowOffset(final Document document, final int index) { Node node = getParagraphAt(document, index); // TODO: doesn't take into account the line wrapping within a paragraph if (node != null) { @@ -993,7 +993,7 @@ org.apache.pivot.util.Console.getDefault return 0; } - private int getRowLength(Document document, int index) { + private int getRowLength(final Document document, final int index) { Node node = getParagraphAt(document, index); // TODO: doesn't take into account the line wrapping within a paragraph // Assuming the node is a Paragraph, the count includes the trailing \n, so discount it @@ -1003,7 +1003,7 @@ org.apache.pivot.util.Console.getDefault return 0; } - private CharSequence getRowCharacters(Document document, int index) { + private CharSequence getRowCharacters(final Document document, final int index) { Node node = getParagraphAt(document, index); // TODO: doesn't take into account the line wrapping within a paragraph if (node != null) { @@ -1013,8 +1013,8 @@ org.apache.pivot.util.Console.getDefault } @Override - public boolean keyPressed(final Component component, int keyCode, - Keyboard.KeyLocation keyLocation) { + public boolean keyPressed(final Component component, final int keyCode, + final Keyboard.KeyLocation keyLocation) { boolean consumed = false; final TextPane textPane = getTextPane(); @@ -1314,14 +1314,14 @@ org.apache.pivot.util.Console.getDefault // Component state events @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); TextPane textPane = getTextPane(); @@ -1337,7 +1337,7 @@ org.apache.pivot.util.Console.getDefault // Text pane events @Override - public void documentChanged(TextPane textPane, Document previousDocument) { + public void documentChanged(final TextPane textPane, final Document previousDocument) { if (documentView != null) { documentView.detach(); documentView = null; @@ -1353,14 +1353,14 @@ org.apache.pivot.util.Console.getDefault } @Override - public void editableChanged(TextPane textPane) { + public void editableChanged(final TextPane textPane) { // No-op } // Text pane selection events @Override - public void selectionChanged(TextPane textPane, int previousSelectionStart, - int previousSelectionLength) { + public void selectionChanged(final TextPane textPane, final int previousSelectionStart, + final int previousSelectionLength) { // If the document view is valid, repaint the selection state; // otherwise, the selection will be updated in layout() if (documentView != null && documentView.isValid()) { @@ -1452,7 +1452,7 @@ org.apache.pivot.util.Console.getDefault } } - private void showCaret(boolean show) { + private void showCaret(final boolean show) { if (scheduledBlinkCaretCallback != null) { scheduledBlinkCaretCallback.cancel(); }