ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Fonts look blurry on scaled screen size
Posted by Michael Opitz on Aug-11-2023 22:34
Attachments:
I have a question regarding Chartdirector 7.0 Java:

I have an application, with Chartdirector which produces nice looking charts, if I have a monitor with an 100% scaling in display settings.
As soon, as I move my application to another screen which has a 125% scaling in display settings, the antialiasing of the fonts gets messy.

Is there a way to adjust Chartdirector to consider the screen scaling?

See attached files "Scale100Percent" and "Scale125Percent".
I have turned on antialiasing with "Chart.setAntiAlias(true, Chart.AutoAntiAlias);"

Both pictures were taken with the same running program on different screens.
Scale100Percent.png
Scale125Percent.png

  Re: Fonts look blurry on scaled screen size
Posted by Michael Opitz on Aug-11-2023 22:40
By the way, I am using OpenJDK to run the program. I have read, that there are mechanisms in Oracle's JDK which may improve the antialiasing.

  Re: Fonts look blurry on scaled screen size
Posted by Peter Kwan on Aug-12-2023 03:18
Hi Michael Opitz,

From your previous message, it seems your application is a Java SWING application (as opposed to a web application). In this case, I guess SWING is doing the scaling automatically. It is quite possible the Oracle Java can scale better then OpenJDK.

ChartDirector 7.0 can scale the image very well that you cannot tell the image has been scaled. However, ChartDirector cannot stop SWING from automatically scaling the image too. That means the image can be scaled twice. You will get a bigger image, but its quality is still the quality provided by SWING scaling.

So to use ChartDirector scaling, you may need to find a way to disable SWING from automatically scale the image.

To ask ChartDirector to scale the image, you can set the bmpScale option before passing the chart to the ChartViewer:

c.setOutputOptions("bmpScale=1.25;");
myChartViewer.setChart(c);

See:
https://www.advsofteng.com/doc/cdjava.htm#BaseChart.setOutputOptions.htm

I searched the Java doc but cannot find a way to control SWING scaling for a particular control. I guess it may be possible to control scaling by a JPanel by overriding its paintComponent method and setting an affine transform there. The ChartViewer control can then be assigned to be a child of the JPanel.

Best Regards
Peter Kwan

  Re: Fonts look blurry on scaled screen size
Posted by Michael Opitz on Aug-15-2023 18:04
Thanks for your answer. I could read the actual scaling from the transform of the current graphics and were able to implement the scaling according to your suggestion.

I have overriden the "paintComponent" method of the ChartViewer to paint it with a scaling of 1.0 and let ChartDirector do the scaling.

Was a bit tricky to adjust the positions, but I solved it.

Works fine now!