Resolving CSS property for node

2019-07-15 08:21发布

maybe my google-fu is just letting me down today, but i have not been able to find a way to resolve arbitrary properties of nodes in order to obtain a style attribute. For instance, I'd like to be able to ask a node 'What is your value (if any) for -fx-fill?'.

A simple application example: I'd like to build a custom legend for a chart. To do so, I'd have to ask a rendered node for their fill property. I could, of course, use my knowledge of the default-colorN classes and simply look up the fill, but it feels like this would be a very bad approach as is violates the whole idea of CSS.

Thanks in advance.

BTW: JavaFX version is 2.1

标签: javafx-2
1条回答
女痞
2楼-- · 2019-07-15 09:02

I'd like to be able to ask a node 'What is your value (if any) for -fx-fill?'

There is no public API for that yet. It is planned to add such an API in a future release. See RT-17293 CSS Style Object Model in Java.

For the 2.0 and 2.1 release, you could probably find the information using undocumented, deprecated impl_ methods, but I wouldn't advise that.

For now, I'd advise just using css chart styling where-ever you can and supplementing it with a sprinkling of dynamic node.lookup() code where it is impossible to achieve the styling using css.

查看更多
登录 后发表回答