greenColor = Color.valueOf("#0F9D58"); arc = new Arc(); arc.setManaged(false); arc.setStartAngle(0); arc.setLength(180); arc.getStyleClass().setAll("arc"); arc.setFill(Color.TRANSPARENT); arc.setStrokeWidth(3); track = new Arc(); track.setManaged(false); track.setStartAngle(0); track.setLength(360); track.setStrokeWidth(3); track.getStyleClass().setAll("track"); track.setFill(Color.TRANSPARENT);
private void updateArcLayout(double radius, double arcSize) { arc.setRadiusX(radius); arc.setRadiusY(radius); arc.setCenterX(arcSize / 2); arc.setCenterY(arcSize / 2); track.setRadiusX(radius); track.setRadiusY(radius); track.setCenterX(arcSize / 2); track.setCenterY(arcSize / 2); track.setStrokeWidth(arc.getStrokeWidth()); }
private static Arc createArc(Color stroke, double strokeWidth) { Arc a = new Arc(); a.setStartAngle(135); a.setLength(-270); a.setFill(Color.TRANSPARENT); a.setStroke(stroke); a.setStrokeWidth(strokeWidth); return a; }
@Override protected void layoutChildren() { double size = Math.min(getWidth(), getHeight()) * 0.9; double margin = size / 10; c.setCenterX(size / 2); c.setCenterY(size / 2); c.setRadius(size / 2); a1.setCenterX(size / 4 + margin / 2); a1.setCenterY(size / 2); a1.setRadiusX(size / 4 - margin / 2); a1.setRadiusY(size / 4 - margin / 2); a2.setCenterX(size * 3 / 4 - margin / 2); a2.setCenterY(size / 2); a2.setRadiusX(size / 4 - margin / 2); a2.setRadiusY(size / 4 - margin / 2); } }
private void createTransition() { if(!getSkinnable().isIndeterminate()) return; final Paint initialColor = arc.getStroke(); if (initialColor == null) { arc.setStroke(blueColor); new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), 1845 + control.getStartingAngle(), Interpolator.LINEAR));
/** * {@inheritDoc} */ @Override protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) { final double strokeWidth = arc.getStrokeWidth(); final double radius = Math.min(contentWidth, contentHeight) / 2 - strokeWidth / 2; final double arcSize = snapSize(radius * 2 + strokeWidth); arcPane.resizeRelocate((contentWidth - arcSize) / 2 + 1, (contentHeight - arcSize) / 2 + 1, arcSize, arcSize); updateArcLayout(radius, arcSize); fillRect.setWidth(arcSize); fillRect.setHeight(arcSize); if (!isValid) { initialize(); isValid = true; } if (!getSkinnable().isIndeterminate()) { arc.setLength(arcLength); if (text.isVisible()) { final double progress = control.getProgress(); int intProgress = (int) Math.round(progress * 100.0); Font font = text.getFont(); text.setFont(Font.font(font.getFamily(), radius / 1.7)); text.setText((progress > 1 ? 100 : intProgress) + "%"); text.relocate((arcSize - text.getLayoutBounds().getWidth()) / 2, (arcSize - text.getLayoutBounds().getHeight()) / 2); } } }
private void initialize() { if (getSkinnable().isIndeterminate()) { if (timeline == null) { createTransition(); if (getSkinnable().impl_isTreeVisible()) { timeline.play(); } } } else { clearAnimation(); arc.setStartAngle(90); updateProgress(); } }
public GeneratorSymbol(Color stroke, double strokeWidth, double size) { setPrefSize(size, size); c = new Circle(); c.setFill(Color.TRANSPARENT); c.setStroke(stroke); c.setStrokeWidth(strokeWidth); a1 = new Arc(); a1.setStartAngle(0); a1.setLength(180); a1.setFill(Color.TRANSPARENT); a1.setStroke(stroke); a1.setStrokeWidth(strokeWidth); a2 = new Arc(); a2.setStartAngle(0); a2.setLength(-180); a2.setFill(Color.TRANSPARENT); a2.setStroke(stroke); a2.setStrokeWidth(strokeWidth); getChildren().addAll(c, a1, a2); }
@Override protected void layoutChildren() { double size = Math.min(getWidth(), getHeight()); double marginY = size / 10; l1.setStartX(size / 2); l1.setStartY(0); l1.setEndX(size / 2); l1.setEndY(marginY); double r = (size - (2 * marginY)) / (2 + 2 * (spirals - 1) * Math.cos(Math.PI / 4)); for (int i = 0; i < spirals; i++) { a[i].setCenterX(size / 2); a[i].setCenterY(marginY + r + 2 * i * r * Math.cos(Math.PI / 4)); a[i].setRadiusX(r); a[i].setRadiusY(r); } l2.setStartX(size / 2); l2.setStartY(size - marginY); l2.setEndX(size / 2); l2.setEndY(size); } }
private void createTransition() { if(!getSkinnable().isIndeterminate()) return; final Paint initialColor = arc.getStroke(); if (initialColor == null) { arc.setStroke(blueColor); new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), 1845 + control.getStartingAngle(), Interpolator.LINEAR));
/** * {@inheritDoc} */ @Override protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) { final double strokeWidth = arc.getStrokeWidth(); final double radius = Math.min(contentWidth, contentHeight) / 2 - strokeWidth / 2; final double arcSize = snapSize(radius * 2 + strokeWidth); arcPane.resizeRelocate((contentWidth - arcSize) / 2 + 1, (contentHeight - arcSize) / 2 + 1, arcSize, arcSize); updateArcLayout(radius, arcSize); fillRect.setWidth(arcSize); fillRect.setHeight(arcSize); if (!isValid) { initialize(); isValid = true; } if (!getSkinnable().isIndeterminate()) { arc.setLength(arcLength); if (text.isVisible()) { final double progress = control.getProgress(); int intProgress = (int) Math.round(progress * 100.0); Font font = text.getFont(); text.setFont(Font.font(font.getFamily(), radius / 1.7)); text.setText((progress > 1 ? 100 : intProgress) + "%"); text.relocate((arcSize - text.getLayoutBounds().getWidth()) / 2, (arcSize - text.getLayoutBounds().getHeight()) / 2); } } }
private void initialize() { if (getSkinnable().isIndeterminate()) { if (timeline == null) { createTransition(); if (NodeHelper.isTreeShowing(getSkinnable())) { timeline.play(); } } } else { clearAnimation(); arc.setStartAngle(90); updateProgress(); } }
greenColor = Color.valueOf("#0F9D58"); arc = new Arc(); arc.setManaged(false); arc.setStartAngle(0); arc.setLength(180); arc.getStyleClass().setAll("arc"); arc.setFill(Color.TRANSPARENT); arc.setStrokeWidth(3); track = new Arc(); track.setManaged(false); track.setStartAngle(0); track.setLength(360); track.setStrokeWidth(3); track.getStyleClass().setAll("track"); track.setFill(Color.TRANSPARENT);
private void updateArcLayout(double radius, double arcSize) { arc.setRadiusX(radius); arc.setRadiusY(radius); arc.setCenterX(arcSize / 2); arc.setCenterY(arcSize / 2); track.setRadiusX(radius); track.setRadiusY(radius); track.setCenterX(arcSize / 2); track.setCenterY(arcSize / 2); track.setStrokeWidth(arc.getStrokeWidth()); }