问题描述
如何获取NumberAxis刻度线标签的字符串表示形式(与图形输出一样)?我可以使用哪种方法来回读NumberAxis上显示的内容.例如,x轴正在显示(1、2、3,...,10).当我使用刻度标记标签的tickMark.getLabel()时,我得到(1.0,2.0,3.0,...,10.0).它正在返回一个双. JavaFX是否使用默认的LabelFormatter方法在将双精度字符显示在屏幕上之前将其转换为整数?
How do I get the string representation (as what is output on the graph) of the tick mark label on the NumberAxis? Which method can I use to read back what is being displayed on the NumberAxis.For example, the x-Axis is displaying (1, 2, 3, ..., 10). When I use the tickMark.getLabel() of the tick mark label, I get (1.0, 2.0, 3.0, ..., 10.0). It is returning a double. Does JavaFX use a default LabelFormatter method that converts the double to an integer before it displays on the screen?
推荐答案
NumberAxis具有一个格式化程序字段(从VaueAxis继承),用于将值转换为字符串.请参见 http://docs.oracle.com/javase/8/javafx/api/javafx/scene/chart/ValueAxis.html#setTickLabelFormatter-javafx.util.StringConverter-
NumberAxis has a formatter field (inherited from VaueAxis) that converts the values to strings. See http://docs.oracle.com/javase/8/javafx/api/javafx/scene/chart/ValueAxis.html#setTickLabelFormatter-javafx.util.StringConverter-
如果它没有给您想要的值,您可以覆盖它.
You can overwrite it if it's not giving you the values you want.
这篇关于JavaFX-NumberAxis上的刻度线标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!