<Swing Dev> [9] Review request for 8153522: Update JLightweightFrame to allow non-integer (and X/Y) scales

Alexandr Scherbatiy alexandr.scherbatiy at oracle.com
Tue Oct 25 17:17:25 UTC 2016


On 9/29/2016 10:55 AM, Semyon Sadetsky wrote:
> Hello,
>
> Please review fix for JDK9:
>
> bug: https://bugs.openjdk.java.net/browse/JDK-8153522
>
> webrev: http://cr.openjdk.java.net/~ssadetsky/8153522/webrev.00/
>
> LightweightFrame Swing embedding API is updated for capability with 
> floating point scale to make JavaFX SwingNode correctly shown on 
> Windows platform.
>
> Backward API compatibility is preserved but methods with old 
> signatures are marked as deprecated.

JLightweightFrame

  155                     new Rectangle(0, 0,
  156                           (int)Math.round(bbImage.getWidth() / 
scaleFactorX),
  157                           (int)Math.round(bbImage.getHeight() / 
scaleFactorY)));

  303             int startX = (int)(x * scaleX);
  304             int startY = (int)(y * scaleY);
  305             int width  = (int)((x + w) * scaleX + 0.5) - startX;
  306             int height = (int)((y + h) * scaleY + 0.5) - startY;

The usual rule is to use Math.floor() for the top left corner of a 
region and Math.ceil() for for the right bottom corner.

171         imageBufferReset(data, x, y, width, height, linestride, 
(int)scaleX);

May be it is better to use Math.round() here for the scale rounding.

Thanks,
Alexandr.

>
> --Semyon
>




More information about the swing-dev mailing list