• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Not the same scale with drawString  RSS feed

 
Ranch Hand
Posts: 111
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

The goal is to display a curve with x in linear and y in logarithm.
This is working well, except I didn't succeed to display the X coordinates



With



The result is as following.

Could you please help ??

Many thanks

Christian
Capture.PNG
[Thumbnail for Capture.PNG]
View without to display the coordinate X
Capture1.PNG
[Thumbnail for Capture1.PNG]
View showing the coordinate X
 
Christian Klugesherz
Ranch Hand
Posts: 111
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please explain why in my code: font.derive() is not working as expected ?



Thanks in advance

Regards

Christian
 
Master Rancher
Posts: 3004
105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Christian,

instead of fonr.deriveFont(at), use font.deriveFont(at.createInverse());
But getting the inverse AffineTranform might throw a checked Exception, so use something like
     
and use this 'realFont'
 
Piet Souris
Master Rancher
Posts: 3004
105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way: a possible problem is the determination of the pixelsize, when the x-scaling and the y-scaling are very different in magnitude. To get a line as thin as possible (i.e. 1 real pixel) you can use

where g2d is a Graphics2D.

Edit: in my previous reply my starting font was with size 12, before applying this derive font and it looked correct.  However, you start with a font size of 1. So, try different settings since I'm not sure of the impact.
 
Christian Klugesherz
Ranch Hand
Posts: 111
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The issue is linked to the width and high of the font.
In fact when my "y" range is going from [0 to 100] it is approximately working
but when my "y" range is going from [-1 to 2] it is ugly. :-(

I guess that issue is linked to the font scale which is biased between high and width.
No idea how to fix that

In the code below just comment or de-comment



Code used:



Thanks in advance

Christian
Capturenotgood.PNG
[Thumbnail for Capturenotgood.PNG]
"y" range is going from [-1 to 2]
Capturenalmostgood.PNG
[Thumbnail for Capturenalmostgood.PNG]
"y" range is going from [0 to 100]
 
Christian Klugesherz
Ranch Hand
Posts: 111
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a remark.

I know that I can fix this issue, simply by saving the transformation before any scale


Then to display the coordinates : Abscissa /Ordinate in 1x1 scale.
But by the way, here I have to compute the position x,y where I want to display the text. .. :-(
Sure, it would have been much easier if there would be a possibility to work directly in the final scale-translate area...
...

Of course, once my coordinates are displayed, to have the possibility to come back to the scaled-translated transformation with


Any comments much appreciated,  in order to display text, in case x/y scales are not the same..

Merci beaucoup

Christian
 
Christian Klugesherz
Ranch Hand
Posts: 111
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hummmmm...

Finally I got it.
The solution was simple to invert the affine transform in the font.deriveFont



Hope it can help anybody else
:-)

Christian
Capture.PNG
[Thumbnail for Capture.PNG]
Work
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!