package shapes; import javafx.scene.CustomNode; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.paint.Color; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Paint; import javafx.scene.paint.Stop; import javafx.scene.shape.Ellipse; import javafx.scene.shape.Rectangle; import javafx.scene.shape.ShapeSubtract; /** * @author Vaibhav Choudhary */ public class Shapes extends CustomNode { public var fillHeight = 0.0; public var fill = 0.0; public var op = 0.0; public var grad: Paint; public override function create(): Node { return Group { rotate: 30 content: [ // Instance of creating ellipse for top of tube Ellipse { stroke: Color.LIGHTGRAY opacity: 0.5 cache: true strokeWidth: 4 centerX: 185, centerY: 98 radiusX: 34, radiusY: 7 fill: LinearGradient { startX: 0.0 startY: 0.0 endX: 1.0 endY: 0.0 stops: [ Stop { color: Color.TRANSPARENT offset: 0.0 }, Stop { color: Color.LIGHTGREEN offset: 0.5 }, Stop { color: Color.TRANSPARENT offset: 1.0 }, ] } } // Instance of creating ellipse for top of liquid Ellipse { translateY: bind 91 - fill opacity: bind op cache: true stroke: Color.LIGHTGRAY strokeWidth: 2 opacity: 1.0 centerX: 185, centerY: 199 radiusX: 28, radiusY: 7 fill: grad } /*Instance of tube sides with cutouts for ellipse at top of tube */ ShapeSubtract { cache: true fill: LinearGradient { startX: 0.0 startY: 0.0 endX: 1.0 endY: 0.0 stops: [ Stop { color: Color.TRANSPARENT offset: 0.0 }, Stop { color: Color.WHITE offset: 0.3 }, Stop { color: Color.BLACK offset: 1.0 }, ] } opacity: 0.4 a: Rectangle { x: 150, y: 100 width: 70, height: 190 fill: Color.BLACK }, b: Ellipse { stroke: Color.BLACK opacity: 0.3 centerX: 184, centerY: 98 radiusX: 34, radiusY: 7 fill: Color.BLACK } }, /* Instance of thin rectangle to create heavy line at bottom of bar above country label */ Rectangle { x: 146, y: 290 width: 81, height: 3 fill: Color.GRAY }, ] }; } }