Search in sources :

Example 1 with CoordTransformer

use of aimax.osm.viewer.CoordTransformer in project aima-java by aimacode.

the class MapPaneCtrl method handleMouseEvent.

protected void handleMouseEvent(MouseEvent event) {
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
        xDrag = event.getX();
        yDrag = event.getY();
        dragActive = false;
    } else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
        adjust(event.getX() - xDrag, event.getY() - yDrag);
        xDrag = event.getX();
        yDrag = event.getY();
        dragActive = true;
    } else if (event.getEventType() == MouseEvent.MOUSE_CLICKED && !dragActive) {
        if (event.getButton() == MouseButton.PRIMARY) {
            CoordTransformer tr = getTransformer();
            getMap().addMarker(tr.lat((int) event.getY()), tr.lon((int) event.getX()));
        } else if (event.getButton() == MouseButton.SECONDARY) {
            getMap().clearMarkersAndTracks();
        } else if (event.getButton() == MouseButton.MIDDLE) {
            MapNode mNode = getRenderer().getNextNode((int) event.getX(), (int) event.getY());
            if (mNode != null)
                showMapEntityInfoDialog(mNode, true);
        }
    }
    // hack...
    currCanvas.requestFocus();
}
Also used : CoordTransformer(aimax.osm.viewer.CoordTransformer) MapNode(aimax.osm.data.entities.MapNode)

Aggregations

MapNode (aimax.osm.data.entities.MapNode)1 CoordTransformer (aimax.osm.viewer.CoordTransformer)1