// Make the progress line+circle follow the pledged amount and disappear if there are no pledges yet.
//
// This is all calculated lazily, so changes in pledgedProperty propagate through to the widgets only
// when they actually need to be drawn.
DoubleBinding progress = min(1.0, divide(pledgedAmount, (double) project.getGoalAmount().value));
NumberBinding pixelWidth = multiply(widthProperty(), progress);
// These come pre-bound in the FXML just to make things look more clear in Scene Builder, so unbind them here.
progressLine.endXProperty().unbind();
progressCircle.centerXProperty().unbind();
animatedBind(progressLine, progressLine.endXProperty(), pixelWidth);
animatedBind(progressCircle, progressCircle.centerXProperty(), pixelWidth);
progressLine.visibleProperty().bind(pixelWidth.greaterThan(0.0));
progressCircle.visibleProperty().bind(progressLine.visibleProperty());
Tooltip tooltip = new Tooltip();
// TODO: Maybe use Adam's BtcFormat class here instead.
tooltip.textProperty().bind(new ReactiveCoinFormatter("%s BTC raised so far", MonetaryFormat.BTC, pledgedAmount));
Tooltip.install(progressCircle, tooltip);