Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » DPI & platform independent figure bounds
DPI & platform independent figure bounds [message #245009] Tue, 19 August 2008 15:36 Go to next message
Justin Dolezy is currently offline Justin DolezyFriend
Messages: 68
Registered: July 2009
Member
Hi all,

Having a bit of an issue with the different DPI's across platforms
[Mac=72x72, Win=96x96 iirc]...

I guess this is more of a general question, but what's the best strategy
for storing coordinates/bounds in a serialised model (XML)? eg a figure
that's 600 pixels wide appears on a Mac at 20cm (say) but on Windows will
be 15cm (say) due to the DPI differences. Obviously this causes havoc on
my 'page' figure!

Was thinking I need to have the model store the DPI at which the diagram
was created, but realisation just dawned as I type that I should probably
convert to device independent units like centimeters.

I guess the usual approach would be to store device independent units,
right?


Thanks for any thoughts!
Justin
Re: DPI & platform independent figure bounds [message #245053 is a reply to message #245009] Thu, 21 August 2008 04:15 Go to previous message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

This problem is resolved in GMF with a MapMode concept. Essentially,
figure coordinates are kept in some generic units. MapMode scaling factor
is initialized at the application runtime, based on DPI, Screen Resolution
etc. Before figure is painted, its generic units coordinates are scaled by
the factor from map mode object, this results in a pixel value for
figure's bounds.
MapMode is defined as some top level figure that owns primary layer and
connection layer, such that primary layer and connection layer figures are
scaled for painting only, i.e. scale factor is pushed on the graphics
object stack.
There are drawbacks in using map mode such as precision. Scaling factor is
non-integer, yet figure coordinates are integer. Therefore precision
errors may occur as a result of translations and you'll be forced to use
precison points, rectangles etc.
You need to explore GMF draw2d component for more information. You'll see
methods DPtoLP(...) and LPtoDP(...) - device unit to logical unit and
logical to device. Device unit = pixel, logical unit = generic unit.
Hope this helps.

Cheers,
Alex
Previous Topic:Problems with Labels (DirectEditRequest)
Next Topic:Big figure problem on linux platorm
Goto Forum:
  


Current Time: Tue Mar 19 10:20:52 GMT 2024

Powered by FUDForum. Page generated in 0.02093 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top