On Fri, 13 Jan 2023 20:36:46 GMT, Harshitha Onkar <hon...@openjdk.org> wrote:
>> In this fix, the common code required for scaled border rendering is unified >> and added to SwingUtilities3. This is achieved by adding a functional >> interface to SwingUtilities3 and calling the the respective paintBorder >> function passed as functional parameter to the method. >> >> Following are the usual steps for any border scaling - >> >> - Resetting transform. >> - Calculating new width, height, x & y-translations. >> - Perform the required border rendering. >> - And at the end restore the previous transform. >> >> To test the refactored code, 3 separate border scaling instances were taken >> (details below) and the SwingUtilities3.paintBorder, (containing the common >> functionality) was applied. All the tests associated with the respective >> border changes pass. >> >> 1. EtchedBorder - [PR#7449](https://github.com/openjdk/jdk/pull/7449) - >> Test: ScaledEtchedBorderTest.java >> 2. LineBorder - [PR#10681](https://github.com/openjdk/jdk/pull/10681) - >> Test: ScaledLineBorderTest & ScaledTextFieldBorderTest.java >> 3. JInternalFrame Border - >> [PR#10274](https://github.com/openjdk/jdk/pull/10274) - Test: >> InternalFrameBorderTest.java >> >> The advantage of this solution is - it avoids code repetition and can be >> reused across all the border classes requiring border scaling fix. > > Harshitha Onkar has updated the pull request incrementally with two > additional commits since the last revision: > > - copyright year updated > - formatting changes, docs added src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java line 148: > 146: /** > 147: * Used within border classes to add specific border implementation > details. > 148: */ Suggestion: /** * A task which paints an <i>unscaled</i> border after {@code Graphics} * transforms are removed. It's used with the * {@link #paintBorder(Component, Graphics, int, int, int, int, UnscaledBorderPainter) * SwingUtilities3.paintBorder} which manages changing the transforms and calculating the * coordinates and size of the border. */ src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java line 151: > 149: @FunctionalInterface > 150: public interface UnscaledBorderPainter { > 151: void paintUnscaledBorder(Component c, Graphics g, Suggestion: /** * Paints the border for the specified component after the * {@code Graphics} transforms are removed. * * <p> * The <i>x</i> and <i>y</i> of the painted border are zero. * * @param c the component for which this border is being painted * @param g the paint graphics * @param w the width of the painted border, in physical pixels * @param h the height of the painted border, in physical pixels * @param scaleFactor the scale that was in the {@code Graphics} * * @see #paintBorder(Component, Graphics, int, int, int, int, UnscaledBorderPainter) SwingUtilities3.paintBorder * @see javax.swing.border.Border#paintBorder(Component, Graphics, int, int, int, int) Border.paintBorder */ void paintUnscaledBorder(Component c, Graphics g, src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java line 159: > 157: * Performs common scaling transformation steps required for > rendering > 158: * the border correctly at different scales. > 159: */ Suggestion: /** * Paints the border for a component ensuring its sides have consistent * thickness at different scales. * <p> * It performs the following steps: * <ol> * <li>Reset the scale transform on the {@code Graphics},</li> * <li>Call {@code painter} to paint the border,</li> * <li>Restore the transform.</li> * </ol> * * @param c the component for which this border is being painted * @param g the paint graphics * @param x the x position of the painted border * @param y the y position of the painted border * @param w the width of the painted border * @param h the height of the painted border * @param painter the painter object which paints the border after * the transform on the {@code Graphics} is reset */ src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java line 167: > 165: // Step 1: Reset Transform > 166: AffineTransform at = null; > 167: Stroke oldStk = null; Suggestion: Stroke oldStroke = null; Let's spell the word in full. It's used twice in the method and I see no reason to abbreviate it. ------------- PR: https://git.openjdk.org/jdk/pull/11571