Scribble
From Planet JFX
[edit] Summary
See this thread in the mailing lists.
Scribble is a simple path editor -- click on the canvas, and paths following mouse drags are converted into Polyline objects. Makes use of the SQL-like array insert functionality to create polylines and add points to them.
[edit] Code
ScribbleRect.fx
import javafx.ext.swing.*;
import javafx.input.*;
import javafx.scene.*;
import javafx.scene.geometry.*;
import javafx.scene.paint.*;
import java.lang.System;
public class Scribble extends CustomNode {
attribute polyline: Polyline;
public override function create(): Node {
var group: Group = Group{
onMousePressed: function (e: MouseEvent) {
polyline = Polyline{points : [e.getStageX(), e.getStageY()]
stroke : Color.RED
strokeWidth: 7};
insert polyline into group.content ;
}// onMousePressed
onMouseDragged: function (e: MouseEvent) {
insert [e.getStageX(), e.getStageY()] into polyline.points;
}// onMouseDragged
content: Rectangle {
width : 400
height: 400
fill : Color.BLUE //Color{opacity: 0}
}// Rectangle
}// Group
return group;
}// create()
}//Scribble
SwingFrame {
closeAction: function(): Void {System.exit(0);}
title : 'Scribble with Rectangle'
background : Color.WHITE;
width : 600
height : 400
visible : true
content: Canvas {
content: [Scribble{}]
}// Canvas
}//SwingFrame

