* @return the tick value display
*/
protected Node createTickValueDisplay(final double height,
final ObjectProperty<Paint> backgroundFillProperty,
final ObjectProperty<Paint> textFillProperty) {
final StackPane valContainer = new StackPane();
final Text val = new Text(getTickValueLabel(false));
val.setFont(tickValueFont);
final DropShadow outerGlow = new DropShadow();
outerGlow.setOffsetX(0);
outerGlow.setOffsetY(0);
outerGlow.setColor(Color.BLUE);
outerGlow.setRadius(2d);
val.setEffect(outerGlow);
Bindings.bindBidirectional(val.fillProperty(), textFillProperty);
//val.setStyle("-fx-text-fill: white;");
angleProperty.addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable,
Number oldValue, Number newValue) {
val.setText(getTickValueLabel(false));//newValue.doubleValue()));
}
});
final double rimThickness = outerRadius - innerRadius;
Shape border;
if (isCircular()) {
final Rectangle rec = new Rectangle(outerRadius, height);
rec.setArcHeight(5d);
rec.setArcWidth(5d);
rec.setTranslateY(5d);
border = rec;
val.setTranslateY(rec.getHeight() / 2d);
valContainer.setTranslateX(centerX - rec.getWidth() / 2d);
valContainer.setTranslateY(centerY + rec.getHeight());
} else {
// create the background border for the tick mark value
final double width = outerRadius - rimThickness;
final double offsetY = centerY + rimThickness;
// TODO : replace square root with proper angle offset
final double offsetX = centerX + dialCenterBackgroundRadius - Math.sqrt(offsetY);
// rotate value text so that it is never upside down
final double angle = -getGeometericStartAngle();
if (Math.abs(angle) > 90d && Math.abs(angle) < 270d) {
val.setRotate(180d);
}
final Circle dialCutout = new Circle(centerX, centerY, innerRadius);
final Circle gaugeCutout = new Circle(centerX, centerY, dialCenterBackgroundRadius
+ rimThickness);
// create the border rectangle
final Polygon rec = new Polygon(centerX, offsetY, centerX + width, offsetY,
centerX + width, offsetY + height, centerX, offsetY + height);
// carve out outer rim rectangle edge
final Shape recArc = Shape.intersect(rec, dialCutout);
// carve out inner dial rectangle edge
border = Shape.subtract(recArc, gaugeCutout);
border.setTranslateX(offsetX);
border.setTranslateY(offsetY);
val.setTranslateX(offsetX);
val.setTranslateY(offsetY);
valContainer.getTransforms().add(new Rotate(angle, centerX, centerY));
}
Bindings.bindBidirectional(border.fillProperty(), backgroundFillProperty);
border.setStroke(Color.GRAY);
border.setStrokeWidth(1d);
valContainer.getChildren().addAll(border, val);
return valContainer;
}