當前位置: 首頁>>代碼示例>>Java>>正文


Java Circle.setOnMousePressed方法代碼示例

本文整理匯總了Java中javafx.scene.shape.Circle.setOnMousePressed方法的典型用法代碼示例。如果您正苦於以下問題:Java Circle.setOnMousePressed方法的具體用法?Java Circle.setOnMousePressed怎麽用?Java Circle.setOnMousePressed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.shape.Circle的用法示例。


在下文中一共展示了Circle.setOnMousePressed方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addLocation

import javafx.scene.shape.Circle; //導入方法依賴的package包/類
public void addLocation(final Location LOCATION) {
    double x = (LOCATION.getLongitude() + 180) * (PREFERRED_WIDTH / 360) + MAP_OFFSET_X;
    double y = (PREFERRED_HEIGHT / 2) - (PREFERRED_WIDTH * (Math.log(Math.tan((Math.PI / 4) + (Math.toRadians(LOCATION.getLatitude()) / 2)))) / (2 * Math.PI)) + MAP_OFFSET_Y;

    Circle locationIcon = new Circle(x, y, size * 0.01);
    locationIcon.setFill(null == LOCATION.getColor() ? getLocationColor() : LOCATION.getColor());

    StringBuilder tooltipBuilder = new StringBuilder();
    if (!LOCATION.getName().isEmpty()) tooltipBuilder.append(LOCATION.getName());
    if (!LOCATION.getInfo().isEmpty()) tooltipBuilder.append("\n").append(LOCATION.getInfo());
    String tooltipText = tooltipBuilder.toString();
    if (!tooltipText.isEmpty()) {
        Tooltip tooltip = new Tooltip(tooltipText);
        tooltip.setFont(Font.font(10));
        Tooltip.install(locationIcon, tooltip);
    }

    if (null != LOCATION.getMouseEnterHandler()) locationIcon.setOnMouseEntered(new WeakEventHandler<>(LOCATION.getMouseEnterHandler()));
    if (null != LOCATION.getMousePressHandler()) locationIcon.setOnMousePressed(new WeakEventHandler<>(LOCATION.getMousePressHandler()));
    if (null != LOCATION.getMouseReleaseHandler()) locationIcon.setOnMouseReleased(new WeakEventHandler<>(LOCATION.getMouseReleaseHandler()));
    if (null != LOCATION.getMouseExitHandler()) locationIcon.setOnMouseExited(new WeakEventHandler<>(LOCATION.getMouseExitHandler()));


    locations.put(LOCATION, locationIcon);
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:26,代碼來源:World.java

示例2: start

import javafx.scene.shape.Circle; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) {
    if (primaryStage == null) {
        return;
    }

    //Create Circles
    Circle circleRed = new Circle(50.0, Color.RED);
    circleRed.setCursor(Cursor.HAND);
    circleRed.setOnMousePressed(circleOnMousePressedEventHandler);
    circleRed.setOnMouseDragged(circleOnMouseDraggedEventHandler);

    Circle circleGreen = new Circle(50.0, Color.GREEN);
    circleGreen.setCursor(Cursor.MOVE);
    circleGreen.setCenterX(150);
    circleGreen.setCenterY(150);
    circleGreen.setOnMousePressed(circleOnMousePressedEventHandler);
    circleGreen.setOnMouseDragged(circleOnMouseDraggedEventHandler);

    Circle circleBlue = new Circle(50.0, Color.BLUE);
    circleBlue.setCursor(Cursor.CROSSHAIR);
    circleBlue.setTranslateX(300);
    circleBlue.setTranslateY(100);
    circleBlue.setOnMousePressed(circleOnMousePressedEventHandler);
    circleBlue.setOnMouseDragged(circleOnMouseDraggedEventHandler);

    Group root = new Group();
    root.getChildren().addAll(circleRed, circleGreen, circleBlue);

    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 400,350));

    primaryStage.setTitle("java-buddy");
    primaryStage.show();
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:36,代碼來源:ExampleMouseDrag.java

示例3: initMessageHandleActions

import javafx.scene.shape.Circle; //導入方法依賴的package包/類
public void initMessageHandleActions(MessageEdgeView edgeView){
    Circle circleHandle = edgeView.getCircleHandle();
    circleHandle.setOnMousePressed(event -> {
        if(tool == ToolEnum.SELECT){
            mode = Mode.DRAGGING;
            selectedEdges.add(edgeView);
            previousMoveX = event.getX();
            previousMoveY = event.getY();
            initMoveX = event.getX();
            initMoveY = event.getY();
        }
    });

    circleHandle.setOnMouseDragged(event -> {
        double offsetX =  (event.getX() - previousMoveX)*(1/drawPane.getScaleX());
        double offsetY = (event.getY() - previousMoveY)*(1/drawPane.getScaleY());
        previousMoveX = event.getX();
        previousMoveY = event.getY();
        if(mode == Mode.DRAGGING){
            MessageEdge edge = (MessageEdge)edgeView.getRefEdge();
            edge.setStartX(edge.getStartX() + offsetX);
            edge.setStartY(edge.getStartY() + offsetY);
        }
    });

    circleHandle.setOnMouseReleased(event -> {
        undoManager.add(new MoveMessageCommand((MessageEdge)edgeView.getRefEdge(), edgeView.getStartX() - initMoveX, edgeView.getStartY() - initMoveY));
        mode = Mode.NO_MODE;
        previousMoveX = 0;
        previousMoveY = 0;
    });
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:33,代碼來源:SequenceDiagramController.java

示例4: initializeHeadline

import javafx.scene.shape.Circle; //導入方法依賴的package包/類
private void initializeHeadline(final Component component) {
    final Label headline = (Label) lookup("#headline");
    final Circle indicator = (Circle) lookup("#indicator");
    final Line line = (Line) lookup("#line");

    line.setStroke(Color.GREY.getColor(Color.Intensity.I400));

    // This is an project wide message that is not specific to a component
    if(component == null) {
        headline.setText("Project");
        return;
    }

    headline.setText(component.getName());
    headline.textProperty().bind(component.nameProperty());

    final EventHandler<MouseEvent> onMouseEntered = event -> {
        setCursor(Cursor.HAND);
        headline.setStyle("-fx-underline: true;");
    };

    final EventHandler<MouseEvent> onMouseExited = event -> {
        setCursor(Cursor.DEFAULT);
        headline.setStyle("-fx-underline: false;");
    };

    final EventHandler<MouseEvent> onMousePressed = event -> {
        CanvasController.setActiveComponent(component);
    };

    headline.setOnMouseEntered(onMouseEntered);
    headline.setOnMouseExited(onMouseExited);
    headline.setOnMousePressed(onMousePressed);
    indicator.setOnMouseEntered(onMouseEntered);
    indicator.setOnMouseExited(onMouseExited);
    indicator.setOnMousePressed(onMousePressed);

    final BiConsumer<Color, Color.Intensity> updateColor = (color, intensity) -> {
        indicator.setFill(color.getColor(component.getColorIntensity()));
    };

    updateColor.accept(component.getColor(), component.getColorIntensity());
    component.colorProperty().addListener((observable, oldColor, newColor) -> updateColor.accept(newColor, component.getColorIntensity()));
}
 
開發者ID:ulriknyman,項目名稱:H-Uppaal,代碼行數:45,代碼來源:MessageCollectionPresentation.java


注:本文中的javafx.scene.shape.Circle.setOnMousePressed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。