解决节点的CSS属性 [英] Resolving CSS property for node

查看:71
本文介绍了解决节点的CSS属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我的google-fu今天让我失望了,但是我一直无法找到一种方法来解析节点的任意属性以获取样式属性.例如,我想问一个节点"-fx-fill的值是多少(如果有)?".

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?'.

一个简单的应用程序示例:我想为图表构建自定义图例.为此,我必须向渲染的节点询问其fill属性.当然,我可以使用我对default-colorN类的了解并简单地查找填充,但是感觉这将是一个非常糟糕的方法,因为它违反了CSS的整体思想.

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.

谢谢.

顺便说一句:JavaFX版本为2.1

BTW: JavaFX version is 2.1

推荐答案

我想问一个节点"-fx-fill的值是多少(如果有)?"

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

目前还没有公共API.计划在将来的版本中添加这样的API. 参见 Java中的RT-17293 CSS样式对象模型.

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.

对于2.0和2.1版本,您可能会使用未记录的不推荐使用的impl_方法查找信息,但我不建议这样做.

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.

就目前而言,我建议您仅使用 css图表尽可能地设置样式,并添加一些动态

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.

这篇关于解决节点的CSS属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆