示例#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;
		}
	}