Important note: this function returns correct results only if the Polygon has been drawn before,
and if the MapView positioning has not changed.
@param event
@return true if the Polygon contains the event position.
543890
public boolean contains(MotionEvent event){
		if (mPath.isEmpty())
			return false;
		RectF bounds = new RectF(); //bounds of the Path
		mPath.computeBounds(bounds, true);
		Region region = new Region();
		//Path has been computed in #draw (we assume that if it can be clicked, it has been drawn before). 
		region.setPath(mPath, new Region((int)bounds.left, (int)bounds.top, 
				(int) (bounds.right), (int) (bounds.bottom)));
		return region.contains((int)event.getX(), (int)event.getY());
	}
1116366
public boolean isExpected(final HandlingEvent event) {
		if (getLegs().isEmpty()) {
			return true;
		}

		if (event.getType() == Type.RECEIVE) {
			// Check that the first leg's origin is the event's location
			final Leg leg = getLegs().get(0);
			return (leg.getFrom().equals(event.getLocation()));
		}

		if (event.getType() == Type.LOAD) {
			// Check that the there is one leg with same from location and
			// carrier movement
			for (Leg leg : getLegs()) {
				if (leg.getFrom().equals(event.getLocation())
						&& leg.getCarrierMovement().equals(
								event.getCarrierMovement()))
					return true;
			}
			return false;
		}

		if (event.getType() == Type.UNLOAD) {
			// Check that the there is one leg with same to loc and carrier
			// movement
			for (Leg leg : getLegs()) {
				if (leg.getTo().equals(event.getLocation())
						&& leg.getCarrierMovement().equals(
								event.getCarrierMovement()))
					return true;
			}
			return false;
		}

		if (event.getType() == Type.CLAIM) {
			// Check that the last leg's destination is from the event's
			// location
			final Leg leg = getLegs().get(getLegs().size() - 1);
			return (leg.getTo().equals(event.getLocation()));
		}

		// HandlingEvent.Type.CUSTOMS;
		return true;
	}
528347
public void onGeometrySplitStart(GeometrySplitStartEvent event) {
		setDisabled(false);

		for (GfxGeometry gfx : splitResult) {
			mapWidget.unregisterWorldPaintable(gfx);
		}
		splitResult.clear();
	}
849117
function (event) {
        var offset = this.offset ()
        var pt = {
            x: event.clientX - offset.left,
            y: event.clientY - offset.top }
        return (pt.x >= 0) && (pt.y >= 0) && (pt.x < $(this).width ()) && (pt.y < $(this).height ()) }
328756
@Override
	public void onMapTouchEnd(TouchEvent<?> event) {
		onUp(event);
		event.stopPropagation();
		event.preventDefault();
	}
724127
function (event) {
        var x = event.gameScreenX + (event.width / 2);
        var y = event.gameScreenY + (event.height / 2);
        this.setOpacity(0.50);
        this.checkDirection.call(this, x, y);
        return false;
    }
868919
public void onGeometryEditMove(GeometryEditMoveEvent event) {
		// Find the elements that need updating:
		Map<GeometryIndex, Boolean> indicesToUpdate = new HashMap<GeometryIndex, Boolean>();
		for (GeometryIndex index : event.getIndices()) {
			if (!indicesToUpdate.containsKey(index)) {
				indicesToUpdate.put(index, false);
				if (!Geometry.POINT.equals(editService.getGeometry().getGeometryType())
						&& !Geometry.MULTI_POINT.equals(editService.getGeometry().getGeometryType())) {
					try {
						List<GeometryIndex> neighbors;
						switch (editService.getIndexService().getType(index)) {
							case TYPE_VERTEX:
								// Move current vertex to the back. This helps the delete operation.
								indicesToUpdate.put(index, true);
								neighbors = editService.getIndexService().getAdjacentEdges(event.getGeometry(), index);
								if (neighbors != null) {
									for (GeometryIndex neighborIndex : neighbors) {
										if (!indicesToUpdate.containsKey(neighborIndex)) {
											indicesToUpdate.put(neighborIndex, false);
										}
									}
								}

								neighbors = editService.getIndexService().getAdjacentVertices(event.getGeometry(),
										index);
								if (neighbors != null) {
									for (GeometryIndex neighborIndex : neighbors) {
										if (!indicesToUpdate.containsKey(neighborIndex)) {
											indicesToUpdate.put(neighborIndex, false);
										}
									}
								}
								break;
							case TYPE_EDGE:
								neighbors = editService.getIndexService().getAdjacentVertices(event.getGeometry(),
										index);
								if (neighbors != null) {
									for (GeometryIndex neighborIndex : neighbors) {
										if (!indicesToUpdate.containsKey(neighborIndex)) {
											indicesToUpdate.put(neighborIndex, false);
										}
									}
								}
								break;
							default:
						}
					} catch (GeometryIndexNotFoundException e) {
						throw new IllegalStateException(e);
					}
				}
			}
		}

		// Check if we need to draw the background (nice, but slows down):
		if (styleProvider.getBackgroundStyle() != null && styleProvider.getBackgroundStyle().getFillOpacity() > 0) {
			if (event.getGeometry().getGeometryType().equals(Geometry.POLYGON)) {
				update(null, false);
			} else if (event.getGeometry().getGeometryType().equals(Geometry.MULTI_POLYGON)
					&& event.getGeometry().getGeometries() != null) {
				for (int i = 0; i < event.getGeometry().getGeometries().length; i++) {
					GeometryIndex index = editService.getIndexService().create(GeometryIndexType.TYPE_GEOMETRY, i);
					indicesToUpdate.put(index, false);
				}
			}
		}

		// Next, redraw the list:
		for (GeometryIndex index : indicesToUpdate.keySet()) {
			update(index, indicesToUpdate.get(index));
		}
	}
1104002
public void onGeometryEditStart(GeometryEditStartEvent event) {
		String geometryType = service.getGeometry().getGeometryType();
		if (Geometry.LINEAR_RING.equals(geometryType) || Geometry.POLYGON.equals(geometryType)
				|| Geometry.MULTI_POLYGON.equals(geometryType)) {
			setDisabled(false);
		}
	}
880893
public void onMouseUp(ListenerEvent event) {
		if (clickstart && !dragging) {
			Coordinate worldPosition = event.getWorldPosition();
			Point point = mapWidget.getMapModel().getGeometryFactory().createPoint(worldPosition);

			SearchByLocationRequest request = new SearchByLocationRequest();
			request.setLocation(GeometryConverter.toDto(point));
			request.setCrs(mapWidget.getMapModel().getCrs());
			request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
			request.setSearchType(SearchByLocationRequest.SEARCH_ALL_LAYERS);
			request.setBuffer(calculateBufferFromPixelTolerance());
			request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
			
			for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
				if (layer.isShowing() && layer instanceof VectorLayer  && !layersToExclude.contains(layer.getId())) {
					request.addLayerWithFilter(layer.getId(), layer.getServerLayerId(),
							((VectorLayer) layer).getFilter());
				}
			}
			final SearchByPointRequest rasterLayerRequest = new SearchByPointRequest();
			rasterLayerRequest.setLocation(point.getCoordinate());
			rasterLayerRequest.setCrs(mapWidget.getMapModel().getCrs());
			rasterLayerRequest.setSearchType(SearchByPointRequest.SEARCH_ALL_LAYERS);
			rasterLayerRequest.setPixelTolerance(pixelTolerance);
			final Map<String, String> rasterLayerIds = new HashMap<String, String>();
			for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
				if (layer.isShowing() && layer instanceof RasterLayer && !layersToExclude.contains(layer.getId())) {
					rasterLayerIds.put(layer.getId(), layer.getServerLayerId());
				}
			}
			rasterLayerRequest.setLayerMapping(rasterLayerIds);
			rasterLayerRequest.setBbox(toBbox(mapWidget.getMapModel().getMapView().getBounds()));
			rasterLayerRequest.setScale(mapWidget.getMapModel().getMapView().getCurrentScale());

			GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
			commandRequest.setCommandRequest(request);
			// TODO: commands are now chained. Perhaps we should combine this
			// into a single command?
			GwtCommandDispatcher.getInstance().execute(commandRequest, 
								new AbstractCommandCallback<SearchByLocationResponse>() {
				public void execute(final SearchByLocationResponse vectorResponse) {
					if (includeRasterLayers) {
						GwtCommand commandRequest = new GwtCommand(SearchByPointRequest.COMMAND);
						commandRequest.setCommandRequest(rasterLayerRequest);
						GwtCommandDispatcher.getInstance().execute(commandRequest,
								new AbstractCommandCallback<SearchByPointResponse>() {
									public void execute(final SearchByPointResponse rasterResponse) {
										//Featuremap maps client layer on feature
										Map<String, List<org.geomajas.layer.feature.Feature>> featureMap = 
											vectorResponse.getFeatureMap();
										featureMap.putAll(rasterResponse.getFeatureMap());
										showFeatureInfo(featureMap);
									}
								});

					} else {
						showFeatureInfo(vectorResponse.getFeatureMap());
					}
				}
			});

		} else {
			dragging = false;
		}
		clickstart = false;
	}
291411
@Override
	public void onDown(HumanInputEvent<?> event) {
		if (dragging && leftWidget) {
			// mouse was moved outside of widget
			doSelect(event);

		} else if (!isRightMouseButton(event)) {
			// no point trying to select when there is no active layer
			dragging = true;
			leftWidget = false;
			timestamp = new Date().getTime();
			begin = getLocation(event, RenderSpace.SCREEN);
			bounds = new Bbox(begin.getX(), begin.getY(), 0.0, 0.0);
			shift = event.isShiftKeyDown();
			rectangle = new Rectangle("selectionRectangle");
			rectangle.setStyle(rectangleStyle);
			rectangle.setBounds(bounds);
			mapWidget.render(rectangle, RenderGroup.SCREEN, RenderStatus.UPDATE);
		}
	}
786480
public void onCoordinateSnapAttempt(CoordinateSnapEvent event) {
		if (editingService.getEditingState() == GeometryEditState.INSERTING) {
			String identifier = baseName + "."
					+ editingService.getIndexService().format(editingService.getInsertIndex());
			Object parentGroup = groups.get(identifier.substring(0, identifier.lastIndexOf('.')) + ".vertices");

			Coordinate temp = event.getTo();
			Coordinate coordinate = mapWidget.getMapModel().getMapView().getWorldViewTransformer().worldToPan(temp);
			addShapeToGraphicsContext(mapWidget.getVectorContext(), parentGroup, identifier, coordinate,
					event.hasSnapped() ? styleService.getVertexSnappedStyle() : new ShapeStyle());
		}
	}
106833
public void onGeometryIndexHighlightBegin(GeometryIndexHighlightBeginEvent event) {
		for (GeometryIndex index : event.getIndices()) {
			update(event.getGeometry(), index, false);
		}
	}
644712
function (event) {
        if (this.released === false) {
            var x = event.gameScreenX + (event.width / 2);
            var y = event.gameScreenY + (event.height / 2);
            // pointerMove is a global on the viewport, so check for coordinates
            if (this.getBounds().containsPoint(x, y)) {
                // if any direction is active, update it if necessary
                if (this.cursors.left === true || this.cursors.right === true) {
                    this.checkDirection.call(this, x, y);
                }
            } else {
                // release keys/joypad if necessary
                this.onRelease.call(this, event);
            }
        }
    }
1232161
public void onChangeEditingState(GeometryEditChangeStateEvent event) {
		switch (event.getEditingState()) {
			case DRAGGING:
				mapPresenter.setCursor("move");
				break;
			case IDLE:
			default:
				mapPresenter.setCursor("default");
				redraw();
		}
	}
464737
public void onGeometryIndexDisabled(GeometryIndexDisabledEvent event) {
		for (GeometryIndex index : event.getIndices()) {
			update(event.getGeometry(), index, false);
		}
	}
746972
@Override
    public boolean onTouchEvent(MotionEvent event) {
        if (!isEnabled())
            return false;

        float v = (value - min) / (max - min);
        float v2 = (value2 - min) / (max - min);

        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            int thumbX = (int) (v * (getWidth() - getPaddingLeft() - getPaddingRight() - thumbRadius * 2) + getPaddingLeft() + thumbRadius);
            int thumbX2 = (int) (v2 * (getWidth() - getPaddingLeft() - getPaddingRight() - thumbRadius2 * 2) + getPaddingLeft() + thumbRadius2);
            if (Math.abs(event.getX() - thumbX) < Math.abs(event.getX() - thumbX2)) {
                draggedThumb = 1;
                if (radiusAnimator != null)
                    radiusAnimator.end();
                radiusAnimator = ValueAnimator.ofFloat(thumbRadius, THUMB_RADIUS_DRAGGED);
                radiusAnimator.setDuration(200);
                radiusAnimator.setInterpolator(interpolator);
                radiusAnimator.addUpdateListener(animation -> {
                    thumbRadius = (float) animation.getAnimatedValue();
                    postInvalidate();
                });
                radiusAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        radiusAnimator = null;
                    }
                });
                radiusAnimator.start();
            } else {
                draggedThumb = 2;
                if (radiusAnimator != null)
                    radiusAnimator.end();
                radiusAnimator = ValueAnimator.ofFloat(thumbRadius2, THUMB_RADIUS_DRAGGED);
                radiusAnimator.setDuration(200);
                radiusAnimator.setInterpolator(interpolator);
                radiusAnimator.addUpdateListener(animation -> {
                    thumbRadius2 = (float) animation.getAnimatedValue();
                    postInvalidate();
                });
                radiusAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        radiusAnimator = null;
                    }
                });
                radiusAnimator.start();
            }
            ViewParent parent = getParent();
            if (parent != null)
                parent.requestDisallowInterceptTouchEvent(true);
            if (showLabel)
                popup.show(this);
        } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) {
            if (draggedThumb == 1) {
                if (style == Style.Discrete) {
                    float val = (float) Math.floor((value - min + step / 2) / step) * step + min;
                    if (valueAnimator != null)
                        valueAnimator.cancel();
                    valueAnimator = ValueAnimator.ofFloat(value, val);
                    valueAnimator.setDuration(200);
                    valueAnimator.setInterpolator(interpolator);
                    valueAnimator.addUpdateListener(animation -> {
                        value = (float) animation.getAnimatedValue();
                        int thumbX = (int) ((value - min) / (max - min) * (getWidth() - getPaddingLeft() - getPaddingRight()) + getPaddingLeft());
                        int thumbY = getHeight() / 2;
                        int radius = rippleDrawable.getRadius();
                        rippleDrawable.setBounds(thumbX - radius, thumbY - radius, thumbX + radius, thumbY + radius);
                        postInvalidate();
                    });
                    valueAnimator.start();
                }
                if (radiusAnimator != null)
                    radiusAnimator.end();
                radiusAnimator = ValueAnimator.ofFloat(thumbRadius, THUMB_RADIUS);
                radiusAnimator.setDuration(200);
                radiusAnimator.setInterpolator(interpolator);
                radiusAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        thumbRadius = (float) animation.getAnimatedValue();
                        postInvalidate();
                    }
                });
                radiusAnimator.start();
            } else {
                if (style == Style.Discrete) {
                    float val2 = (float) Math.floor((value2 - min + step / 2) / step) * step + min;
                    if (valueAnimator != null)
                        valueAnimator.cancel();
                    valueAnimator = ValueAnimator.ofFloat(value2, val2);
                    valueAnimator.setDuration(200);
                    valueAnimator.setInterpolator(interpolator);
                    valueAnimator.addUpdateListener(animation -> {
                        value2 = (float) animation.getAnimatedValue();
                        int thumbX = (int) ((value2 - min) / (max - min) * (getWidth() - getPaddingLeft() - getPaddingRight()) + getPaddingLeft());
                        int thumbY = getHeight() / 2;
                        int radius = rippleDrawable.getRadius();
                        rippleDrawable.setBounds(thumbX - radius, thumbY - radius, thumbX + radius, thumbY + radius);
                        postInvalidate();
                    });
                    valueAnimator.start();
                }
                if (radiusAnimator != null)
                    radiusAnimator.end();
                radiusAnimator = ValueAnimator.ofFloat(thumbRadius2, THUMB_RADIUS);
                radiusAnimator.setDuration(200);
                radiusAnimator.setInterpolator(interpolator);
                radiusAnimator.addUpdateListener(animation -> {
                    thumbRadius2 = (float) animation.getAnimatedValue();
                    postInvalidate();
                });
                radiusAnimator.start();
            }
            //draggedThumb = -1;
            ViewParent parent = getParent();
            if (parent != null)
                parent.requestDisallowInterceptTouchEvent(false);
            if (showLabel)
                popup.dismiss();
        }

        if (draggedThumb == 1) {
            v = (event.getX() - getPaddingLeft()) / (getWidth() - getPaddingLeft() - getPaddingRight());
            v = Math.max(0, Math.min(v, 1));
        } else if (draggedThumb == 2) {
            v2 = (event.getX() - getPaddingLeft()) / (getWidth() - getPaddingLeft() - getPaddingRight());
            v2 = Math.max(0, Math.min(v2, 1));
        }

        if (v > v2) {
            draggedThumb = 3 - draggedThumb;
            float t = v;
            v = v2;
            v2 = t;
            t = thumbRadius;
            thumbRadius = thumbRadius2;
            thumbRadius2 = t;
        }
        float newValue = v * (max - min) + min;
        float newValue2 = v2 * (max - min) + min;

        int thumbX = 0;
        if (draggedThumb == 1) {
            thumbX = (int) (v * (getWidth() - getPaddingLeft() - getPaddingRight()) + getPaddingLeft());
        } else if (draggedThumb == 2) {
            thumbX = (int) (v2 * (getWidth() - getPaddingLeft() - getPaddingRight()) + getPaddingLeft());
        }
        int thumbY = getHeight() / 2;
        int radius = rippleDrawable.getRadius();

        if (showLabel && draggedThumb > 0) {
            int[] location = new int[2];
            getLocationInWindow(location);
            popup.setText(String.format(labelFormat, draggedThumb == 1 ? newValue : newValue2));
            popup.update(thumbX + location[0] - popup.getBubbleWidth() / 2, thumbY - radius + location[1] - popup.getHeight());
        }

        if (rippleDrawable != null) {
            rippleDrawable.setHotspot(event.getX(), event.getY());
            rippleDrawable.setBounds(thumbX - radius, thumbY - radius, thumbX + radius, thumbY + radius);
        }

        postInvalidate();
        if ((newValue != value || newValue2 != value2) && onValueChangedListener != null) {
            if (style == Style.Discrete) {
                int sv = stepValue(newValue);
                int sv2 = stepValue(newValue2);
                if (stepValue(value) != sv || stepValue(value2) != sv2)
                    onValueChangedListener.onValueChanged(this, sv, sv2);
            } else {
                onValueChangedListener.onValueChanged(this, newValue, newValue2);
            }
        }
        value = newValue;
        value2 = newValue2;
        super.onTouchEvent(event);
        return true;
    }
23152
public void onDoubleClick(DoubleClickEvent event) {
		tempLength = 0;
		mapWidget.unregisterWorldPaintable(distanceLine);
		mapWidget.unregisterWorldPaintable(lineSegment);
		distanceLine.setGeometry(null);
		lineSegment.setGeometry(null);
		if (panel != null) {
			panel.destroy();
		}
		dispatchState(State.STOP);
	}