java - Coordinate transformation Dilemma, User coordinate to Device coordinate? -
I am working on a task that includes data like "length" of a road in "millimeter". And according to the specification, how do I change my Jephrah 4 meter * 3 meters (device coordinates ...?).
Now, I know at least that this data is real world data and the device does not have pixel information. However after finding some sources you can actually convert these data into pixels by Graphics 2D class.
Resources I have received this information,
Core Java 2, Section II - Advanced Feature, Author - K.A.C. Horstman & amp; Gary Cornell
However, I googled for real examples with no luck.
Does anyone know any source, where I can read more about this and if you have any examples where someone has actually done such a thing, then it would be more informative.
So far, I know that we need the assumption of Graphics 2D class. The number of pixels in meters is such a method in Graphics 2D that allows you to set this assumption Helps. The method is,
g2D.scale (pixelmeter, pixelmetter); // and from meters I can draw a line with meters or millimeters g2D.draw (new line 2d. double (coordinates in meters));
I tried the code above but really want to draw the line really hard.
">
Change the coordinates of a
java.awt.geom.AffineTransform object and meter into your case. In your case,
AffineTransform.getScaleInstance (sx, sy) .
Then I call the
Graphics2D function to draw my lines and polygons using pixels coordinates.
This makes debugging easy: You can see the coordinate values before and after the change.
The Advanced topic section in the Java tutorial describes how to make changes with
Graphics2D with the example:
Comments
Post a Comment