/** * {@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 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; }
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); }
/** * {@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); } } }