<commit_before>/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2003-2008, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.swt.event;

import java.awt.geom.AffineTransform;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.swt.SwtMapPane;

/**
 * A MouseEvent which contains methods to obtain coordinates in real world CoordinateSystem as well
 * as Screen Coordinates.
 * 
 * @author <NAME> (adapted from code by <NAME>)
 * @author <NAME> (www.hydrologis.com)
 * @since 2.6
 *
 *
 *
 * @source $URL$
 */
public final class MapMouseEvent {
    private static final long serialVersionUID = 3894658044662688321L;

    private DirectPosition2D geoCoords;

    private boolean isWheelEvent;

    private int wheelAmount;

    private final MouseEvent event;

    /**
     * Constructor. Calculates the map position of the mouse event.
     * 
     * @param pane the map pane sending this event.
     * @param event the mouse event.
     * @param isWheel if <code>true</code> then the event comes from the mouse wheel.
     */
    public MapMouseEvent( SwtMapPane pane, MouseEvent event, boolean isWheel ) {
        this.event = event;

        isWheelEvent = isWheel;
        if (!isWheel) {
            wheelAmount = 0;

            AffineTransform tr = pane.getScreenToWorldTransform();
            geoCoords = new DirectPosition2D(event.x, event.y);
            tr.transform(geoCoords, geoCoords);
            geoCoords.setCoordinateReferenceSystem(pane.getMapContent().getCoordinateReferenceSystem());
        } else {
            wheelAmount = 3;// event.getWheelRotation();
        }
    }

    /**
     * Indicates a mouse wheel event.
     * 
     * @return <code>true</code> if this a mouse wheel event<commit_msg>fix to get map position also in case of wheelevents<commit_after>/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2003-2008, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.swt.event;

import java.awt.geom.AffineTransform;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.swt.SwtMapPane;

/**
 * A MouseEvent which contains methods to obtain coordinates in real world CoordinateSystem as well
 * as Screen Coordinates.
 * 
 * @author <NAME> (adapted from code by <NAME>)
 * @author <NAME> (www.hydrologis.com)
 * @since 2.6
 *
 *
 *
 * @source $URL$
 */
public final class MapMouseEvent {
    private DirectPosition2D geoCoords;

    private boolean isWheelEvent;

    private int wheelAmount;

    private final MouseEvent event;

    /**
     * Constructor. Calculates the map position of the mouse event.
     * 
     * @param pane the map pane sending this event.
     * @param event the mouse event.
     * @param isWheel if <code>true</code> then the event comes from the mouse wheel.
     */
    public MapMouseEvent( SwtMapPane pane, MouseEvent event, boolean isWheel ) {
        this.event = event;
        isWheelEvent = isWheel;
        if (!isWheel) {
            wheelAmount = 0;
        } else {
            wheelAmount = event.count;
        }
        AffineTransform tr = pane.getScreenToWorldTransform();
        geoCoords = new DirectPosition2D(event.x, event.y);
        tr.transform(geoCoords, geoCoords);
        geoCoords.setCoordinateReferenceSystem(pane.getMapContent().getCoordinateReferenceSystem());
    }

    /**
     * Indicates a mouse wheel event.
     * 
     * @return <code>true</code> if this a mouse wheel event
{'fraction_non_alphanumeric': 0.08386683738796415, 'fraction_numerical': 0.011096884336320957, 'mean_word_length': 2.9025811823480434, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4743568', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1335, 'n_words': 465}