@Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width, 0.0, width, height, 0.0, height, noParent ? 0 : getOffset(), noParent ? 0 : height / 2}); setClip(polygon); } };
points[i] = polygonPoints.get(i); Polygon polygon = new Polygon(points); polygon.setStrokeWidth(1); polygon.setStroke(borderColor); if (lineCount % 2 == 0) polygon.setFill(Color.rgb(0xF8, 0xF8, 0xF8,0.2)); else polygon.setFill(Color.rgb(0xFA, 0xFA, 0xFA,0.2)); lineCount++; pane.getChildren().add(polygon);
/** * Initialize the polygons * @param polygons List of polygons that are to be reset. */ public void resetPolygons(List<Polygon> polygons) { ImageView imageView = getImageView(); for (int i = 0; i < polygons.size(); i++) { Polygon polygon = polygons.get(i); if (imageView != null) { polygon.setLayoutX(imageView.getLayoutX()); polygon.setLayoutY(imageView.getLayoutY()); } if (withPolygonShading) { polygon.setFill(colors[i%colors.length]); polygon.setOpacity(0.5); } else { polygon.setFill(Color.TRANSPARENT); } getChildren().add(polygon); } }
MenuButton(String stringKey) { btn = new FXGLButton(); btn.setAlignment(Pos.CENTER_LEFT); btn.setStyle("-fx-background-color: transparent"); btn.textProperty().bind(localizedStringProperty(stringKey)); p.setMouseTransparent(true); Paint g = new LinearGradient(0, 1, 1, 0.2, true, CycleMethod.NO_CYCLE, new Stop(0.6, Color.color(1, 0.8, 0, 0.34)), new Stop(0.85, Color.color(1, 0.8, 0, 0.74)), new Stop(1, Color.WHITE)); p.fillProperty().bind( Bindings.when(btn.pressedProperty()).then((Paint) Color.color(1, 0.8, 0, 0.75)).otherwise(g) ); p.setStroke(Color.color(0.1, 0.1, 0.1, 0.15)); p.setEffect(new GaussianBlur()); // TODO: hover and/or focused? p.visibleProperty().bind(btn.hoverProperty()); getChildren().addAll(btn, p); }
/** * Create the polygon using the polygon loader. * @param polygonName name of the polygon * @return Polygon definition */ private Polygon createPolygonShape(String polygonName) { List<Polygons.PolygonsForScene.Polygon> startupPolygons = polygonLoader.getPolygon("/polygonDefinition.xml", "startup"); Polygon untransformed = polygonLoader.toJavaFXPolygon(polygonLoader.find(startupPolygons, polygonName)); if (withPolygonShading) { untransformed.setFill(Color.DARKGREEN); untransformed.setOpacity(0.5); } else { untransformed.setFill(Color.TRANSPARENT); } return untransformed; }
public PaginationV2Builder nextButtonNode(Node nextButtonNode) { if (nextButtonNode instanceof Polygon && withPolygonShading) { ((Polygon)nextButtonNode).setFill(Color.DARKGREEN); nextButtonNode.setOpacity(0.5); } this.nextButtonNode = new SimpleObjectProperty<>(this, "nextButtonNode", nextButtonNode); return this; }
untransformed.hoverProperty().addListener(new LabelHoverChangeListener(newGameLbl)); untransformed.setOnMouseClicked(event -> { pluginLoader.loadPlugins(); changeScene(uiFactory.getNewGameScene()); untransformed.hoverProperty().addListener(new LabelHoverChangeListener(loadGameLbl)); untransformed.setOnMouseClicked(event -> { pluginLoader.loadPlugins(); changeScene(uiFactory.getLoadGameScene()); untransformed.hoverProperty().addListener(new LabelHoverChangeListener(optionsLbl)); labelShapes.getChildren().add(untransformed); Label creditsLbl = new Label(messageSource.getMessage("ch.sahits.game.openpatrician.display.scene.StartupScene.credits", new Object[]{}, locale.getCurrentLocal())); untransformed = createPolygonShape("credits"); untransformed.hoverProperty().addListener(new LabelHoverChangeListener(creditsLbl)); untransformed.setOnMouseClicked(event -> changeScene(uiFactory.getCreditsScene()) ); Label historyLbl = new Label(messageSource.getMessage("ch.sahits.game.openpatrician.display.scene.StartupScene.history", new Object[]{}, locale.getCurrentLocal())); untransformed = createPolygonShape("history"); untransformed.hoverProperty().addListener(new LabelHoverChangeListener(historyLbl)); untransformed.setOnMouseClicked(event -> changeScene(uiFactory.getHanseaticHistoryScene()) );
/** * Create the polygon using the polygon loader. * @param polygonName name of the polygon * @return Polygon definition */ private Polygon createPolygonShape(String polygonName) { List<Polygons.PolygonsForScene.Polygon> startupPolygons = polygonLoader.getPolygon("/polygonDefinition.xml", "credits"); Polygon untransformed = polygonLoader.toJavaFXPolygon(polygonLoader.find(startupPolygons, polygonName)); if (withPolygonShading) { untransformed.setFill(Color.DARKGREEN); untransformed.setOpacity(0.5); } else { untransformed.setFill(Color.TRANSPARENT); } return untransformed; }
public PaginationV2Builder backButtonNode(Node backButtonNode) { if (backButtonNode instanceof Polygon && withPolygonShading) { ((Polygon)backButtonNode).setFill(Color.DARKGREEN); backButtonNode.setOpacity(0.5); } this.backButtonNode = new SimpleObjectProperty<>(this, "backButtonNode", backButtonNode); return this; }
@Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width - getOffset(), 0.0, width, height / 2, width - getOffset(), height, 0.0, height}); setClip(polygon); } };
/** * Create the polygon using the polygon loader. * @param polygonName name of the polygon * @return Polygon definition */ private Polygon createPolygonShape(String polygonName) { List<Polygons.PolygonsForScene.Polygon> startupPolygons = polygonLoader.getPolygon("/polygonDefinition.xml", "history"); Polygon untransformed = polygonLoader.toJavaFXPolygon(polygonLoader.find(startupPolygons, polygonName)); untransformed.setFill(Color.TRANSPARENT); return untransformed; } /**
@Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width - getOffset(), 0.0, width, height / 2, width - getOffset(), height, 0.0, height, getOffset(), height / 2}); setClip(polygon); } };
/** * Transform a polygon using the defined perspective transformation * @param polygon untransformed polygon * @return polygon with applied transformation. */ public Polygon transform(Polygon polygon) { List<Point2D> points = convertToPoints(polygon.getPoints()); Polygon transformedPolygon = new Polygon(); for (Point2D p : points) { double xd = p.getX()*a11 + p.getY()*a12 + b1; double yd = p.getX()*a21 + p.getY()*a22 + b2; transformedPolygon.getPoints().addAll(xd, yd); } return transformedPolygon; }
@Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width, 0.0, width, height, 0.0, height, noParent ? 0 : getOffset(), noParent ? 0 : height / 2}); setClip(polygon); } };
@Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width - getOffset(), 0.0, width, height / 2, width - getOffset(), height, 0.0, height}); setClip(polygon); } };
@Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width - getOffset(), 0.0, width, height / 2, width - getOffset(), height, 0.0, height, getOffset(), height / 2}); setClip(polygon); } };