Java Code Examples for javafx.scene.input.MouseEvent#MOUSE_RELEASED

The following examples show how to use javafx.scene.input.MouseEvent#MOUSE_RELEASED . 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: HeatControlSkin.java    From Enzo with Apache License 2.0 6 votes vote down vote up
private void handleMouseEvent(final MouseEvent MOUSE_EVENT) {
    final Object    SRC  = MOUSE_EVENT.getSource();
    final EventType TYPE = MOUSE_EVENT.getEventType();
    if (SRC.equals(targetIndicator)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {    
            userAction = true;
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getTarget()));
            resizeText();                
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            touchRotate(MOUSE_EVENT.getSceneX() - getSkinnable().getLayoutX(), MOUSE_EVENT.getSceneY() - getSkinnable().getLayoutY(), targetIndicatorRotate);                
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {                
            getSkinnable().setTarget(Double.parseDouble(newTarget));
            fadeBack();
        }
    }
}
 
Example 2
Source File: Switch.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
public Switch() {
    getStylesheets().add(Switch.class.getResource("switch.css").toExternalForm());
    aspectRatio      = PREFERRED_HEIGHT / PREFERRED_WIDTH;
    _active          = false;
    _activeColor     = Tile.BLUE;
    _foregroundColor = Tile.FOREGROUND;
    _backgroundColor = Tile.BACKGROUND;

    mouseEventHandler = e -> {
        final EventType TYPE = e.getEventType();
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            setActive(!isActive());
            fireEvent(SWITCH_PRESSED);
        } else if(MouseEvent.MOUSE_RELEASED == TYPE) {
            fireEvent(SWITCH_RELEASED);
        }
    };
    selectedListener = o -> moveThumb();

    timeline = new Timeline();

    initGraphics();
    registerListeners();
}
 
Example 3
Source File: PointerEventHandler.java    From jfxvnc with Apache License 2.0 6 votes vote down vote up
private void sendMouseEvents(MouseEvent event) {

    xPosProperty.set((int) Math.floor(event.getX() / zoomLevel));
    yPosProperty.set((int) Math.floor(event.getY() / zoomLevel));

    byte buttonMask = 0;
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
      if (event.isMiddleButtonDown()) {
        buttonMask = 2;
      } else if (event.isSecondaryButtonDown()) {
        buttonMask = 4;
      } else {
        buttonMask = 1;
      }
      fire(new PointerEvent(buttonMask, xPosProperty.get(), yPosProperty.get()));
    } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED || event.getEventType() == MouseEvent.MOUSE_MOVED) {
      buttonMask = 0;
    }

    fire(new PointerEvent(buttonMask, xPosProperty.get(), yPosProperty.get()));

  }
 
Example 4
Source File: OverviewPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(final MouseEvent t) {
    if (t.getEventType() == MouseEvent.MOUSE_MOVED) {
        handleResizing(t);
    } else if (t.getEventType() == MouseEvent.MOUSE_PRESSED) {
        origin = t.getX(); // Set the origin on all mouse presses.

        handleResizing(t);
    } else if (t.getEventType() == MouseEvent.MOUSE_RELEASED) {
        handleRelease(t);
    } else if (t.getEventType() == MouseEvent.MOUSE_DRAGGED) {
        handleDragging(t);
    }
}
 
Example 5
Source File: CardAppleMouse.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
private void processMouseEvent(MouseEvent event) {
    if (event.getEventType() == MouseEvent.MOUSE_MOVED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
        Node source = (Node) event.getSource();
        updateLocation(event.getSceneX(), event.getSceneY(), source.getBoundsInLocal());
        event.consume();
    }
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
        mousePressed(event);
        event.consume();
    } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
        mouseReleased(event);
        event.consume();
    }
}
 
Example 6
Source File: UICanvas.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
@Override
public void handle(MouseEvent event) {
	MouseButton btn = event.getButton();
	if (!(event.getTarget() instanceof Canvas)) {
		return;
	}

	Canvas c = (Canvas) event.getTarget();
	Point2D p = c.sceneToLocal(event.getSceneX(), event.getSceneY());
	int mousex = (int) p.getX();
	int mousey = (int) p.getY();

	if (event.getEventType() == MouseEvent.MOUSE_MOVED || event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
		canvas.mouseMoved(mousex, mousey);
		canvas.setLastMousePosition(mousex, mousey);
		if (mouseDown) {
			this.canvas.requestPaint();
		}
	} else {
		if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
			mouseDown = true;
			canvas.mousePressed(mousex, mousey, btn);
		} else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
			canvas.mouseReleased(mousex, mousey, btn);
			mouseDown = false;
			canvas.requestPaint();
		}
	}

}
 
Example 7
Source File: InteractiveGaugeSkin.java    From medusademo with Apache License 2.0 5 votes vote down vote up
public void handleMouseEvent(final MouseEvent EVENT) {
    if (getSkinnable().isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        getSkinnable().fireEvent(getSkinnable().BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        getSkinnable().fireEvent(getSkinnable().BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}
 
Example 8
Source File: HSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}
 
Example 9
Source File: QuarterSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}
 
Example 10
Source File: VSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}
 
Example 11
Source File: GaugeSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED == TYPE) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        drawKnob(true);
    } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        drawKnob(false);
    }
}
 
Example 12
Source File: GaugeSkin.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private void handleMouseEvent(final MouseEvent MOUSE_EVENT) {
    final Object    SRC  = MOUSE_EVENT.getSource();
    final EventType TYPE = MOUSE_EVENT.getEventType();
    if (getSkinnable().isInteractive() && SRC.equals(threshold)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Threshold");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            touchRotate(MOUSE_EVENT.getSceneX() - getSkinnable().getLayoutX(), MOUSE_EVENT.getSceneY() - getSkinnable().getLayoutY(), thresholdRotate);
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC instanceof Marker) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText(((Marker) SRC).getText());
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            touchRotate(MOUSE_EVENT.getSceneX() - getSkinnable().getLayoutX(), MOUSE_EVENT.getSceneY() - getSkinnable().getLayoutY(), getSkinnable().getMarkers().get(SRC));
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(minMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Min");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(maxMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Max");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}
 
Example 13
Source File: RadialBargraphSkin.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private void handleMouseEvent(final MouseEvent MOUSE_EVENT) {
    final Object    SRC  = MOUSE_EVENT.getSource();
    final EventType TYPE = MOUSE_EVENT.getEventType();
    if (getSkinnable().isInteractive() && SRC.equals(threshold)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Threshold");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getThreshold()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            touchRotate(MOUSE_EVENT.getSceneX() - getSkinnable().getLayoutX(), MOUSE_EVENT.getSceneY() - getSkinnable().getLayoutY(), thresholdRotate);
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            getSkinnable().setThreshold(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC instanceof Marker) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText(((Marker) SRC).getText());
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", ((Marker) SRC).getValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_DRAGGED == TYPE) {
            touchRotate(MOUSE_EVENT.getSceneX() - getSkinnable().getLayoutX(), MOUSE_EVENT.getSceneY() - getSkinnable().getLayoutY(), getSkinnable().getMarkers().get(SRC));
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            ((Marker) SRC).setValue(Double.parseDouble(value.getText()));
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(minMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Min");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    } else if (getSkinnable().isInteractive() && SRC.equals(maxMeasuredValue)) {
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            unit.setText("Max");
            value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMaxMeasuredValue()));
            resizeText();
        } else if (MouseEvent.MOUSE_RELEASED == TYPE) {
            fadeBackToInteractive();
        }
    }
}
 
Example 14
Source File: SwitchTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    mouseEventHandler = e -> {
        if (!tile.isInteractive()) { return; }
        final EventType TYPE = e.getEventType();
        if (MouseEvent.MOUSE_PRESSED == TYPE) {
            tile.setActive(!tile.isActive());
            tile.fireEvent(SWITCH_PRESSED);
        } else if(MouseEvent.MOUSE_RELEASED == TYPE) {
            tile.fireEvent(SWITCH_RELEASED);
        }
    };
    selectedListener = o -> moveThumb();

    timeline = new Timeline();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setWrapText(true);
    description.setTextFill(tile.getTextColor());
    Helper.enableNode(description, !tile.getDescription().isEmpty());

    switchBorder = new Rectangle();

    switchBackground = new Rectangle();
    switchBackground.setMouseTransparent(true);
    switchBackground.setFill(tile.isActive() ? tile.getActiveColor() : tile.getBackgroundColor());

    thumb = new Circle();
    thumb.setMouseTransparent(true);
    thumb.setEffect(shadow);

    getPane().getChildren().addAll(titleText, text, description, switchBorder, switchBackground, thumb);
}
 
Example 15
Source File: GUIConsoleInput.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new GUI console input.
 *
 * @param area GUI text area
 */
public GUIConsoleInput(InlineCssTextArea area) {
  this.area = area;
  initialPos = -1;
  inputText = null;
  area.setEditable(false);
  queue = new ArrayBlockingQueue<>(1);
  listener = new EventHandler<KeyEvent>() {
    @Override
    public void handle(KeyEvent e) {
      switch (e.getCode()) {
        case UP:
        case KP_UP:
        case PAGE_UP:
          area.moveTo(initialPos);
          e.consume();
          break;
        case DOWN:
        case KP_DOWN:
        case PAGE_DOWN:
          area.moveTo(area.getLength());
          e.consume();
          break;
        // ensure always that caret position is >= initialPos
        case LEFT:
        case KP_LEFT:
        case BACK_SPACE:
          if (area.getCaretPosition() == initialPos)
            e.consume();
          break;
        // return user response
        case ENTER:
          // after user release enter key return response
          if (e.getEventType() == KeyEvent.KEY_RELEASED)
            returnResponse();
          break;
        // nothing
        default:
          // change area input color
          if (initialPos < area.getLength()) {
            area.setStyle(initialPos, area.getLength(), "-fx-fill: #4a148c;");
          }
          break;
      }
    }
  };
  mouseListener = new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent e) {
      EventType<? extends MouseEvent> type = e.getEventType();
      // disable mouse selection
      if (type == MouseEvent.DRAG_DETECTED || type == MouseEvent.MOUSE_DRAGGED)
        e.consume();
      // control caret position
      if (type == MouseEvent.MOUSE_CLICKED || type == MouseEvent.MOUSE_RELEASED || type == MouseEvent.MOUSE_PRESSED) {
        if (e.getButton() == MouseButton.PRIMARY) {
          if (area.getCaretPosition() < initialPos) {
            area.setDisable(true);
            area.moveTo(initialPos);
            area.setDisable(false);
          }
        } else {
          e.consume();
        }
      }
    }
  };
  stopListener = new ChangeListener<Boolean>() {
    @Override
    public void changed(ObservableValue obs, Boolean oldValue, Boolean newValue) {
      if (!newValue) {
        returnResponse();
      }
    }
  };
}
 
Example 16
Source File: ImagePanel.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void handle(MouseEvent e) {
    if (e.getEventType() == MouseEvent.MOUSE_PRESSED) {
        requestFocus();
        if (new_rectangle_is_being_drawn == false) {
            starting_point_x = e.getX();
            starting_point_y = e.getY();
            newRect = new Annotation();
            newRect.setFill(SELECTED_ANNOTATION_COLOR);
            new_rectangle_is_being_drawn = true;
            anchorPane.getChildren().add(newRect);
        }
    }
    if (e.getEventType() == MouseEvent.MOUSE_DRAGGED) {
        if (!edit) {
            return;
        }
        if (new_rectangle_is_being_drawn == true) {
            double current_ending_point_x = e.getX();
            double current_ending_point_y = e.getY();
            if (current_ending_point_x < 0) {
                current_ending_point_x = 0;
            }
            if (current_ending_point_y < 0) {
                current_ending_point_y = 0;
            }
            if (current_ending_point_x > canvas.getWidth()) {
                current_ending_point_x = canvas.getWidth();
            }
            if (current_ending_point_y > canvas.getHeight()) {
                current_ending_point_y = canvas.getHeight();
            }

            adjust_rectangle_properties(starting_point_x, starting_point_y, current_ending_point_x, current_ending_point_y,
                    newRect);
            ensureVisible(scrollPane, newRect);
        }
    }
    if (e.getEventType() == MouseEvent.MOUSE_RELEASED) {
        anchorPane.getChildren().remove(newRect);
        newRect.setFill(ANNOTATION_COLOR);
        newRect.setText("Annotation");
        if (newRect.getWidth() > 10 && newRect.getHeight() > 10) {
            System.out.println("ImagePanel.ImagePanelMouseListener.handle(" + newRect + ")");
            annotations.add(newRect);
        }
        drawGraphics();
        newRect = null;
        new_rectangle_is_being_drawn = false;
    }
}
 
Example 17
Source File: SwitchTileSkin.java    From OEE-Designer with MIT License 4 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override protected void initGraphics() {
       super.initGraphics();

       mouseEventHandler = e -> {
           final EventType TYPE = e.getEventType();
           if (MouseEvent.MOUSE_PRESSED == TYPE) {
               tile.setActive(!tile.isActive());
               tile.fireEvent(SWITCH_PRESSED);
           } else if(MouseEvent.MOUSE_RELEASED == TYPE) {
               tile.fireEvent(SWITCH_RELEASED);
           }
       };
       selectedListener = o -> moveThumb();

       timeline = new Timeline();

       titleText = new Text();
       titleText.setFill(tile.getTitleColor());
       Helper.enableNode(titleText, !tile.getTitle().isEmpty());

       text = new Text(tile.getText());
       text.setFill(tile.getUnitColor());
       Helper.enableNode(text, tile.isTextVisible());

       description = new Label(tile.getDescription());
       description.setAlignment(tile.getDescriptionAlignment());
       description.setWrapText(true);
       description.setTextFill(tile.getTextColor());
       Helper.enableNode(description, !tile.getDescription().isEmpty());

       switchBorder = new Rectangle();

       switchBackground = new Rectangle();
       switchBackground.setMouseTransparent(true);
       switchBackground.setFill(tile.isActive() ? tile.getActiveColor() : tile.getBackgroundColor());

       thumb = new Circle();
       thumb.setMouseTransparent(true);
       thumb.setEffect(shadow);

       getPane().getChildren().addAll(titleText, text, description, switchBorder, switchBackground, thumb);
   }