DPI & platform independent figure bounds [message #245009] |
Tue, 19 August 2008 11:36  |
Eclipse User |
|
|
|
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 00:15  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06796 seconds