On Tue, 29 Nov 2022 02:12:28 GMT, SWinxy <d...@openjdk.org> wrote:

>> @SWinxy Thanks for catching it. That's right, but the scale factor cannot be 
>> zero, it should probably be handled similar to `stkWidth` if **'at is 
>> null'** (at is null when g is not an instance of Graphics2D). I'll need to 
>> check the scale value to be used in this context.
>> 
>> Something like below. 
>>  `at != null ? at.getScaleX() : 1;`
>
> Oh I see. Otherwise the thickness would be zero. I feeeeel like doing a large 
> if-else on checking if g is a Graphics2D would end up being cleaner. I 
> fiddled around and this is what the else branch would look like with the 
> affine transform value being `1`:
> 
> g.translate(x, y);
> g.setColor(background);
> // Draw the bulk of the border
> for (int i = 0; i < 5; i++) {
>     g.drawRect(i, i, w - (i * 2), h - (i * 2));
> }
> if (c instanceof JInternalFrame internalFrame && internalFrame.isResizable()) 
> {
>     // Draw the Long highlight lines
>     g.setColor(highlight);
>     g.drawLine(CORNER + 1, 2, w - CORNER, 2); //top
>     g.drawLine(2, CORNER + 1, 2, h - CORNER); //left
>     g.drawLine(w - 2, CORNER + 1, w - 2, h - CORNER); //right
>     g.drawLine(CORNER + 1, h - 2, w - CORNER, h - 2); //bottom
>     // Draw the Long shadow lines
>     g.setColor(shadow);
>     g.drawLine(CORNER, 1, w - CORNER - 1, 1);
>     g.drawLine(1, CORNER, 1, h - CORNER - 1);
>     g.drawLine(w - 3, CORNER, w - 3, h - CORNER - 1);
>     g.drawLine(CORNER, h - 3, w - CORNER - 1, h - 3);
> }
> // restore previous transform
> g.translate(-x, -y);

@SWinxy @aivanov-jdk Added a new local variable `scaleFactor` to avoid NPE 
issues (mentioned above) if AffineTransform (at) is not set. This variable is 
later used to scale the thickness and corners of the border (line 313 & 330).

-------------

PR: https://git.openjdk.org/jdk/pull/11305

Reply via email to