Scale-invariant border-sizing in JavaFX via CSS?

Viewed 93

I'm trying to specify a border size to a JavaFX node such that with the parent of the node is scaled, the resulting border still occupies the same width on screen.

For example, I have

Pane container = new Pane();
Pane nodeWithBorder = new Pane();
nodeWithBorder.getStyleClass().add('my-node');

In my stylesheet, I have something similar to

.my-node {
   -fx-border-width: 2px;
   -fx-border-color: red;
   ...
}

Assuming container has scaleX = scaleY = 1, the resulting border for nodeWithBorder will render with width of 2px.

What I'd like to achieve via CSS is when container.setScaleX(2); container.setScaleY(2), the nodeWithBorder should correspondingly scale in size, but render with the same 2px border.

I can do this programmatically by specifiy the border in the code and creating a binding between its width property and the scale properties. Since I need to do this in several places within my application and it's not always known which level in the parent-tree the scale is changing, I was wondering if there is a way to specify this with some-sort of relative unit via the CSS.

0 Answers
Related