private void rebuild() { // update indeterminate indicator final int segments = skin.indeterminateSegmentCount.get(); opacities.clear(); pathsG.getChildren().clear(); final double step = 0.8 / (segments - 1); for (int i = 0; i < segments; i++) { Region region = new Region(); region.setScaleShape(false); region.setCenterShape(false); region.getStyleClass().addAll("segment", "segment" + i); if (fillOverride instanceof Color) { Color c = (Color) fillOverride; region.setStyle( "-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + "" + c.getOpacity() + ");"); } else { region.setStyle(null); } double opacity = Math.min(1, i * step); opacities.add(opacity); region.setOpacity(opacity); pathsG.getChildren().add(region); } }
@Override protected void layoutChildren() { Insets controlInsets = control.getInsets(); final double w = control.getWidth() - controlInsets.getLeft() - controlInsets.getRight(); final double h = control.getHeight() - controlInsets.getTop() - controlInsets.getBottom(); final double prefW = pathsG.prefWidth(-1); final double prefH = pathsG.prefHeight(-1); double scaleX = w / prefW; double scale = scaleX; if ((scaleX * prefH) > h) { scale = h / prefH; } double indicatorW = prefW * scale - 3; double indicatorH = prefH * scale - 3; pathsG.resizeRelocate((w - indicatorW) / 2, (h - indicatorH) / 2, indicatorW, indicatorH); }