Author: rwhitcomb Date: Thu May 31 18:25:47 2018 New Revision: 1832639 URL: http://svn.apache.org/viewvc?rev=1832639&view=rev Log: PIVOT-1032: Fix more "check-style" issues.
Modified: pivot/trunk/core/src/org/apache/pivot/json/JSON.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/RulerSkin.java Modified: pivot/trunk/core/src/org/apache/pivot/json/JSON.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/json/JSON.java?rev=1832639&r1=1832638&r2=1832639&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/json/JSON.java (original) +++ pivot/trunk/core/src/org/apache/pivot/json/JSON.java Thu May 31 18:25:47 2018 @@ -35,7 +35,10 @@ import org.apache.pivot.util.Utils; * consideration is given to an object that implements the {@link Dictionary} * interface. */ -public class JSON { +public final class JSON { + private JSON() { + } + /** * Returns the value at a given path. * @@ -71,8 +74,8 @@ public class JSON { String key = keys.get(i); - Map<String, T> adapter = (Map<String, T>) (value instanceof java.util.Map ? - new MapAdapter<>((java.util.Map<String, T>) value) + Map<String, T> adapter = (Map<String, T>) (value instanceof java.util.Map + ? new MapAdapter<>((java.util.Map<String, T>) value) : (value instanceof Map ? ((Map<String, T>) value) : new BeanAdapter(value))); if (adapter.containsKey(key)) { @@ -145,8 +148,8 @@ public class JSON { throw new IllegalArgumentException("Invalid path."); } - Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map ? - new MapAdapter<>((java.util.Map<String, T>) parent) + Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map + ? new MapAdapter<>((java.util.Map<String, T>) parent) : (parent instanceof Map ? ((Map<String, T>) parent) : new BeanAdapter(parent))); @@ -227,8 +230,8 @@ public class JSON { if (parent == null) { containsKey = false; } else { - Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map ? - new MapAdapter<>((java.util.Map<String, T>) parent) + Map<String, T> adapter = (Map<String, T>) (parent instanceof java.util.Map + ? new MapAdapter<>((java.util.Map<String, T>) parent) : (parent instanceof Map ? ((Map<String, T>) parent) : new BeanAdapter(parent))); containsKey = adapter.containsKey(key); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java?rev=1832639&r1=1832638&r2=1832639&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java Thu May 31 18:25:47 2018 @@ -27,7 +27,7 @@ import org.apache.pivot.wtk.Insets; import org.apache.pivot.wtk.Orientation; /** - * Fill pane skin. + * Theme-independent skin for the {@link FillPane} component. */ public class FillPaneSkin extends ContainerSkin implements FillPaneListener { private Insets padding = Insets.NONE; @@ -55,8 +55,7 @@ public class FillPaneSkin extends Contai heightUpdated = Math.max(heightUpdated - padding.getHeight(), 0); } - // Preferred width is the sum of the preferred widths of all - // components + // Preferred width is the sum of the preferred widths of all components int j = 0; for (int i = 0, n = fillPane.getLength(); i < n; i++) { Component component = fillPane.get(i); @@ -96,8 +95,7 @@ public class FillPaneSkin extends Contai Orientation orientation = fillPane.getOrientation(); if (orientation == Orientation.HORIZONTAL) { - // Preferred height is the maximum preferred height of all - // components + // Preferred height is the maximum preferred height of all components for (int i = 0, n = fillPane.getLength(); i < n; i++) { Component component = fillPane.get(i); @@ -112,8 +110,7 @@ public class FillPaneSkin extends Contai widthUpdated = Math.max(widthUpdated - padding.getWidth(), 0); } - // Preferred height is the sum of the preferred heights of all - // components + // Preferred height is the sum of the preferred heights of all components int j = 0; for (int i = 0, n = fillPane.getLength(); i < n; i++) { Component component = fillPane.get(i); @@ -142,12 +139,11 @@ public class FillPaneSkin extends Contai int preferredWidth = 0; int preferredHeight = 0; + int j = 0; switch (fillPane.getOrientation()) { - case HORIZONTAL: { - // Preferred width is the sum of the preferred widths of all - // components - int j = 0; + case HORIZONTAL: + // Preferred width is the sum of the preferred widths of all components for (int i = 0, n = fillPane.getLength(); i < n; i++) { Component component = fillPane.get(i); @@ -163,14 +159,10 @@ public class FillPaneSkin extends Contai if (j > 1) { preferredWidth += spacing * (j - 1); } - break; - } - case VERTICAL: { - // Preferred height is the sum of the preferred heights of all - // components - int j = 0; + case VERTICAL: + // Preferred height is the sum of the preferred heights of all components for (int i = 0, n = fillPane.getLength(); i < n; i++) { Component component = fillPane.get(i); @@ -186,13 +178,10 @@ public class FillPaneSkin extends Contai if (j > 1) { preferredHeight += spacing * (j - 1); } - break; - } - default: { + default: break; - } } // Include padding @@ -210,7 +199,7 @@ public class FillPaneSkin extends Contai int contentHeight = 0; switch (fillPane.getOrientation()) { - case HORIZONTAL: { + case HORIZONTAL: int clientHeight = Math.max(height - padding.getHeight(), 0); for (Component component : fillPane) { @@ -220,11 +209,9 @@ public class FillPaneSkin extends Contai component.getBaseline(componentWidth, clientHeight)); } } - break; - } - case VERTICAL: { + case VERTICAL: int clientWidth = Math.max(width - padding.getWidth(), 0); for (Component component : fillPane) { @@ -243,13 +230,10 @@ public class FillPaneSkin extends Contai contentHeight += size.height + spacing; } } - break; - } - default: { + default: break; - } } if (baseline != -1) { @@ -355,7 +339,7 @@ public class FillPaneSkin extends Contai * @return The amount of space between the edge of the FillPane and its * components. */ - public Insets getPadding() { + public final Insets getPadding() { return padding; } @@ -365,7 +349,7 @@ public class FillPaneSkin extends Contai * * @param padding The new values for padding. */ - public void setPadding(Insets padding) { + public final void setPadding(Insets padding) { Utils.checkNull(padding, "padding"); this.padding = padding; @@ -423,11 +407,11 @@ public class FillPaneSkin extends Contai setPadding(Insets.decode(padding)); } - public int getSpacing() { + public final int getSpacing() { return spacing; } - public void setSpacing(int spacing) { + public final void setSpacing(int spacing) { Utils.checkNonNegative(spacing, "spacing"); this.spacing = spacing; Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java?rev=1832639&r1=1832638&r2=1832639&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/GridPaneSkin.java Thu May 31 18:25:47 2018 @@ -32,7 +32,7 @@ import org.apache.pivot.wtk.Insets; import org.apache.pivot.wtk.Orientation; /** - * Grid pane skin. + * Theme-independent skin for the {@link GridPane} component. */ public class GridPaneSkin extends ContainerSkin implements GridPane.Skin, GridPaneListener { /** @@ -57,8 +57,8 @@ public class GridPaneSkin extends Contai visibleRows = new boolean[rowCount]; visibleColumns = new boolean[columnCount]; - int visibleRowCountLocal = 0; - int visibleColumnCountLocal = 0; + int visibleRowCountCalc = 0; + int visibleColumnCountCalc = 0; for (int i = 0; i < rowCount; i++) { GridPane.Row row = rows.get(i); @@ -68,20 +68,20 @@ public class GridPaneSkin extends Contai if (component != null && component.isVisible()) { if (!visibleRows[i]) { - visibleRowCountLocal++; + visibleRowCountCalc++; visibleRows[i] = true; } if (!visibleColumns[j]) { - visibleColumnCountLocal++; + visibleColumnCountCalc++; visibleColumns[j] = true; } } } } - this.visibleRowCount = visibleRowCountLocal; - this.visibleColumnCount = visibleColumnCountLocal; + this.visibleRowCount = visibleRowCountCalc; + this.visibleColumnCount = visibleColumnCountCalc; } public boolean isRowVisible(int rowIndex) { @@ -108,6 +108,9 @@ public class GridPaneSkin extends Contai private int cellHeight = 0; + /** + * Default constructor. + */ public GridPaneSkin() { horizontalGridColor = defaultForegroundColor(); verticalGridColor = defaultForegroundColor(); @@ -132,7 +135,7 @@ public class GridPaneSkin extends Contai Metadata metadata = new Metadata(); - int cellHeightLocal = getCellHeight(height, metadata); + int cellHeightValue = getCellHeight(height, metadata); int preferredCellWidth = 0; for (int i = 0; i < rowCount; i++) { @@ -143,7 +146,7 @@ public class GridPaneSkin extends Contai if (component != null && component.isVisible()) { preferredCellWidth = Math.max(preferredCellWidth, - component.getPreferredWidth(cellHeightLocal)); + component.getPreferredWidth(cellHeightValue)); } } } @@ -151,8 +154,8 @@ public class GridPaneSkin extends Contai // The preferred width of the grid pane is the sum of the column // widths, plus padding and spacing - int preferredWidth = (metadata.visibleColumnCount * preferredCellWidth) + - padding.getWidth(); + int preferredWidth = (metadata.visibleColumnCount * preferredCellWidth) + + padding.getWidth(); if (metadata.visibleColumnCount > 1) { preferredWidth += (metadata.visibleColumnCount - 1) * horizontalSpacing; @@ -172,7 +175,7 @@ public class GridPaneSkin extends Contai Metadata metadata = new Metadata(); - int cellWidthLocal = getCellWidth(width, metadata); + int cellWidthValue = getCellWidth(width, metadata); int preferredCellHeight = 0; for (int i = 0; i < rowCount; i++) { @@ -183,7 +186,7 @@ public class GridPaneSkin extends Contai if (component != null && component.isVisible()) { preferredCellHeight = Math.max(preferredCellHeight, - component.getPreferredHeight(cellWidthLocal)); + component.getPreferredHeight(cellWidthValue)); } } } @@ -191,8 +194,8 @@ public class GridPaneSkin extends Contai // The preferred height of the grid pane is the sum of the row // heights, plus padding and spacing - int preferredHeight = (metadata.visibleRowCount * preferredCellHeight) + - padding.getHeight(); + int preferredHeight = (metadata.visibleRowCount * preferredCellHeight) + + padding.getHeight(); if (metadata.visibleRowCount > 1) { preferredHeight += (metadata.visibleRowCount - 1) * verticalSpacing; @@ -232,8 +235,8 @@ public class GridPaneSkin extends Contai // The preferred width of the grid pane is the sum of the column // widths, plus padding and spacing - int preferredWidth = (metadata.visibleColumnCount * preferredCellWidth) + - padding.getWidth(); + int preferredWidth = (metadata.visibleColumnCount * preferredCellWidth) + + padding.getWidth(); if (metadata.visibleColumnCount > 1) { preferredWidth += (metadata.visibleColumnCount - 1) * horizontalSpacing; @@ -242,8 +245,8 @@ public class GridPaneSkin extends Contai // The preferred height of the grid pane is the sum of the row // heights, plus padding and spacing - int preferredHeight = (metadata.visibleRowCount * preferredCellHeight) + - padding.getHeight(); + int preferredHeight = (metadata.visibleRowCount * preferredCellHeight) + + padding.getHeight(); if (metadata.visibleRowCount > 1) { preferredHeight += (metadata.visibleRowCount - 1) * verticalSpacing; @@ -263,11 +266,10 @@ public class GridPaneSkin extends Contai Metadata metadata = new Metadata(); - int cellWidthLocal = getCellWidth(width, metadata); - int cellHeightLocal = getCellHeight(height, metadata); + int cellWidthValue = getCellWidth(width, metadata); + int cellHeightValue = getCellHeight(height, metadata); - // Return the first available baseline by traversing cells top left to - // bottom right + // Return the first available baseline by traversing cells top left to bottom right int baseline = -1; @@ -281,7 +283,7 @@ public class GridPaneSkin extends Contai Component component = row.get(j); if (component != null && component.isVisible()) { - baseline = component.getBaseline(cellWidthLocal, cellHeightLocal); + baseline = component.getBaseline(cellWidthValue, cellHeightValue); if (baseline != -1) { baseline += rowY; @@ -289,7 +291,7 @@ public class GridPaneSkin extends Contai } } - rowY += (cellHeightLocal + verticalSpacing); + rowY += (cellHeightValue + verticalSpacing); } } @@ -385,10 +387,13 @@ public class GridPaneSkin extends Contai } /** - * Gets the cell width given the specified grid pane width and metadata. + * @return The cell width given the specified grid pane width and metadata. + * + * @param width The overall grid pane width (can be -1). + * @param metadata Information about visible rows and columns. */ private int getCellWidth(int width, Metadata metadata) { - int cellWidthLocal = -1; + int cellWidthCalc = -1; if (width != -1) { int clientWidth = width - padding.getWidth(); @@ -399,18 +404,21 @@ public class GridPaneSkin extends Contai clientWidth = Math.max(0, clientWidth); - cellWidthLocal = (metadata.visibleColumnCount == 0) ? 0 : clientWidth + cellWidthCalc = (metadata.visibleColumnCount == 0) ? 0 : clientWidth / metadata.visibleColumnCount; } - return cellWidthLocal; + return cellWidthCalc; } /** - * Gets the cell height given the specified grid pane height and metadata. + * @return The cell height given the specified grid pane height and metadata. + * + * @param height The overall height of the grid pane (can be -1). + * @param metadata Information about visible rows and columns. */ private int getCellHeight(int height, Metadata metadata) { - int cellHeightLocal = -1; + int cellHeightCalc = -1; if (height != -1) { int clientHeight = height - padding.getHeight(); @@ -421,28 +429,26 @@ public class GridPaneSkin extends Contai clientHeight = Math.max(0, clientHeight); - cellHeightLocal = (metadata.visibleRowCount == 0) ? 0 : clientHeight + cellHeightCalc = (metadata.visibleRowCount == 0) ? 0 : clientHeight / metadata.visibleRowCount; } - return cellHeightLocal; + return cellHeightCalc; } /** - * @return The padding that will be reserved around the grid pane during - * layout. + * @return The padding that will be reserved around the grid pane during layout. */ - public Insets getPadding() { + public final Insets getPadding() { return padding; } /** - * Sets the padding that will be reserved around the grid pane during - * layout. + * Sets the padding that will be reserved around the grid pane during layout. * * @param padding The individual padding values for each side. */ - public void setPadding(Insets padding) { + public final void setPadding(Insets padding) { Utils.checkNull(padding, "padding"); this.padding = padding; @@ -450,8 +456,7 @@ public class GridPaneSkin extends Contai } /** - * Sets the padding that will be reserved around the grid pane during - * layout. + * Sets the padding that will be reserved around the grid pane during layout. * * @param padding The single value to use for all sides. */ @@ -460,8 +465,7 @@ public class GridPaneSkin extends Contai } /** - * Sets the padding that will be reserved around the grid pane during - * layout. + * Sets the padding that will be reserved around the grid pane during layout. * * @param padding The dictionary of padding values, containing {@code "top"}, * {@code "bottom"}, {@code "left}, and {@code "right"} entries. @@ -471,8 +475,7 @@ public class GridPaneSkin extends Contai } /** - * Sets the padding that will be reserved around the grid pane during - * layout. + * Sets the padding that will be reserved around the grid pane during layout. * * @param padding A sequence with values in the order {top, left, bottom, right}. */ @@ -481,8 +484,7 @@ public class GridPaneSkin extends Contai } /** - * Sets the padding that will be reserved around the grid pane during - * layout. + * Sets the padding that will be reserved around the grid pane during layout. * * @param padding The single value to use for all sides. */ @@ -491,8 +493,7 @@ public class GridPaneSkin extends Contai } /** - * Sets the padding that will be reserved around the grid pane during - * layout. + * Sets the padding that will be reserved around the grid pane during layout. * * @param padding A JSON-format string containing the padding values. */ @@ -504,7 +505,7 @@ public class GridPaneSkin extends Contai * @return The spacing that will be applied in between the grid pane's columns * during layout. */ - public int getHorizontalSpacing() { + public final int getHorizontalSpacing() { return horizontalSpacing; } @@ -514,7 +515,7 @@ public class GridPaneSkin extends Contai * * @param horizontalSpacing The non-negative spacing value between columns. */ - public void setHorizontalSpacing(int horizontalSpacing) { + public final void setHorizontalSpacing(int horizontalSpacing) { Utils.checkNonNegative(horizontalSpacing, "horizontalSpacing"); this.horizontalSpacing = horizontalSpacing; @@ -525,7 +526,7 @@ public class GridPaneSkin extends Contai * @return The spacing that will be applied in between the grid pane's rows * during layout. */ - public int getVerticalSpacing() { + public final int getVerticalSpacing() { return verticalSpacing; } @@ -535,7 +536,7 @@ public class GridPaneSkin extends Contai * * @param verticalSpacing The non-negative spacing value between rows. */ - public void setVerticalSpacing(int verticalSpacing) { + public final void setVerticalSpacing(int verticalSpacing) { Utils.checkNonNegative(verticalSpacing, "verticalSpacing"); this.verticalSpacing = verticalSpacing; @@ -546,7 +547,7 @@ public class GridPaneSkin extends Contai * @return Whether or not horizontal grid lines will be painted in between the * grid pane's rows. */ - public boolean getShowHorizontalGridLines() { + public final boolean getShowHorizontalGridLines() { return showHorizontalGridLines; } @@ -556,7 +557,7 @@ public class GridPaneSkin extends Contai * * @param showHorizontalGridLines Whether to show horizontal grid lines. */ - public void setShowHorizontalGridLines(boolean showHorizontalGridLines) { + public final void setShowHorizontalGridLines(boolean showHorizontalGridLines) { this.showHorizontalGridLines = showHorizontalGridLines; repaintComponent(); } @@ -565,7 +566,7 @@ public class GridPaneSkin extends Contai * @return Whether or not vertical grid lines will be painted in between the * grid pane's columns. */ - public boolean getShowVerticalGridLines() { + public final boolean getShowVerticalGridLines() { return showVerticalGridLines; } @@ -575,7 +576,7 @@ public class GridPaneSkin extends Contai * * @param showVerticalGridLines Whether to show the vertical grid lines. */ - public void setShowVerticalGridLines(boolean showVerticalGridLines) { + public final void setShowVerticalGridLines(boolean showVerticalGridLines) { this.showVerticalGridLines = showVerticalGridLines; repaintComponent(); } @@ -583,7 +584,7 @@ public class GridPaneSkin extends Contai /** * @return The color used to paint the grid pane's horizontal grid lines. */ - public Color getHorizontalGridColor() { + public final Color getHorizontalGridColor() { return horizontalGridColor; } @@ -592,7 +593,7 @@ public class GridPaneSkin extends Contai * * @param horizontalGridColor The new color for the horizontal grid lines. */ - public void setHorizontalGridColor(Color horizontalGridColor) { + public final void setHorizontalGridColor(Color horizontalGridColor) { Utils.checkNull(horizontalGridColor, "horizontalGridColor"); this.horizontalGridColor = horizontalGridColor; @@ -616,7 +617,7 @@ public class GridPaneSkin extends Contai /** * @return The color used to paint the grid pane's vertical grid lines. */ - public Color getVerticalGridColor() { + public final Color getVerticalGridColor() { return verticalGridColor; } @@ -625,7 +626,7 @@ public class GridPaneSkin extends Contai * * @param verticalGridColor The new color for vertical grid lines. */ - public void setVerticalGridColor(Color verticalGridColor) { + public final void setVerticalGridColor(Color verticalGridColor) { Utils.checkNull(verticalGridColor, "verticalGridColor"); this.verticalGridColor = verticalGridColor; Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/RulerSkin.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/RulerSkin.java?rev=1832639&r1=1832638&r2=1832639&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/RulerSkin.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/RulerSkin.java Thu May 31 18:25:47 2018 @@ -68,7 +68,8 @@ public class RulerSkin extends Component borders = Borders.ALL; majorDivision = 4; minorDivision = 2; - showMajorNumbers = showMinorNumbers = false; + showMajorNumbers = false; + showMinorNumbers = false; Theme theme = currentTheme(); setFont(theme.getFont()); @@ -93,9 +94,9 @@ public class RulerSkin extends Component Orientation orientation = ruler.getOrientation(); // Give a little extra height if showing numbers - return (orientation == Orientation.HORIZONTAL) ? - ((showMajorNumbers || showMinorNumbers) ? - ((int)Math.ceil(charHeight) + MAJOR_SIZE + 5) : MAJOR_SIZE * 2) : 0; + return (orientation == Orientation.HORIZONTAL) + ? ((showMajorNumbers || showMinorNumbers) + ? ((int) Math.ceil(charHeight) + MAJOR_SIZE + 5) : MAJOR_SIZE * 2) : 0; } @Override @@ -104,12 +105,13 @@ public class RulerSkin extends Component Orientation orientation = ruler.getOrientation(); // Give a little extra width if showing numbers - return (orientation == Orientation.VERTICAL) ? - ((showMajorNumbers || showMinorNumbers) ? - ((int)Math.ceil(charWidth) + MAJOR_SIZE + 5) : MAJOR_SIZE * 2) : 0; + return (orientation == Orientation.VERTICAL) + ? ((showMajorNumbers || showMinorNumbers) + ? ((int) Math.ceil(charWidth) + MAJOR_SIZE + 5) : MAJOR_SIZE * 2) : 0; } - private void showNumber(Graphics2D graphics, FontRenderContext fontRenderContext, int number, int x, int y) { + private void showNumber(Graphics2D graphics, FontRenderContext fontRenderContext, int number, + int x, int y) { String num = Integer.toString(number); StringCharacterIterator line; @@ -129,20 +131,20 @@ public class RulerSkin extends Component textBounds = glyphVector.getLogicalBounds(); width = (float) textBounds.getWidth(); height = (float) textBounds.getHeight(); - fx = (float)x - (width / 2.0f); + fx = (float) x - (width / 2.0f); if (flip) { - fy = (float)(y - 2); + fy = (float) (y - 2); } else { - fy = (float)(y - 1) + height; + fy = (float) (y - 1) + height; } graphics.drawGlyphVector(glyphVector, fx, fy); break; case VERTICAL: // Draw the number one digit at a time, vertically just off the tip of the line if (flip) { - fx = (float)(x - 1) - charWidth; + fx = (float) (x - 1) - charWidth; } else { - fx = (float)(x + 3); + fx = (float) (x + 3); } int numDigits = num.length(); float heightAdjust = (numDigits % 2 == 1) ? charHeight / 2.0f : 0.0f; @@ -151,13 +153,15 @@ public class RulerSkin extends Component glyphVector = font.createGlyphVector(fontRenderContext, line); int midDigit = (numDigits + 1) / 2; if (i <= midDigit) { - fy = (float)y + heightAdjust - descent - (float)(midDigit - i - 1) * charHeight; + fy = (float) y + heightAdjust - descent - (float) (midDigit - i - 1) * charHeight; } else { - fy = (float)y + heightAdjust - descent + (float)(i - midDigit - 1) * charHeight; + fy = (float) y + heightAdjust - descent + (float) (i - midDigit - 1) * charHeight; } graphics.drawGlyphVector(glyphVector, fx, fy); } break; + default: + break; } } @@ -182,16 +186,18 @@ public class RulerSkin extends Component height -= markerInsets.getHeight(); width -= markerInsets.getWidth(); - FontRenderContext fontRenderContext = showMajorNumbers || showMinorNumbers ? - GraphicsUtilities.prepareForText(graphics, font, color) : null; + FontRenderContext fontRenderContext = showMajorNumbers || showMinorNumbers + ? GraphicsUtilities.prepareForText(graphics, font, color) : null; + + int start, end2, end3, end4; Orientation orientation = ruler.getOrientation(); switch (orientation) { - case HORIZONTAL: { - int start = flip ? bottom - 1 : top; - int end2 = flip ? (start - (MAJOR_SIZE - 1)) : (MAJOR_SIZE - 1); - int end3 = flip ? (start - (MINOR_SIZE - 1)) : (MINOR_SIZE - 1); - int end4 = flip ? (start - (REGULAR_SIZE - 1)) : (REGULAR_SIZE - 1); + case HORIZONTAL: + start = flip ? bottom - 1 : top; + end2 = flip ? (start - (MAJOR_SIZE - 1)) : (MAJOR_SIZE - 1); + end3 = flip ? (start - (MINOR_SIZE - 1)) : (MINOR_SIZE - 1); + end4 = flip ? (start - (REGULAR_SIZE - 1)) : (REGULAR_SIZE - 1); for (int i = 0, n = right / markerSpacing + 1; i < n; i++) { int x = i * markerSpacing + left; @@ -212,15 +218,13 @@ public class RulerSkin extends Component graphics.drawLine(x, start, x, end4); } } - break; - } - case VERTICAL: { - int start = flip ? right - 1 : left; - int end2 = flip ? (start - (MAJOR_SIZE - 1)) : (MAJOR_SIZE - 1); - int end3 = flip ? (start - (MINOR_SIZE - 1)) : (MINOR_SIZE - 1); - int end4 = flip ? (start - (REGULAR_SIZE - 1)) : (REGULAR_SIZE - 1); + case VERTICAL: + start = flip ? right - 1 : left; + end2 = flip ? (start - (MAJOR_SIZE - 1)) : (MAJOR_SIZE - 1); + end3 = flip ? (start - (MINOR_SIZE - 1)) : (MINOR_SIZE - 1); + end4 = flip ? (start - (REGULAR_SIZE - 1)) : (REGULAR_SIZE - 1); for (int i = 0, n = bottom / markerSpacing + 1; i < n; i++) { int y = i * markerSpacing + top; @@ -240,13 +244,10 @@ public class RulerSkin extends Component graphics.drawLine(start, y, end4, y); } } - break; - } - default: { + default: break; - } } } @@ -259,7 +260,7 @@ public class RulerSkin extends Component * @return The interval at which the "major" (that is, the long) * markers are drawn. */ - public int getMajorDivision() { + public final int getMajorDivision() { return majorDivision; } @@ -288,7 +289,7 @@ public class RulerSkin extends Component * @return The interval at which the "minor" (that is, the slightly * longer than normal) markers are drawn. */ - public int getMinorDivision() { + public final int getMinorDivision() { return minorDivision; } @@ -316,7 +317,7 @@ public class RulerSkin extends Component /** * @return The number of pixels interval at which to draw markers. */ - public int getMarkerSpacing() { + public final int getMarkerSpacing() { return markerSpacing; } @@ -342,7 +343,7 @@ public class RulerSkin extends Component * @return Whether the ruler is "flipped", that is the markers * start from the inside rather than the outside. */ - public boolean getFlip() { + public final boolean getFlip() { return flip; } @@ -353,7 +354,7 @@ public class RulerSkin extends Component /** * @return Whether to display numbers at each major division. */ - public boolean getShowMajorNumbers() { + public final boolean getShowMajorNumbers() { return showMajorNumbers; } @@ -370,7 +371,7 @@ public class RulerSkin extends Component /** * @return Whether to display numbers at each minor division. */ - public boolean getShowMinorNumbers() { + public final boolean getShowMinorNumbers() { return showMinorNumbers; } @@ -387,7 +388,7 @@ public class RulerSkin extends Component /** * @return The border configuration for this ruler. */ - public Borders getBorders() { + public final Borders getBorders() { return borders; } @@ -401,7 +402,7 @@ public class RulerSkin extends Component /** * @return The insets for the markers (on each edge). */ - public Insets getMarkerInsets() { + public final Insets getMarkerInsets() { return markerInsets; } @@ -437,7 +438,7 @@ public class RulerSkin extends Component * * @return The foreground (marker) color. */ - public Color getColor() { + public final Color getColor() { return color; } @@ -473,7 +474,7 @@ public class RulerSkin extends Component * * @return The current background color. */ - public Color getBackgroundColor() { + public final Color getBackgroundColor() { return backgroundColor; } @@ -507,7 +508,7 @@ public class RulerSkin extends Component /** * @return The font used to format division numbers (if enabled). */ - public Font getFont() { + public final Font getFont() { return font; } @@ -516,7 +517,7 @@ public class RulerSkin extends Component * * @param font The new font to use. */ - public void setFont(Font font) { + public final void setFont(Font font) { Utils.checkNull(font, "font"); // The font we will use is the same name and style, but a 11 pt type @@ -526,7 +527,7 @@ public class RulerSkin extends Component FontRenderContext fontRenderContext = Platform.getFontRenderContext(); GlyphVector glyphVector = this.font.createGlyphVector(fontRenderContext, "0"); Rectangle2D textBounds = glyphVector.getLogicalBounds(); - this.charWidth = (float)textBounds.getWidth(); + this.charWidth = (float) textBounds.getWidth(); // Since we're just drawing numbers, the line spacing can be just the ascent value for the font LineMetrics lm = this.font.getLineMetrics("0", fontRenderContext); this.charHeight = lm.getAscent();