Re: [OpenJDK 2D-Dev] Clarification regarding PageFormat and Paper getImageable* functions orientation consideration

2021-03-23 Thread Alexey Ivanov

Hi Rajat,

I agree with Phil.

Both PageFormat [1] and Paper [2] have getImageable*() methods. The spec 
for each of these methods in PageFormat states, “This method takes into 
account the orientation of the page.” The implementation confirms this 
statement.


Yet the spec for Paper does not have this statement.

The test case in JDK-8203395 [3] gets the margins from Paper object and 
it gets the same results, irrespective of the page orientation. This is 
*expected* because Paper does not take into account the orientation.


As you noticed, getting the margins from PageFormat object directly 
produces the expected result: the margins are different in portrait 
(default) and landscape orientation.


Thus both classes — PageFormat and Paper — behave exactly as specified.


As for the question:
My question is that should Paper getImageable* functions also need 
take into account orientation as per spec ?, or is the current 
behavior of them not considering orientation correct and why ?
The Paper object doesn't have orientation. So I believe the current 
behaviour is correct.


--
Regards,
Alexey

[1] 
https://docs.oracle.com/javase/8/docs/api/java/awt/print/PageFormat.html#getImageableX--

https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/awt/print/PageFormat.html#getImageableX()
[2] 
https://docs.oracle.com/javase/8/docs/api/java/awt/print/Paper.html#getImageableX--

https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/java/awt/print/Paper.html#getImageableX()
[3]  https://bugs.openjdk.java.net/browse/JDK-8203395


On 22/03/2021 21:54, Philip Race wrote:

There's no bug here from what I am being shown.

>"PageFormat showing wrong printer margins in LANDSCAPE orientation” .

Really ? But I don't see anywhere the PageFormat is queried for this.
Instead the test case digs inside the PageFormat and retrieves the 
Paper and asks for *its* margins


I see a comment in the bug :
> All getImageable methodes javadoc say "This method takes into 
account the orientation of the page" but It's not true before printing.


The methods that say that, are the ones on PageFormat, not the ones on 
Paper. So wrong.



-phil

On 3/22/21 1:55 PM, Rajat Mahajan wrote:


Hi all,

*_Issue:_*

*__*

I am working on https://bugs.openjdk.java.net/browse/JDK-8203395 
  and this bug is 
about *“PageFormat showing wrong printer margins in LANDSCAPE 
orientation” .*


**

*Application code it trying to print in Landscape and Portrait but 
both show same margins:*


Margins default : 12,12,17,17

Margins OrientationRequested.LANDSCAPE : 12,12,17,17

**

*The code of the application uses Paper object for getting margins :*

PageFormat pf = printerJob.getPageFormat(aset);

   Paper paper = pf.getPaper();

   long paperTopMargin = Math.round(paper.getImageableY());
   long paperLeftMargin = Math.round(paper.getImageableX());
   long paperRightMargin = Math.round(paper.getWidth() - 
paper.getImageableWidth() - paperLeftMargin);
   long paperBottomMargin = Math.round(paper.getHeight() - 
paper.getImageableHeight() - paperTopMargin);


When I looked at the latest JDK code, PageFormat getImageable 
functions are taking into account Orientation and Paper getImageable 
functions are not , and hence we see the same output.


Using Page format object instead of Paper shows the correct output:

Margins default : 12,12,17,17

Margins OrientationRequested.LANDSCAPE : 17,17,12,12

*_Question:_*

My question is that should Paper getImageable* functions also need 
take into account orientation as per spec ?, or is the current 
behavior of them not considering orientation correct and why ?








Re: [OpenJDK 2D-Dev] Clarification regarding PageFormat and Paper getImageable* functions orientation consideration

2021-03-22 Thread Philip Race

There's no bug here from what I am being shown.

>"PageFormat showing wrong printer margins in LANDSCAPE orientation” .

Really ? But I don't see anywhere the PageFormat is queried for this.
Instead the test case digs inside the PageFormat and retrieves the Paper 
and asks for *its* margins


I see a comment in the bug :
> All getImageable methodes javadoc say "This method takes into account 
the orientation of the page" but It's not true before printing.


The methods that say that, are the ones on PageFormat, not the ones on 
Paper. So wrong.



-phil

On 3/22/21 1:55 PM, Rajat Mahajan wrote:


Hi all,

*_Issue:_*

*__*

I am working on https://bugs.openjdk.java.net/browse/JDK-8203395 
  and this bug is 
about *“PageFormat showing wrong printer margins in LANDSCAPE 
orientation” .*


**

*Application code it trying to print in Landscape and Portrait but 
both show same margins:*


Margins default : 12,12,17,17

Margins OrientationRequested.LANDSCAPE : 12,12,17,17

**

*The code of the application uses Paper object for getting margins :*

PageFormat pf = printerJob.getPageFormat(aset);

   Paper paper = pf.getPaper();

   long paperTopMargin = Math.round(paper.getImageableY());
   long paperLeftMargin = Math.round(paper.getImageableX());
   long paperRightMargin = Math.round(paper.getWidth() - 
paper.getImageableWidth() - paperLeftMargin);
   long paperBottomMargin = Math.round(paper.getHeight() - 
paper.getImageableHeight() - paperTopMargin);


When I looked at the latest JDK code, PageFormat getImageable 
functions are taking into account Orientation and Paper getImageable 
functions are not , and hence we see the same output.


Using Page format object instead of Paper shows the correct output:

Margins default : 12,12,17,17

Margins OrientationRequested.LANDSCAPE : 17,17,12,12

*_Question:_*

My question is that should Paper getImageable* functions also need 
take into account orientation as per spec ?, or is the current 
behavior of them not considering orientation correct and why ?






[OpenJDK 2D-Dev] Clarification regarding PageFormat and Paper getImageable* functions orientation consideration

2021-03-22 Thread Rajat Mahajan
Hi all,

Issue:

I am working on https://bugs.openjdk.java.net/browse/JDK-8203395  and this bug 
is about "PageFormat showing wrong printer margins in LANDSCAPE orientation" .

Application code it trying to print in Landscape and Portrait but both show 
same margins:

Margins default : 12,12,17,17
Margins OrientationRequested.LANDSCAPE : 12,12,17,17

The code of the application uses Paper object for getting margins :

PageFormat pf = printerJob.getPageFormat(aset);

   Paper paper = pf.getPaper();

   long paperTopMargin = Math.round(paper.getImageableY());
   long paperLeftMargin = Math.round(paper.getImageableX());
   long paperRightMargin = Math.round(paper.getWidth() - 
paper.getImageableWidth() - paperLeftMargin);
   long paperBottomMargin = Math.round(paper.getHeight() - 
paper.getImageableHeight() - paperTopMargin);

When I looked at the latest JDK code, PageFormat getImageable functions are 
taking into account Orientation and Paper getImageable functions are not , and 
hence we see the same output.

Using Page format object instead of Paper shows the correct output:

Margins default : 12,12,17,17
Margins OrientationRequested.LANDSCAPE : 17,17,12,12

Question:

My question is that should Paper getImageable* functions also need take into 
account orientation as per spec ?, or is the current behavior of them not 
considering orientation correct and why ?