Diego Fdez. Durán wrote:
> If rewrite the example code so I can transform among screen and world
> coordinates and back in a cleaner way, and fix many syntax errors in the
> example.
>
> I'm waiting for your comments :)
>
Cool!
So what I would need to do; is break down what world2screen is doing (it
is doing something!). And show people how to do it step by step .. in
the reverse order. I have not looked at the code yet so I am not sure.
> private void updateTransforms() {
> try {
> world2screen =
> RendererUtilities.worldToScreenTransform(mapContext.getLayerBounds(),
> new Rectangle(panelMap.getWidth(), panelMap.getHeight()));
> screen2world = world2screen.createInverse();
> } catch (IOException ex) {
> } catch (NoninvertibleTransformException ex) {
> }
> }
>
There are several transform methods; I think there is a way to transform
the provided DirectPosition( ie point) in one step. If we can do that
we never have to look at what axis is X and what axis is Y; and we will
be doing this properly.
-
http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/operation/MathTransform.html
> /*
> * "point" has the point coordinates in world UTM coordinate reference
> * system.
> */
> private void drawPoint(Graphics g, DirectPosition point) {
>
DirectPosition positionScreen = world2screen.transform( point, null );
Point2D pointScreen = new Point( (int) point.getOrdinate(0),
point.getOrdinate(1) );
> int ovalSize = 20;
> Color colorPrevious = g.getColor(); // Save previous color
> g.setColor(Color.BLACK); // "Point" color
> g.fillOval((int) (pointScreen.getX() - ovalSize / 2),
> (int) (pointScreen.getY() - ovalSize / 2),
> ovalSize,
> ovalSize);
> g.setColor(colorPrevious); // Restore color
> }
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users