public RaceTrack() { ImageView carImageView = new ImageView(new Image( DataAppPreloader.class.getResourceAsStream("images/car.png"))); road = SVGPathBuilder.create() .content(trackPath).fill(null).stroke(Color.gray(0.4)) .strokeWidth(50) .effect(DropShadowBuilder.create().radius(20).blurType(BlurType.ONE_PASS_BOX).build()) .build(); SVGPath trackLine = SVGPathBuilder.create() .content(trackPath).fill(null).stroke(Color.WHITE) .strokeDashArray(8d,6d).build(); Line startLine = LineBuilder.create() .startX(610.312).startY(401.055).endX(610.312).endY(450.838) .stroke(Color.WHITE).strokeDashArray(2d,2d).build(); Text startFinish = TextBuilder.create().text("START/FINISH").fill(Color.WHITE) .x(570).y(475).build(); percentage = TextBuilder.create().text("0%") .x(390).y(170).font(Font.font("System", 60)) .fill(Color.web("#ddf3ff")) .stroke(Color.web("#73c0f7")) .effect(DropShadowBuilder.create().radius(15).color(Color.web("#3382ba")).blurType(BlurType.ONE_PASS_BOX).build()) .build(); ImageView raceCarImg = new ImageView(new Image( DataAppPreloader.class.getResourceAsStream("images/Mini-red-and-white.png"))); raceCarImg.setX(raceCarImg.getImage().getWidth()/2); raceCarImg.setY(raceCarImg.getImage().getHeight()/2); raceCarImg.setRotate(90); raceCar = new Group(raceCarImg); track = new Group(road, trackLine, startLine, startFinish); track.setCache(true); // add children getChildren().addAll(track, raceCar, percentage); // Create path animation that we will use to drive the car along the track race = new PathTransition(Duration.seconds(1), road, raceCar); race.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); race.play(); race.pause(); // center our content and set our size setTranslateX(-road.getBoundsInLocal().getMinX()); setTranslateY(-road.getBoundsInLocal().getMinY()); setPrefSize(road.getBoundsInLocal().getWidth(), road.getBoundsInLocal().getHeight()); setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE); }
public static SVGPath shapeToSvgPath(final Shape SHAPE) { return SVGPathBuilder.create().content(shapeToSvgString(SHAPE)).build(); }