- Welcome, Guest. Please Login or Register
MindFusion  
  We are soon releasing MindFusion.JavaScript pack. Initial version includes chart, diagram, calendar, map, virtual keyboard, gauge and UI components. Here are the beta version and live demo for anyone interested.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Java 10 and Windows Text Scaling Support
Read 1726 times

Jasef   Offline
YaBB Newbies
*
Posts: 23


   
     
 
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 | 62 )
image.png (15 KB | 85 )
image.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1718
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: 23


   
     
 
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: 23


   
     
 
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 | 4 )
Overview_Scaling.png
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1718
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: 1718
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    
 
     
Page Index Toggle Pages: 1 Send Topic Print