@Override protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { if (Region.USE_COMPUTED_SIZE == control.getRadius()) { return super.computeMaxHeight(width, topInset, rightInset, bottomInset, leftInset); } else { return control.getRadius() * 2 + arc.getStrokeWidth() * 2; } }
@Override protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { if (Region.USE_COMPUTED_SIZE == control.getRadius()) { return super.computeMaxHeight(height, topInset, rightInset, bottomInset, leftInset); } else { return control.getRadius() * 2 + arc.getStrokeWidth() * 2; } }
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()); }
/** * {@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); } } }
@Override protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { if (Region.USE_COMPUTED_SIZE == control.getRadius()) { return super.computeMaxHeight(height, topInset, rightInset, bottomInset, leftInset); } else { return control.getRadius() * 2 + arc.getStrokeWidth() * 2; } }
@Override protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { if (Region.USE_COMPUTED_SIZE == control.getRadius()) { return super.computeMaxHeight(width, topInset, rightInset, bottomInset, leftInset); } else { return control.getRadius() * 2 + arc.getStrokeWidth() * 2; } }
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()); }
/** * {@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); } } }