Some times ago I wrote a mail about AffineTransforms, perhaps it helps. It is possible to draw pixels using world coordinates. Please read below ----------------
Some mathematical basics here. An affine transform is a powerful mechanism to transform coordinates. To get the new coordinates x' and y', the following calculation is done. [ x'] [ m00 m01 m02 ] [ x ] [ m00x + m01y + m02 ] [ y'] = [ m10 m11 m12 ] [ y ] = [ m10x + m11y + m12 ] [ 1 ] [ 0 0 1 ] [ 1 ] = [ 0 + 0 + 1 ] A simple example: if you want to shift a point 5 units on the x axis and -7 units at the y axis, the following matrix is needed [ 1 0 5 ] [ 0 1 -7 ] [ 0 0 1 ] Of course, you can say this is easy, x'=x+5 and y'=y-7 would do the same. Another one, lets do some scaling, say factor 3 [ 3 0 0 ] [ 0 3 0 ] [ 0 0 1 ] This is easy too, x'=x*3 and y'=y*3 would the job. The power of affine transforms is that you can combine multiple matrices into a single one, doing a set of individual transformations within one step. There is a java method "concatenate(AffineTransform)" for the AffineTransform class. But be careful, given 3 transformatons A,B,C and you want to combine them in this order, you have to go from right to left. C concatenate B concatenate A will give you the expected result. A mapping from world coordinates to pixel coordinates needs some operations but can be done within one affine transformation. The second powerful feature is that you can create an inverse transform (Method createInverse), which will do the mapping in the other direction out of the box. Believe me, if you are used to use AffineTransform objects, you will use them forever. Hope this helps Cheers Christian ----------- Quoting Francesca Martelli <[email protected]>: > Hi all, > I have a problem with translation from utm coordinates in screen pixel > position. I have already seen the tutorials (world2screen, > data2world...), but examples reported there seem do not work in my case. > > I have a mapContext with shapefiles in a jmappane, and I would like to > paint a point (with position expressed in UTM coordinates) over the map. > > Any help is greatly appreciated. > Francesca > > > -- > Francesca Martelli, Computer Science Ph.D. > Algorithms and Computational Mathematics Group, IIT - CNR, Pisa > Phone: +39 050 315 3191 (office), +39 050 315 2333 (fax) > http://www.iit.cnr.it/francesca.martelli/ > email: [email protected] > > > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > _______________________________________________ > Geotools-gt2-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
