Author: rwhitcomb Date: Mon Oct 30 16:54:16 2023 New Revision: 1913446 URL: http://svn.apache.org/viewvc?rev=1913446&view=rev Log: PIVOT-1032: Small style changes in a few more places.
Modified: pivot/trunk/core/src/org/apache/pivot/util/CharUtils.java pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java pivot/trunk/wtk/src/org/apache/pivot/wtk/DropAction.java pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java Modified: pivot/trunk/core/src/org/apache/pivot/util/CharUtils.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/CharUtils.java?rev=1913446&r1=1913445&r2=1913446&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/util/CharUtils.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/CharUtils.java Mon Oct 30 16:54:16 2023 @@ -29,6 +29,14 @@ public final class CharUtils { } /** + * @return Whether the given character is one of the line-ending chars. + * @param ch The character to check. + */ + private static boolean isLineEnding(final char ch) { + return (ch == '\r' || ch == '\n'); + } + + /** * Return a {@link CharSpan} describing a "word" which contains the given * starting location in the character sequence. * <p> "Words" are defined as sequences of "Unicode Identifier Part" characters @@ -48,7 +56,6 @@ public final class CharUtils { } int adjustedStart = start; - char ch; // Adjust the start position to put it within the sequence length // and skip any trailing line endings at that point @@ -57,7 +64,7 @@ public final class CharUtils { if (adjustedStart < 0) { return null; } - while ((ch = sequence.charAt(adjustedStart)) == '\r' || ch == '\n') { + while (isLineEnding(sequence.charAt(adjustedStart))) { adjustedStart--; } } @@ -67,7 +74,7 @@ public final class CharUtils { int selectionStart = adjustedStart; int selectionLength = 1; - ch = sequence.charAt(selectionStart); + char ch = sequence.charAt(selectionStart); if (Character.isWhitespace(ch)) { // Move backward to beginning of whitespace block // but not before the beginning of the text. Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java?rev=1913446&r1=1913445&r2=1913446&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java Mon Oct 30 16:54:16 2023 @@ -25,17 +25,31 @@ import org.apache.pivot.wtk.skin.Display * Container that serves as the root of a component hierarchy. */ public final class Display extends Container { + /** + * The display host (bridge to AWT) that really implements this display. + */ private ApplicationContext.DisplayHost displayHost; - public Display(ApplicationContext.DisplayHost displayHost) { - this.displayHost = displayHost; + /** + * Construct a display on the given {@link ApplicationContext.DisplayHost}. + * + * @param host The display host that implements this display. + */ + public Display(final ApplicationContext.DisplayHost host) { + displayHost = host; super.setSkin(new DisplaySkin()); } + /** + * @return The display host attached to this display. + */ public ApplicationContext.DisplayHost getDisplayHost() { return displayHost; } + /** + * @return The AWT host window of this display. + */ public java.awt.Window getHostWindow() { java.awt.Container parent = displayHost.getParent(); while (parent != null && !(parent instanceof java.awt.Window)) { @@ -51,41 +65,41 @@ public final class Display extends Conta @Override @UnsupportedOperation - protected void setSkin(Skin skin) { + protected void setSkin(final Skin skin) { throw new UnsupportedOperationException("Can't replace Display skin."); } @Override @UnsupportedOperation - protected void setParent(Container parent) { + protected void setParent(final Container parent) { throw new UnsupportedOperationException("Display can't have a parent."); } @Override @UnsupportedOperation - public void setLocation(int x, int y) { + public void setLocation(final int x, final int y) { throw new UnsupportedOperationException("Can't change the location of the display."); } @Override @UnsupportedOperation - public void setVisible(boolean visible) { + public void setVisible(final boolean visible) { throw new UnsupportedOperationException("Can't change the visibility of the display."); } @Override @UnsupportedOperation - public void setTooltipText(String tooltipText) { + public void setTooltipText(final String tooltipText) { throw new UnsupportedOperationException("Can't set a tooltip on the display."); } @Override - public void repaint(int x, int y, int width, int height, boolean immediate) { + public void repaint(final int x, final int y, final int width, final int height, final boolean immediate) { if (immediate) { Graphics2D graphics = (Graphics2D) displayHost.getGraphics(); - // If the display host has been made non-displayable (as will - // happen when the native peer closes), graphics will be null + // If the display host has been made non-displayable (as will happen when the native peer closes), + // graphics will be null if (graphics != null) { double scale = displayHost.getScale(); if (scale == 1) { @@ -104,9 +118,9 @@ public final class Display extends Conta } @Override - public void insert(Component component, int index) { + public void insert(final Component component, final int index) { if (!(component instanceof Window)) { - throw new IllegalArgumentException("component must be an instance " + "of " + throw new IllegalArgumentException("component must be an instance of " + Window.class); } @@ -114,7 +128,7 @@ public final class Display extends Conta } @Override - protected void descendantAdded(Component descendant) { + protected void descendantAdded(final Component descendant) { super.descendantAdded(descendant); String automationID = descendant.getAutomationID(); @@ -125,7 +139,7 @@ public final class Display extends Conta } @Override - protected void descendantRemoved(Component descendant) { + protected void descendantRemoved(final Component descendant) { super.descendantRemoved(descendant); String automationID = descendant.getAutomationID(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/DropAction.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/DropAction.java?rev=1913446&r1=1913445&r2=1913446&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/DropAction.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/DropAction.java Mon Oct 30 16:54:16 2023 @@ -17,8 +17,12 @@ package org.apache.pivot.wtk; import java.awt.Cursor; -import static java.awt.dnd.DnDConstants.*; -import static java.awt.dnd.DragSource.*; +import static java.awt.dnd.DnDConstants.ACTION_COPY; +import static java.awt.dnd.DnDConstants.ACTION_LINK; +import static java.awt.dnd.DnDConstants.ACTION_MOVE; +import static java.awt.dnd.DragSource.DefaultCopyDrop; +import static java.awt.dnd.DragSource.DefaultLinkDrop; +import static java.awt.dnd.DragSource.DefaultMoveDrop; import java.awt.event.InputEvent; Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java?rev=1913446&r1=1913445&r2=1913446&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/FontUtilities.java Mon Oct 30 16:54:16 2023 @@ -367,8 +367,7 @@ public final class FontUtilities { * @throws FontFormatException if the font file itself was malformed. */ public static Font registerFont(final File fullFontFilePath) - throws IOException, FontFormatException - { + throws IOException, FontFormatException { try { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font f = Font.createFont(Font.TRUETYPE_FONT, fullFontFilePath); @@ -392,8 +391,7 @@ public final class FontUtilities { * @throws FontFormatException if the font file itself was malformed. */ public static Font registerFont(final InputStream fontInputStream) - throws IOException, FontFormatException - { + throws IOException, FontFormatException { try { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font f = Font.createFont(Font.TRUETYPE_FONT, fontInputStream);