Java Code Examples for processing.event.MouseEvent#MOVE

The following examples show how to use processing.event.MouseEvent#MOVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 6 votes vote down vote up
public void checkMouseDragPoint(MouseEvent event) {
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		break;
	case MouseEvent.RELEASE:
		if(SELECTED_POINT != null) save();
		SELECTED_POINT = null;
		break;
	case MouseEvent.MOVE:
		checkMouseHoverPoint();
		break;
	case MouseEvent.DRAG:
		if( SELECTED_POINT != null ) {
			SELECTED_POINT.setLocation( mousePoint );
			updateCenter();
		}
		break;
	}
}
 
Example 2
Source File: MouseShutdown.java    From haxademic with MIT License 6 votes vote down vote up
public void mouseEvent(MouseEvent event) {
  // int x = event.getX();
  // int y = event.getY();

  switch (event.getAction()) {
    case MouseEvent.PRESS:
      break;
    case MouseEvent.RELEASE:
      break;
    case MouseEvent.CLICK:
    	click();
      break;
    case MouseEvent.DRAG:
      break;
    case MouseEvent.MOVE:
      break;
  }
}
 
Example 3
Source File: UIButton.java    From haxademic with MIT License 6 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	if(!isActive()) return;
	
	int mouseX = event.getX();
	int mouseY = event.getY();

	switch (event.getAction()) {
		case MouseEvent.PRESS:
			pressed = rect.contains(mouseX, mouseY);
			break;
		case MouseEvent.RELEASE:
			if(pressed && over) click();
			pressed = false;
			break;
		case MouseEvent.MOVE:
			over = rect.contains(mouseX, mouseY);
			break;
		case MouseEvent.DRAG:
			over = rect.contains(mouseX, mouseY);
			break;
	}
}
 
Example 4
Source File: UISlider.java    From haxademic with MIT License 6 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	if(isActive() == false) return;
	// collision detection
	mousePoint.setLocation(event.getX(), event.getY());
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		if(uiRect.contains(mousePoint)) mousePressed = true;
		break;
	case MouseEvent.RELEASE:
		if(mousePressed) {
			mousePressed = false;
			if(saves) PrefToText.setValue(id, value);
		}
		break;
	case MouseEvent.MOVE:
		mouseHovered = uiRect.contains(mousePoint);
		break;
	case MouseEvent.DRAG:
		if(mousePressed) {
			float deltaX = (P.p.mouseX - P.p.pmouseX) * dragStep;
			value += deltaX;
			value = P.constrain(value, valueMin, valueMax);
		}
		break;
	}
}
 
Example 5
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 5 votes vote down vote up
public void checkHoverQuad(MouseEvent event) {
	switch (event.getAction()) {
	case MouseEvent.MOVE:
		isHovered = inside(mousePoint, points);
		break;
	}
}
 
Example 6
Source File: SavedRectangle.java    From haxademic with MIT License 5 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	switch (event.getAction()) {
		case MouseEvent.PRESS:
			mouseStartPoint.setLocation( event.getX() + rectOffset.x, event.getY() + rectOffset.y );
			if(rectangle.contains(mouseStartPoint) && SavedRectangle.curDragging == null) {
				isDragging = true;
				SavedRectangle.curDragging = this;
				float cornerClickDist = (float) mouseStartPoint.distance(rectangle.x + rectangle.width, rectangle.y + rectangle.height);
				if(cornerClickDist < 15) {
					isResizing = true;
				} 
				rectangleMove = new Rectangle(rectangle); // build temp rectangle for moving
			}
			break;
		case MouseEvent.RELEASE:
			if(isDragging == true) {
				updateRectangle(rectangleMove);
				SavedRectangle.curDragging = null;
				rectangleMove = null;
				isDragging = false;
				isResizing = false;
			}
			break;
		case MouseEvent.MOVE:
			break;
		case MouseEvent.DRAG:
			if(isDragging == true) {
				mouseMovePoint.setLocation( event.getX() + rectOffset.x, event.getY() + rectOffset.y );
				int mouseDeltaX = mouseMovePoint.x - mouseStartPoint.x;
				int mouseDeltaY = mouseMovePoint.y - mouseStartPoint.y;
				if(isResizing == false) {
					rectangleMove.setLocation(rectangle.x + mouseDeltaX, rectangle.y + mouseDeltaY );
				} else {
					rectangleMove.setSize(rectangle.width + mouseDeltaX, rectangle.height + mouseDeltaY );
				}
			}
			break;
	}
}
 
Example 7
Source File: SavedPointUI.java    From haxademic with MIT License 5 votes vote down vote up
public void checkHover(MouseEvent event) {
	switch (event.getAction()) {
	case MouseEvent.MOVE:
		isHovered = (position.dist( mousePoint ) < mouseActiveDist);
		if(active && !isHovered) active = false;
		break;
	}
}
 
Example 8
Source File: DMXEditor.java    From haxademic with MIT License 5 votes vote down vote up
public void checkMouseDragPoint(MouseEvent event) {
	boolean createDragMode = P.store.getBoolean(DRAG_CREATE_MODE);
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		if(createDragMode && isHoveringPoint() == false) {
			// check points to see if one is hovered. cancel if so
			points.add(newPoint());
			draggingNewPoint = true;
		}
		break;
	case MouseEvent.RELEASE:
		// create a 2nd point on release
		if(createDragMode && draggingNewPoint) {
			points.add(newPoint());
			draggingNewPoint = false;
			lights.add(new LightBar(dmxUniverseDefault, dmxMode, points.get(points.size() - 2).position(), points.get(points.size() - 1).position())); // add last 2 points PVectors to new LightFixture
		}
		break;
	case MouseEvent.MOVE:
		// set hovered point as active
		boolean foundOne = false;
		for (int i = 0; i < points.size(); i++) {
			if(points.get(i).isHovered()) {
				pointIndex = i;
				foundOne = true;
			}
		}
		if(foundOne == false) pointIndex = -1;
		setActivePoint();
		break;
	case MouseEvent.DRAG:
		// if creating a new line, draw line from first point
		break;
	}
}
 
Example 9
Source File: UITextInput.java    From haxademic with MIT License 5 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	if(active == false) return;
	int mouseX = event.getX();
	int mouseY = event.getY();
	
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		pressed = rect.contains(mouseX,  mouseY);
		// if no textinputs are clicked, clear out ACTIVE_INPUT
		break;
	case MouseEvent.RELEASE:
		pressed = false;
		focused = rect.contains(mouseX, mouseY);
		ACTIVE_INPUT = null;
		if(focused) {
			SystemUtil.setTimeout(activeTimeout, 10);
		} else {
			if(saves) PrefToText.setValue(id, value);
		}
		break;
	case MouseEvent.MOVE:
		over = rect.contains(mouseX,  mouseY);
		break;
	case MouseEvent.DRAG:
		break;
	}
}