- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.JavaScript pack. It includes chart, diagram, calendar, map, virtual keyboard, gauge and UI components. Here are more details and live demo for anyone interested.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Java 10 and Windows Text Scaling Support
Read 2410 times

Jasef   Offline
YaBB Newbies
*
Posts: 26


   
     
 
Java 10 and Windows Text Scaling Support
Jun 21st, 2018 at 12:40am
 
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 | 71 )
image.png (15 KB | 92 )
image.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #1 - Jun 24th, 2018 at 4:13pm
 
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:
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
 
 
 
IP Logged    
 
     

Jasef   Offline
YaBB Newbies
*
Posts: 26


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #2 - Jun 25th, 2018 at 11:33pm
 
Thanks Slavcho.

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

Code (Java):
    @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.
 
 
 
IP Logged    
 
     

Jasef   Offline
YaBB Newbies
*
Posts: 26


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #3 - Jul 12th, 2019 at 2:53am
 
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 | 12 )
Overview_Scaling.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #4 - Jul 17th, 2019 at 9:33am
 
Our developer is investigating this.

Regards,
Slavcho
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #5 - Jul 18th, 2019 at 10:11am
 
This build should fix it -
https://mindfusion.eu/_beta/jdiag_highdpi.zip

Source code diff is -
Code:
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
 
 
 
IP Logged    
 
     

Jasef   Offline
YaBB Newbies
*
Posts: 26


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #6 - Jul 28th, 2019 at 11:04pm
 
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).
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #7 - Aug 18th, 2019 at 9:56am
 
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 | 12 )
Untitled_007.png
 
IP Logged    
 
     

Jasef   Offline
YaBB Newbies
*
Posts: 26


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #8 - Aug 19th, 2019 at 12:19am
 
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 9:54pm by Jasef »

Scaling.png (137 KB | 10 )
Scaling.png
Scaling2.png (118 KB | 10 )
Scaling2.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #9 - Aug 26th, 2019 at 12:16pm
 
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
 
 
 
IP Logged    
 
     

Jasef   Offline
YaBB Newbies
*
Posts: 26


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #10 - Aug 28th, 2019 at 10:23pm
 
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 | 10 )
Scaling3.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Java 10 and Windows Text Scaling Support
Reply #11 - Aug 29th, 2019 at 5:56am
 
in setViewport method -

Code:
-		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
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print