Shape shape = getShape(); if (getShape() != null) { widthHeightRatio = shape.prefWidth(-1) / shape.prefHeight(-1); if (getSize() != Region.USE_COMPUTED_SIZE) { setSizeRatio(getSize());
line.setRotate(angle/2); Shape finalShape = Shape.subtract(circle, innerCircle); finalShape.setFill(Color.TRANSPARENT); finalShape.setTranslateX(gapCausedByScale); finalShape.setTranslateY(gapCausedByScale); finalShape.rotateProperty().bind(currentRotation); finalShape.setOnMouseDragged(mouseEvent -> { Bounds bounds = control.getBoundsInParent(); Point2D center = control.localToScene(bounds.getWidth() / 2, bounds.getHeight()); finalShape.setOnMouseReleased(event -> snapToNearestAngle());
/** * A factor method for setting the colors for any shape.<br/> * @param shape The Shape object to set colors. Cannot be null. * @param fill The fill color of the shape. If null, no fill will be set. * @param stroke The stroke color of the shape. If null, <p>strokeWidth</p> must also be null. * @param strokeWidth The stroke width of the shape. If null, <p>stroke</p> must also be null. */ public static void setShapeColors(Shape shape, Paint fill, Paint stroke, Double strokeWidth) { final Preconditions p = new Preconditions(); p.checkNull(shape, "PARAM(shape) cannot be null."); p.checkArgument( (null != stroke && null != strokeWidth) || (null == stroke && null == strokeWidth), "PARAM(stroke) and PARAM(strokeWidth) must either both be null, or neither be null." ); p.checkArgument(null == stroke || null == strokeWidth || 0d <= strokeWidth, "PARAM(strokeWidth) must be greater than or equal to zero."); p.reportViolations(); if(null != fill) { shape.setFill(fill); } // END if if(null != stroke && null != strokeWidth) { shape.setStroke(stroke); shape.setStrokeWidth(strokeWidth); } // END if } // END setShapeColors
private void addDebugViewSensor(HitBox hitBox) { Shape view = null; if (hitBox.getShape().isCircle()) { double radius = hitBox.getWidth() / 2; view = new Circle(radius, radius, radius, null); } else if (hitBox.getShape().isRectangle()) { view = new Rectangle(hitBox.getWidth(), hitBox.getHeight(), null); } if (view != null) { view.strokeProperty().bind(FXGL.getSettings().getDevSensorColor()); view.setTranslateX(hitBox.getMinX()); view.setTranslateY(hitBox.getMinY()); debugBBox.getChildren().add(view); } }
final KeyValue kv2 = new KeyValue(shape.fillProperty(), new Color(0, 1, 0, 0.80)); final KeyFrame kf2 = new KeyFrame(Duration.millis(300), kv2); timeline.getKeyFrames().add(kf2); final KeyValue kv3 = new KeyValue(shape.strokeProperty(), new Color(0, 1, 0, 0.90)); final KeyFrame kf3 = new KeyFrame(Duration.millis(300), kv3);
/** * Compute the needed clip for stage's shadow border * * @param newBounds * @param shadowVisible */ void setShadowClip(Bounds newBounds) { external.relocate(newBounds.getMinX() - SHADOW_WIDTH, newBounds.getMinY() - SHADOW_WIDTH); internal.setX(SHADOW_WIDTH); internal.setY(SHADOW_WIDTH); internal.setWidth(newBounds.getWidth()); internal.setHeight(newBounds.getHeight()); internal.setArcWidth(shadowRectangle.getArcWidth()); // shadowRectangle // CSS cannot be // applied on // this internal.setArcHeight(shadowRectangle.getArcHeight()); external.setWidth(newBounds.getWidth() + SHADOW_WIDTH * 2); external.setHeight(newBounds.getHeight() + SHADOW_WIDTH * 2); Shape clip = Shape.subtract(external, internal); shadowRectangle.setClip(clip); }
protected void initStyle() { connectionPath.getStyleClass().setAll( "vnode-connection", "vnode-connection-" + type); receiverConnectorUI.getStyleClass().setAll( "vnode-connection-receiver", "vnode-connection-receiver-" + type); getReceiverUI().setFill(new Color(0, 1.0, 0, 0.0)); getReceiverUI().setStroke(new Color(0, 1.0, 0, 0.0)); getReceiverUI().setStrokeWidth(3); }
private void addDebugView(HitBox hitBox) { Shape view = null; if (hitBox.getShape().isCircle()) { double radius = hitBox.getWidth() / 2; view = new Circle(radius, radius, radius, null); } else if (hitBox.getShape().isRectangle()) { view = new Rectangle(hitBox.getWidth(), hitBox.getHeight(), null); } if (view != null) { view.strokeProperty().bind(FXGL.getSettings().getDevBBoxColor()); view.setTranslateX(hitBox.getMinX()); view.setTranslateY(hitBox.getMinY()); debugBBox.getChildren().add(view); } }
Shape shape = getShape(); if (getShape() != null) { widthHeightRatio = shape.prefWidth(-1) / shape.prefHeight(-1); if (getSize() != Region.USE_COMPUTED_SIZE) { setSizeRatio(getSize());