Package org.geotools.swing

Source Code of org.geotools.swing.JMapPaneExamples

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geotools.swing;

import org.geotools.geometry.DirectPosition2D;
import org.geotools.swing.event.MapMouseAdapter;
import org.geotools.swing.event.MapMouseEvent;

/**
*
* @author michael
*/
public class JMapPaneExamples {

void listenForClicks(JMapPane myMapPane) {
    // mouselistener start
    myMapPane.addMouseListener(new MapMouseAdapter() {

        @Override
        public void onMouseClicked(MapMouseEvent ev) {
            // print the screen and world position of the mouse
            System.out.println("mouse click at");
            System.out.printf("  screen: x=%d y=%d \n", ev.getX(), ev.getY());

            DirectPosition2D pos = ev.getWorldPos();
            System.out.printf("  world: x=%.2f y=%.2f \n", pos.x, pos.y);
        }

        @Override
        public void onMouseEntered(MapMouseEvent ev) {
            System.out.println("mouse entered map pane");
        }

        @Override
        public void onMouseExited(MapMouseEvent ev) {
            System.out.println("mouse left map pane");
        }
    });    
    // mouselistener end
}

}
TOP

Related Classes of org.geotools.swing.JMapPaneExamples

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.