Пример #1
0
	/**
	 * method that will be called when mouse presses
	 * @param point , the point mouse press at
	 */
	public void onMousePress(Location point){
		lastpoint = point;
		if (isShown && mouse.contains(point)) {
			isGrabbed = true;
		} else {
			isGrabbed = false;
		}
		timer.reset();
		moved = false;
	}
Пример #2
0
	/**
	 * method that will be called when mouse drags
	 * @param point , the point mouse drag at
	 */
	public void onMouseDrag(Location point) {
		
		if (isGrabbed) {
			double xMovement = point.getX() - lastpoint.getX();
			double yMovement = point.getY() - lastpoint.getY();
			//get distance of movement
			
			mouse.move(xMovement, yMovement);
			lastpoint = point;
			moved = true;
		}
	}
Пример #3
0
	/**
	 * method that will be called when mouse releases
	 * @param point , the point mouse release at
	 */
	public void onMouseRelease(Location point) {
		isGrabbed = false;
		if(isShown && !moved &&
				timer.elapsedMilliseconds() >= FLIP_PRESS_THRESHOLD){
			if(mouse.inFace(point)){
				mouse.move((double)(CENTER_X - point.getX()),
						(double)(CENTER_Y - point.getY()));
			}
			else if(mouse.inLeftEar(point)){
				mouse.turnLeft();
			}
			else if(mouse.inRightEar(point)){
				mouse.turnRight();
			}
		}

	}
Пример #4
0
	/**
	 * method that will be called when mouse exits the boundary
	 * @param point , the point mouse exit at
	 */
	public void onMouseExit(Location point){
		if(isShown){
		mouse.removeFromCanvas();
		isShown = false;
		}
	}