Discussion:
Fix proposal: boolean flag & public API for JDK-8204060 - Disable smoothing at javafx.scene.canvas.GraphicsContext.drawImage()
Ambarish Rapte
2018-10-15 19:29:27 UTC
Permalink
Hi All,



This email is for discussion regarding the fix https://bugs.openjdk.java.net/browse/JDK-8204060 .



Issue:

Images drawn using javafx.scene.canvas .GraphicsContext::drawImage() always apply filtering to the image.



Solution:

javafx.scene.canvas.GraphicsContext should provide an option to enable and disable smoothing.



Proposal:

Adding a Boolean flag & APIs to control smoothing.



Add a boolean flag to control smoothing
Add two public APIs

public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
public boolean getImageSmoothing() {}

If image smoothing is true, images will be scaled using a higher quality filtering when transforming or scaling the source image to fit in the destination rectangle.
If image smoothing is false, images will be scaled without filtering (or by using a lower quality filtering) when transforming or scaling the source image to fit in the destination rectangle.



Please provide your comments on the proposal.





Regards,

Ambarish
Dan Howard
2018-10-15 22:36:03 UTC
Permalink
Shouldn't it be "is" rather than "get" for boolean?  Other than that,
sounds good!
Post by Ambarish Rapte
Hi All,
This email is for discussion regarding the fix https://bugs.openjdk.java.net/browse/JDK-8204060 .
Images drawn using javafx.scene.canvas .GraphicsContext::drawImage() always apply filtering to the image.
javafx.scene.canvas.GraphicsContext should provide an option to enable and disable smoothing.
Adding a Boolean flag & APIs to control smoothing.
Add a boolean flag to control smoothing
Add two public APIs
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
public boolean getImageSmoothing() {}
If image smoothing is true, images will be scaled using a higher quality filtering when transforming or scaling the source image to fit in the destination rectangle.
If image smoothing is false, images will be scaled without filtering (or by using a lower quality filtering) when transforming or scaling the source image to fit in the destination rectangle.
Please provide your comments on the proposal.
Regards,
Ambarish
Kevin Rushforth
2018-10-15 22:55:08 UTC
Permalink
Yes, it should be "isImageSmoothing", thanks for catching this!

This looks good to me to other than that.

The only other comment is that when you write the docs, make sure you
indicate that this applies to drawImage calls, both in the docs of the
new setImageSmooth method, and in the docs of the drawImage calls.
Perhaps you post the proposed javadoc changes, since they will be needed
for the CSR?

-- Kevin
Post by Dan Howard
Shouldn't it be "is" rather than "get" for boolean?  Other than that,
sounds good!
Post by Ambarish Rapte
Hi All,
This email is for discussion regarding the fix
https://bugs.openjdk.java.net/browse/JDK-8204060 .
Images drawn using javafx.scene.canvas .GraphicsContext::drawImage()
always apply filtering to the image.
javafx.scene.canvas.GraphicsContext should provide an option to
enable and disable smoothing.
Adding a Boolean flag & APIs to control smoothing.
Add a boolean flag to control smoothing
Add two public APIs
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
public boolean getImageSmoothing() {}
If image smoothing is true, images will be scaled using a higher
quality filtering when transforming or scaling the source image to
fit in the destination rectangle.
If image smoothing is false, images will be scaled without filtering
(or by using a lower quality filtering) when transforming or scaling
the source image to fit in the destination rectangle.
Please provide your comments on the proposal.
Regards,
Ambarish
Ambarish Rapte
2018-10-16 17:56:22 UTC
Permalink
Hi All,

Below is documentation for the new APIs and a slight modification in the description of existing drawImage() APIs

New APIs setImageSmoothing() & isImageSmoothing()
*****************************************************************
setImageSmoothing () API
*****************************************************************

/**
* Sets the image smoothing flag.
* The default value is {@code true}.<br>
* Image smoothing is an <a href="#image-attr">Image attribute</a>
* used to enable or disable image smoothing for
* {@link #drawImage(javafx.scene.image.Image, double, double) drawImage(all forms)}
* as specified in the <a href="#attr-ops-table">Rendering Attributes Table</a>.<br>
* If image smoothing is {@code true}, images will be scaled using a higher
* quality filtering when transforming or scaling the source image to fit
* in the destination rectangle.<br>
* If image smoothing is {@code false}, images will be scaled without filtering
* (or by using a lower quality filtering) when transforming or scaling the
* source image to fit in the destination rectangle.
*
* @since 12
* @param imageSmoothing true to enable or false to disable smoothing.
* @defaultValue {@code true}
*/
public void setImageSmoothing(boolean imageSmoothing) {
//......
}

*****************************************************************
isImageSmoothing () API
*****************************************************************
/**
* Gets the current state of image smoothing.
* The default value is {@code true}.
*
* @since 12
* @return image smoothing state.
*/
public boolean isImageSmoothing() {
//......
}

*****************************************************************
Image smoothing attribute shall be added to GraphicsContext class docs, in the table "List of Rendering Attributes".
And reference to new image smoothing attribute shall be mentioned in the description of drawImage()
*****************************************************************
* <p>
* This method will be affected by any of the
* <a href="#comm-attr">global common</a>
+ * or <a href="#image-attr">image</a>
* attributes as specified in the
* <a href="#attr-ops-table">Rendering Attributes Table</a>.
* </p>
*****************************************************************

Regards,
Ambarish

-----Original Message-----
From: Kevin Rushforth
Sent: Tuesday, October 16, 2018 4:25 AM
To: Dan Howard <***@videotron.ca>; Ambarish Rapte <***@oracle.com>; openjfx-***@openjdk.java.net
Subject: Re: Fix proposal: boolean flag & public API for JDK-8204060 - Disable smoothing at javafx.scene.canvas.GraphicsContext.drawImage()

Yes, it should be "isImageSmoothing", thanks for catching this!

This looks good to me to other than that.

The only other comment is that when you write the docs, make sure you indicate that this applies to drawImage calls, both in the docs of the new setImageSmooth method, and in the docs of the drawImage calls.
Perhaps you post the proposed javadoc changes, since they will be needed for the CSR?

-- Kevin
Post by Dan Howard
Shouldn't it be "is" rather than "get" for boolean?  Other than that,
sounds good!
Post by Ambarish Rapte
Hi All,
This email is for discussion regarding the fix
https://bugs.openjdk.java.net/browse/JDK-8204060 .
Images drawn using javafx.scene.canvas .GraphicsContext::drawImage()
always apply filtering to the image.
javafx.scene.canvas.GraphicsContext should provide an option to
enable and disable smoothing.
Adding a Boolean flag & APIs to control smoothing.
Add a boolean flag to control smoothing Add two public APIs
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
public boolean getImageSmoothing() {}
If image smoothing is true, images will be scaled using a higher
quality filtering when transforming or scaling the source image to
fit in the destination rectangle.
If image smoothing is false, images will be scaled without filtering
(or by using a lower quality filtering) when transforming or scaling
the source image to fit in the destination rectangle.
Please provide your comments on the proposal.
Regards,
Ambarish
Nir Lisker
2018-10-17 07:54:26 UTC
Permalink
Hi Ambarish,

* I don't think you need to list the default value in the description if
you use @default (which I see other properties don't), for both get and set.
* "true" and "false" in @param need @code.
* I would choose either "image smoothing flag" (used in setter) or "image
smoothing state" (used in getter) consistently.

Thanks,
Nir
Post by Ambarish Rapte
Hi All,
Below is documentation for the new APIs and a slight modification in the
description of existing drawImage() APIs
New APIs setImageSmoothing() & isImageSmoothing()
*****************************************************************
setImageSmoothing () API
*****************************************************************
/**
* Sets the image smoothing flag.
* Image smoothing is an <a href="#image-attr">Image attribute</a>
* used to enable or disable image smoothing for
* as specified in the <a href="#attr-ops-table">Rendering Attributes Table</a>.<br>
* quality filtering when transforming or scaling the source image to fit
* in the destination rectangle.<br>
* (or by using a lower quality filtering) when transforming or scaling the
* source image to fit in the destination rectangle.
*
*/
public void setImageSmoothing(boolean imageSmoothing) {
//......
}
*****************************************************************
isImageSmoothing () API
*****************************************************************
/**
* Gets the current state of image smoothing.
*
*/
public boolean isImageSmoothing() {
//......
}
*****************************************************************
Image smoothing attribute shall be added to GraphicsContext class docs, in
the table "List of Rendering Attributes".
And reference to new image smoothing attribute shall be mentioned in the
description of drawImage()
*****************************************************************
* <p>
* This method will be affected by any of the
* <a href="#comm-attr">global common</a>
+ * or <a href="#image-attr">image</a>
* attributes as specified in the
* <a href="#attr-ops-table">Rendering Attributes Table</a>.
* </p>
*****************************************************************
Regards,
Ambarish
-----Original Message-----
From: Kevin Rushforth
Sent: Tuesday, October 16, 2018 4:25 AM
Subject: Re: Fix proposal: boolean flag & public API for JDK-8204060 -
Disable smoothing at javafx.scene.canvas.GraphicsContext.drawImage()
Yes, it should be "isImageSmoothing", thanks for catching this!
This looks good to me to other than that.
The only other comment is that when you write the docs, make sure you
indicate that this applies to drawImage calls, both in the docs of the new
setImageSmooth method, and in the docs of the drawImage calls.
Perhaps you post the proposed javadoc changes, since they will be needed for the CSR?
-- Kevin
Shouldn't it be "is" rather than "get" for boolean? Other than that,
sounds good!
Post by Ambarish Rapte
Hi All,
This email is for discussion regarding the fix
https://bugs.openjdk.java.net/browse/JDK-8204060 .
Images drawn using javafx.scene.canvas .GraphicsContext::drawImage()
always apply filtering to the image.
javafx.scene.canvas.GraphicsContext should provide an option to
enable and disable smoothing.
Adding a Boolean flag & APIs to control smoothing.
Add a boolean flag to control smoothing Add two public APIs
public void setImageSmoothing(boolean imageSmoothing) {} to enable or
disable smoothing.
public boolean getImageSmoothing() {}
If image smoothing is true, images will be scaled using a higher
quality filtering when transforming or scaling the source image to
fit in the destination rectangle.
If image smoothing is false, images will be scaled without filtering
(or by using a lower quality filtering) when transforming or scaling
the source image to fit in the destination rectangle.
Please provide your comments on the proposal.
Regards,
Ambarish
Ambarish Rapte
2018-10-23 12:14:41 UTC
Permalink
Thanks Kevin, Nir & Dan for the review.

 

I shall make these changes and share the fix for review on new email.

 

Regards,

Ambarish

 

From: Nir Lisker <***@gmail.com>
Sent: Wednesday, October 17, 2018 1:24 PM
To: Ambarish Rapte <***@oracle.com>
Cc: openjfx-***@openjdk.java.net Mailing <openjfx-***@openjdk.java.net>
Subject: Re: Fix proposal: boolean flag & public API for JDK-8204060 - Disable smoothing at javafx.scene.canvas.GraphicsContext.drawImage()

 

Hi Ambarish,

 

* I don't think you need to list the default value in the description if you use @default (which I see other properties don't), for both get and set.

* "true" and "false" in @param need @code.

* I would choose either "image smoothing flag" (used in setter) or "image smoothing state" (used in getter) consistently.

 

Thanks,

Nir

 

 

On Tue, Oct 16, 2018 at 8:57 PM Ambarish Rapte <HYPERLINK "mailto:***@oracle.com"***@oracle.com> wrote:

Hi All,

Below is documentation for the new APIs and a slight modification in the description of existing drawImage() APIs

New APIs setImageSmoothing() & isImageSmoothing()
*****************************************************************
setImageSmoothing () API
*****************************************************************

     /**
     * Sets the image smoothing flag.
     * The default value is {@code true}.<br>
     * Image smoothing is an <a href="#image-attr">Image attribute</a>
     * used to enable or disable image smoothing for
     * {@link #drawImage(javafx.scene.image.Image, double, double) drawImage(all forms)}
     * as specified in the <a href="#attr-ops-table">Rendering Attributes Table</a>.<br>
     * If image smoothing is {@code true}, images will be scaled using a higher
     * quality filtering when transforming or scaling the source image to fit
     * in the destination rectangle.<br>
     * If image smoothing is {@code false}, images will be scaled without filtering
     * (or by using a lower quality filtering) when transforming or scaling the
     * source image to fit in the destination rectangle.
     *
     * @since 12
     * @param imageSmoothing true to enable or false to disable smoothing.
     * @defaultValue {@code true}
     */
    public void setImageSmoothing(boolean imageSmoothing) {
    //......
    }

*****************************************************************
isImageSmoothing () API
*****************************************************************
    /**
     * Gets the current state of image smoothing.
     * The default value is {@code true}.
     *
     * @since 12
     * @return image smoothing state.
     */
    public boolean isImageSmoothing() {
        //......
        }

*****************************************************************
Image smoothing attribute shall be added to GraphicsContext class docs, in the table "List of Rendering Attributes".
And reference to new image smoothing attribute shall be mentioned in the description of drawImage()
*****************************************************************
      * <p>
      * This method will be affected by any of the
      * <a href="#comm-attr">global common</a>
+     * or <a href="#image-attr">image</a>
      * attributes as specified in the
      * <a href="#attr-ops-table">Rendering Attributes Table</a>.
      * </p>
*****************************************************************

Regards,
Ambarish

-----Original Message-----
From: Kevin Rushforth
Sent: Tuesday, October 16, 2018 4:25 AM
To: Dan Howard <HYPERLINK "mailto:***@videotron.ca"***@videotron.ca>; Ambarish Rapte <HYPERLINK "mailto:***@oracle.com"***@oracle.com>; HYPERLINK "mailto:openjfx-***@openjdk.java.net"openjfx-***@openjdk.java.net
Subject: Re: Fix proposal: boolean flag & public API for JDK-8204060 - Disable smoothing at javafx.scene.canvas.GraphicsContext.drawImage()

Yes, it should be "isImageSmoothing", thanks for catching this!

This looks good to me to other than that.

The only other comment is that when you write the docs, make sure you indicate that this applies to drawImage calls, both in the docs of the new setImageSmooth method, and in the docs of the drawImage calls.
Perhaps you post the proposed javadoc changes, since they will be needed for the CSR?

-- Kevin
Post by Dan Howard
Shouldn't it be "is" rather than "get" for boolean?  Other than that,
sounds good!
Post by Ambarish Rapte
Hi All,
This email is for discussion regarding the fix
https://bugs.openjdk.java.net/browse/JDK-8204060 .
Images drawn using javafx.scene.canvas .GraphicsContext::drawImage()
always apply filtering to the image.
javafx.scene.canvas.GraphicsContext should provide an option to
enable and disable smoothing.
Adding a Boolean flag & APIs to control smoothing.
Add a boolean flag to control smoothing Add two public APIs
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
public boolean getImageSmoothing() {}
If image smoothing is true, images will be scaled using a higher
quality filtering when transforming or scaling the source image to
fit in the destination rectangle.
If image smoothing is false, images will be scaled without filtering
(or by using a lower quality filtering) when transforming or scaling
the source image to fit in the destination rectangle.
Please provide your comments on the proposal.
Regards,
Ambarish
Nir Lisker
2018-10-15 22:52:37 UTC
Permalink
Post by Ambarish Rapte
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
A bit of forward thinking here. Will there always be only 2 ways of doing
smoothing: "on" or "off"?
If there will be different algorithms for smoothing, will they be set
separately by "setSmoothingAlgorithm" a la strategy pattern?
Some similar cases use an enum, like CacheHint [1], or what I think should
have been an enum, like SceneAntialiasing [2] (which has another 2
commented-out settings). Is adding elements to an enum even allowed by
backwards compatibility?

[1]
https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/CacheHint.html
[2]
https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/SceneAntialiasing.html
Post by Ambarish Rapte
Hi All,
This email is for discussion regarding the fix
https://bugs.openjdk.java.net/browse/JDK-8204060 .
Images drawn using javafx.scene.canvas .GraphicsContext::drawImage()
always apply filtering to the image.
javafx.scene.canvas.GraphicsContext should provide an option to enable and
disable smoothing.
Adding a Boolean flag & APIs to control smoothing.
Add a boolean flag to control smoothing
Add two public APIs
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
public boolean getImageSmoothing() {}
If image smoothing is true, images will be scaled using a higher quality
filtering when transforming or scaling the source image to fit in the
destination rectangle.
If image smoothing is false, images will be scaled without filtering (or
by using a lower quality filtering) when transforming or scaling the source
image to fit in the destination rectangle.
Please provide your comments on the proposal.
Regards,
Ambarish
Kevin Rushforth
2018-10-15 22:58:58 UTC
Permalink
A good question. In this case it is intended to match the
ImageView::smooth property, which is a boolean. If there is a need later
that more than one value is needed we would have to add a new enum
attribute that would take effect if imageSmooth==true, but that would be
the case for any of the smooth attributes for shapes as well.

-- Kevin
Post by Nir Lisker
Post by Ambarish Rapte
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
A bit of forward thinking here. Will there always be only 2 ways of doing
smoothing: "on" or "off"?
If there will be different algorithms for smoothing, will they be set
separately by "setSmoothingAlgorithm" a la strategy pattern?
Some similar cases use an enum, like CacheHint [1], or what I think should
have been an enum, like SceneAntialiasing [2] (which has another 2
commented-out settings). Is adding elements to an enum even allowed by
backwards compatibility?
[1]
https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/CacheHint.html
[2]
https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/SceneAntialiasing.html
Post by Ambarish Rapte
Hi All,
This email is for discussion regarding the fix
https://bugs.openjdk.java.net/browse/JDK-8204060 .
Images drawn using javafx.scene.canvas .GraphicsContext::drawImage()
always apply filtering to the image.
javafx.scene.canvas.GraphicsContext should provide an option to enable and
disable smoothing.
Adding a Boolean flag & APIs to control smoothing.
Add a boolean flag to control smoothing
Add two public APIs
public void setImageSmoothing(boolean imageSmoothing) {} to enable or disable smoothing.
public boolean getImageSmoothing() {}
If image smoothing is true, images will be scaled using a higher quality
filtering when transforming or scaling the source image to fit in the
destination rectangle.
If image smoothing is false, images will be scaled without filtering (or
by using a lower quality filtering) when transforming or scaling the source
image to fit in the destination rectangle.
Please provide your comments on the proposal.
Regards,
Ambarish
Loading...