1 package org
.eclipse
.tracecompass
.internal
.provisional
.tmf
.ui
.views
.timegraph2
.swtjfx
.examples
;
3 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
5 import javafx
.application
.Application
;
6 import javafx
.scene
.Group
;
7 import javafx
.scene
.Scene
;
8 import javafx
.scene
.canvas
.Canvas
;
9 import javafx
.scene
.canvas
.GraphicsContext
;
10 import javafx
.scene
.paint
.Color
;
11 import javafx
.scene
.shape
.ArcType
;
12 import javafx
.stage
.Stage
;
15 public class ExampleCanvas
extends Application
{
17 public static void main(String
[] args
) {
22 public void start(Stage primaryStage
) {
23 primaryStage
.setTitle("Drawing Operations Test");
24 Group root
= new Group();
25 Canvas canvas
= new Canvas(300, 250);
26 GraphicsContext gc
= canvas
.getGraphicsContext2D();
28 root
.getChildren().add(canvas
);
29 primaryStage
.setScene(new Scene(root
));
33 private static void drawShapes(GraphicsContext gc
) {
34 gc
.setFill(Color
.GREEN
);
35 gc
.setStroke(Color
.BLUE
);
37 gc
.strokeLine(40, 10, 10, 40);
38 gc
.fillOval(10, 60, 30, 30);
39 gc
.strokeOval(60, 60, 30, 30);
40 gc
.fillRoundRect(110, 60, 30, 30, 10, 10);
41 gc
.strokeRoundRect(160, 60, 30, 30, 10, 10);
42 gc
.fillArc(10, 110, 30, 30, 45, 240, ArcType
.OPEN
);
43 gc
.fillArc(60, 110, 30, 30, 45, 240, ArcType
.CHORD
);
44 gc
.fillArc(110, 110, 30, 30, 45, 240, ArcType
.ROUND
);
45 gc
.strokeArc(10, 160, 30, 30, 45, 240, ArcType
.OPEN
);
46 gc
.strokeArc(60, 160, 30, 30, 45, 240, ArcType
.CHORD
);
47 gc
.strokeArc(110, 160, 30, 30, 45, 240, ArcType
.ROUND
);
48 gc
.fillPolygon(new double[]{10, 40, 10, 40},
49 new double[]{210, 210, 240, 240}, 4);
50 gc
.strokePolygon(new double[]{60, 90, 60, 90},
51 new double[]{210, 210, 240, 240}, 4);
52 gc
.strokePolyline(new double[]{110, 140, 110, 140},
53 new double[]{210, 210, 240, 240}, 4);
This page took 0.032492 seconds and 5 git commands to generate.