Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Java 10 and Windows Text Scaling Support (Read 11296 times)
Jasef
YaBB Newbies
*
Offline



Posts: 26
Joined: Jul 17th, 2011
Java 10 and Windows Text Scaling Support
Jun 20th, 2018 at 11:40pm
Print Post  
Does JDiagram 4.3.2 support Java 10 and windows text (resolution) scaling?
(Does not require high resolution monitors, reproducible on both 1080 and 1440 resolutions)

I seem to be getting a white area to the right and below the diagram area which the diagram view covers. (See attached image)
You can test this with ctrl+mouse wheel to see the diagram zoon in/out.
(There should be no zooming when the mouse is in the gray area)
It doesn't happen on Java 8. It also occurs on Java 9.

I've also attached some sample code.
  

MainWin.zip ( 0 KB | 336 Downloads )
image.png ( 15 KB | 247 Downloads )
image.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Java 10 and Windows Text Scaling Support
Reply #1 - Jun 24th, 2018 at 3:13pm
Print Post  
From what we can tell, Java started scaling control layout sizes by ScreenResolution value. The diagram does not draw itself relative to DiagramView's size though, but already scales by ScreenResolution internally, so Java's additional scale leaves that white border unpainted. You can work around that by inverse-scaling the view size to compensate for the extra resolution scale:

Code
Select All
public class DiagramViewEx extends DiagramView
{
  public DiagramViewEx(Diagram diagram)
  {
    super(diagram);
  }

  public Dimension getPreferredSize()
  {
    var scale = Toolkit.getDefaultToolkit().getScreenResolution() / 96.0f;
    var size = super.getPreferredSize();
    size.setSize(
      size.getWidth() / scale,
      size.getHeight() / scale);
    return size;
  }
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Jasef
YaBB Newbies
*
Offline



Posts: 26
Joined: Jul 17th, 2011
Re: Java 10 and Windows Text Scaling Support
Reply #2 - Jun 25th, 2018 at 10:33pm
Print Post  
Thanks Slavcho.

We had to use the following instead to handle Windows not updating the value from getScreenResolution until log out.

Code (Java)
Select All
    @Override
    public Dimension getPreferredSize()
    {
        AffineTransform transform = getGraphicsConfiguration().getDefaultTransform();
        Dimension size = super.getPreferredSize();

        size.setSize(
                size.getWidth() / transform.getScaleX(),
                size.getHeight() / transform.getScaleY()
        );

        return size;
    } 




Cheers,
Jasef.
  
Back to top
 
IP Logged
 
Jasef
YaBB Newbies
*
Offline



Posts: 26
Joined: Jul 17th, 2011
Re: Java 10 and Windows Text Scaling Support
Reply #3 - Jul 12th, 2019 at 1:53am
Print Post  
Hi,

we've also noticed that in 4.3.3 and 4.4 that the Overview has similar issues when windows scaling is turned on.

If you look at the attached screenshot, the two images display the overview's view port as different sizes when the diagram's view has only changed locations.
More obvious with the more vertical space the diagram has.

In some cases, the overview's view port does not even represent what the diagram's view is.

Anything we can change to fix this (licensed with the source)


Thanks,
Jasef.
  

Overview_Scaling.png ( 155 KB | 279 Downloads )
Overview_Scaling.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Java 10 and Windows Text Scaling Support
Reply #4 - Jul 17th, 2019 at 8:33am
Print Post  
Our developer is investigating this.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Java 10 and Windows Text Scaling Support
Reply #5 - Jul 18th, 2019 at 9:11am
Print Post  
This build should fix it -
https://mindfusion.eu/_beta/jdiag_highdpi.zip

Source code diff is -
Code
Select All
diff --git a/src/com/mindfusion/diagramming/Overview.java b/src/com/mindfusion/diagramming/Overview.java
index 0edb761..d8100c1 100644
--- a/src/com/mindfusion/diagramming/Overview.java
+++ b/src/com/mindfusion/diagramming/Overview.java
@@ -358,7 +358,8 @@ public class Overview extends JComponent
 			}
 			g2d.drawImage(diagramImage, 0, 0, this);

-			g2d.setTransform(getTransform());
+			//g2d.setTransform(getTransform());
+			g2d.transform(getTransform());
 			g2d.setColor(marginalColor);

 			Area ar = new Area(rectDoc);
@@ -614,8 +615,9 @@ public class Overview extends JComponent
 			return;

 		Rectangle rc = diagramView.getVisibleRect();
-		Point2D.Float ptDocRB = diagramView.deviceToDoc(new Point(rc.x
-				+ rc.width, rc.y + rc.height));
+		rcDoc = diagramView.deviceToDoc(rc);
+		/*Point2D.Float ptDocRB = diagramView.deviceToDoc(
+			new Point(rc.x + rc.width, rc.y + rc.height));

 		// Make sure the doc viewport does not exceed the document content
 		Rectangle2D docBounds = diagram().getBounds();
@@ -626,7 +628,7 @@ public class Overview extends JComponent

 		// Viewport in document coordinates
 		Utilities.FromLTRB(diagramView.getScrollX(), diagramView.getScrollY(),
-				ptDocRB.getX(), ptDocRB.getY(), rcDoc);
+				ptDocRB.getX(), ptDocRB.getY(), rcDoc);*/

 		// Viewport in client coordinates
 		rcView = Utilities.docToDevice(getTransform(), rcDoc); 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jasef
YaBB Newbies
*
Offline



Posts: 26
Joined: Jul 17th, 2011
Re: Java 10 and Windows Text Scaling Support
Reply #6 - Jul 28th, 2019 at 10:04pm
Print Post  
Awesome, that seems to work when interacting with the diagram, however I'm noticing that interacting with the overview itself that the mouse click on the overview doesn't recenter the view port to the mouse position (view port represents the diagram though).
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Java 10 and Windows Text Scaling Support
Reply #7 - Aug 18th, 2019 at 8:56am
Print Post  
Clicks work correctly in our tests, e.g. the attached screenshot is from after clicking the overview over the now-centered node while initial viewport did not contain it. Note that the viewport might not get centered if scroll position is near the diagram's boundaries as the viewport can't stick outside them - that's not coming from the Windows display scale factor but works the same at 100% scale. If it's not centering the viewport for you while away from the diagram's edges, please post your Overview property values and related diagram ones like size and measure unit.
  

Untitled_007.png ( 192 KB | 300 Downloads )
Untitled_007.png
Back to top
 
IP Logged
 
Jasef
YaBB Newbies
*
Offline



Posts: 26
Joined: Jul 17th, 2011
Re: Java 10 and Windows Text Scaling Support
Reply #8 - Aug 18th, 2019 at 11:19pm
Print Post  
Settings for the use case:
- Windows 10
- Windows scaling set to 125%
- Using the previously attached: jdiag_highdpi.zip
- Using JDiagram 4.4 sample files against the above jar.
- Adopt OpenJDK 11

Attached a couple of screenshots of what I meant in the my previous post.
(I could email a video of it, if that helps)
But as you can see, my first click doesn't align the viewport centrally on the mouse click. And clicking again will do so, but the diagram will have same view as the initial click.
Also doing a drag will see the viewport not being aligned (centrally) to the mouse either. (Where the first click to start the drag is not within the viewport)

(Edit: Added Java)
« Last Edit: Aug 19th, 2019 at 8:54pm by Jasef »  

Scaling.png ( 137 KB | 248 Downloads )
Scaling.png
Scaling2.png ( 118 KB | 268 Downloads )
Scaling2.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Java 10 and Windows Text Scaling Support
Reply #9 - Aug 26th, 2019 at 11:16am
Print Post  
Right, our developer was trying it with older Java. This build should correctly center the viewport around clicks -
https://mindfusion.eu/_beta/jdiag_highdpi.zip

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jasef
YaBB Newbies
*
Offline



Posts: 26
Joined: Jul 17th, 2011
Re: Java 10 and Windows Text Scaling Support
Reply #10 - Aug 28th, 2019 at 9:23pm
Print Post  
This seems to be working, it might still need some more polishing, but works enough.
One is attempting to drag, but just hold mouse1 down and letting go (see screenshot).
And some issues around the borders that is similar to above or not reaching the edge (Different behavior to no-scaling).

Can I get a source diff please.


Thanks,
Jasef.
  

Scaling3.png ( 63 KB | 289 Downloads )
Scaling3.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Java 10 and Windows Text Scaling Support
Reply #11 - Aug 29th, 2019 at 4:56am
Print Post  
in setViewport method -

Code
Select All
-		rcDoc.setRect(Utilities.deviceToDoc(getTransform(), rcView));
+		GraphicsConfiguration gfxConfig = getGraphicsConfiguration();
+		AffineTransform transform = gfxConfig != null ?
+			gfxConfig.getDefaultTransform() : new AffineTransform();
+		transform.concatenate(getTransform());
+
+		rcDoc.setRect(Utilities.deviceToDoc(transform, rcView)); 



Regrds,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Java 10 and Windows Text Scaling Support
Reply #12 - Dec 3rd, 2019 at 8:16am
Print Post  
Beta build here should fix the highlight offset from that last screenshot -
https://mindfusion.eu/Forum/YaBB.pl?num=1574787534

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint