Import "views" plugins
[deliverable/tracecompass.git] / tmf / org.lttng.scope.tmf2.views.ui / src / org / lttng / scope / tmf2 / views / ui / jfx / examples / ArrowExample.java
1 package org.lttng.scope.tmf2.views.ui.jfx.examples;
2
3 import org.eclipse.jdt.annotation.Nullable;
4 import org.lttng.scope.tmf2.views.ui.jfx.Arrow;
5
6 import javafx.application.Application;
7 import javafx.scene.Scene;
8 import javafx.scene.layout.Pane;
9 import javafx.scene.paint.Color;
10 import javafx.stage.Stage;
11
12 public class ArrowExample extends Application {
13
14 public static void main(String[] args) {
15 launch(args);
16 }
17
18 @Override
19 public void start(@Nullable Stage primaryStage) throws Exception {
20 if (primaryStage == null) {
21 return;
22 }
23
24 Pane root = new Pane();
25 Arrow arrow = new Arrow();
26 arrow.setStroke(Color.GREEN);
27 root.getChildren().add(arrow);
28
29 root.setOnMouseClicked(evt -> {
30 switch (evt.getButton()) {
31 case PRIMARY:
32 // set pos of end with arrow head
33 arrow.setEndX(evt.getX());
34 arrow.setEndY(evt.getY());
35 break;
36 case SECONDARY:
37 // set pos of end without arrow head
38 arrow.setStartX(evt.getX());
39 arrow.setStartY(evt.getY());
40 break;
41 case MIDDLE:
42 case NONE:
43 default:
44 break;
45 }
46 });
47
48 Scene scene = new Scene(root, 400, 400);
49
50 primaryStage.setScene(scene);
51 primaryStage.show();
52 }
53
54 }
This page took 0.031491 seconds and 5 git commands to generate.