17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package test.javafx.scene.chart;
27
28
29 import javafx.beans.property.ListProperty;
30 import javafx.beans.property.SimpleListProperty;
31 import org.junit.Test;
32 import javafx.collections.*;
33 import javafx.scene.chart.Axis.TickMark;
34 import javafx.css.ParsedValue;
35 import javafx.css.CssMetaData;
36 import javafx.css.StyleableProperty;
37 import javafx.css.CssParser;
38 import javafx.scene.Node;
39 import javafx.scene.ParentShim;
40 import javafx.scene.Scene;
41 import javafx.scene.chart.AreaChart;
42 import javafx.scene.chart.Axis;
43 import javafx.scene.chart.AxisShim;
44 import javafx.scene.chart.CategoryAxis;
45 import javafx.scene.chart.Chart;
46 import javafx.scene.chart.ChartShim;
47 import javafx.scene.chart.NumberAxis;
48 import javafx.scene.chart.XYChart;
49 import javafx.scene.layout.StackPane;
50 import javafx.scene.paint.Color;
51
52 import javafx.scene.text.Font;
53 import javafx.scene.text.Text;
54 import javafx.stage.Stage;
55 import org.junit.Assert;
56 import static org.junit.Assert.assertEquals;
57 import static org.junit.Assert.assertSame;
69 return areachart;
70 }
71
72 @Test
73 public void testTickMarksToString() {
74 startApp();
75 pulse();
76 yaxis.getTickMarks().toString();
77 System.out.println(" --- "+yaxis.getTickMarks().toString());
78 }
79
80 // RT-22166
81 @Test public void testTickLabelFont() {
82 startApp();
83 Font f = yaxis.getTickLabelFont();
84 // default caspian value for font size = 10
85 assertEquals(10, new Double(f.getSize()).intValue());
86 assertEquals(10, new Double(AxisShim.get_measure(yaxis).getFont().getSize()).intValue());
87
88 // set tick label font via css and test if ticklabelfont, measure and tick textnode follow.
89 ParsedValue pv = new CssParser().parseExpr("-fx-tick-label-font","0.916667em System");
90 Object val = pv.convert(null);
91 CssMetaData prop = ((StyleableProperty)yaxis.tickLabelFontProperty()).getCssMetaData();
92 prop.set(yaxis, val, null);
93 // confirm tickLabelFont, measure and tick's textnode all are in sync with -fx-tick-label-font
94 assertEquals(11, new Double(yaxis.getTickLabelFont().getSize()).intValue());
95 assertEquals(11, new Double(AxisShim.get_measure(yaxis).getFont().getSize()).intValue());
96 final ObservableList<Axis.TickMark<Number>> yaTickMarks = yaxis.getTickMarks();
97 TickMark tm = yaTickMarks.get(0);
98 assertEquals(11, new Double(AxisShim.TickMark_get_textNode(tm).getFont().getSize()).intValue());
99 // set tick label font programmatically and test.
100 yaxis.setTickLabelFont(new Font(12.0f));
101 assertEquals(12, new Double(yaxis.getTickLabelFont().getSize()).intValue());
102 assertEquals(12, new Double(AxisShim.get_measure(yaxis).getFont().getSize()).intValue());
103 assertEquals(12, new Double(AxisShim.TickMark_get_textNode(tm).getFont().getSize()).intValue());
104 }
105
106 @Test public void testSetTickLabelFill() {
107 startApp();
108 pulse();
109 yaxis.setTickLabelFill(Color.web("#444444"));
|
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package test.javafx.scene.chart;
27
28
29 import javafx.beans.property.ListProperty;
30 import javafx.beans.property.SimpleListProperty;
31 import org.junit.Test;
32 import javafx.collections.*;
33 import javafx.scene.chart.Axis.TickMark;
34 import javafx.css.ParsedValue;
35 import javafx.css.CssMetaData;
36 import javafx.css.StyleableProperty;
37 import javafx.css.CssParserShim;
38 import javafx.scene.Node;
39 import javafx.scene.ParentShim;
40 import javafx.scene.Scene;
41 import javafx.scene.chart.AreaChart;
42 import javafx.scene.chart.Axis;
43 import javafx.scene.chart.AxisShim;
44 import javafx.scene.chart.CategoryAxis;
45 import javafx.scene.chart.Chart;
46 import javafx.scene.chart.ChartShim;
47 import javafx.scene.chart.NumberAxis;
48 import javafx.scene.chart.XYChart;
49 import javafx.scene.layout.StackPane;
50 import javafx.scene.paint.Color;
51
52 import javafx.scene.text.Font;
53 import javafx.scene.text.Text;
54 import javafx.stage.Stage;
55 import org.junit.Assert;
56 import static org.junit.Assert.assertEquals;
57 import static org.junit.Assert.assertSame;
69 return areachart;
70 }
71
72 @Test
73 public void testTickMarksToString() {
74 startApp();
75 pulse();
76 yaxis.getTickMarks().toString();
77 System.out.println(" --- "+yaxis.getTickMarks().toString());
78 }
79
80 // RT-22166
81 @Test public void testTickLabelFont() {
82 startApp();
83 Font f = yaxis.getTickLabelFont();
84 // default caspian value for font size = 10
85 assertEquals(10, new Double(f.getSize()).intValue());
86 assertEquals(10, new Double(AxisShim.get_measure(yaxis).getFont().getSize()).intValue());
87
88 // set tick label font via css and test if ticklabelfont, measure and tick textnode follow.
89 ParsedValue pv = new CssParserShim().parseExpr("-fx-tick-label-font","0.916667em System");
90 Object val = pv.convert(null);
91 CssMetaData prop = ((StyleableProperty)yaxis.tickLabelFontProperty()).getCssMetaData();
92 prop.set(yaxis, val, null);
93 // confirm tickLabelFont, measure and tick's textnode all are in sync with -fx-tick-label-font
94 assertEquals(11, new Double(yaxis.getTickLabelFont().getSize()).intValue());
95 assertEquals(11, new Double(AxisShim.get_measure(yaxis).getFont().getSize()).intValue());
96 final ObservableList<Axis.TickMark<Number>> yaTickMarks = yaxis.getTickMarks();
97 TickMark tm = yaTickMarks.get(0);
98 assertEquals(11, new Double(AxisShim.TickMark_get_textNode(tm).getFont().getSize()).intValue());
99 // set tick label font programmatically and test.
100 yaxis.setTickLabelFont(new Font(12.0f));
101 assertEquals(12, new Double(yaxis.getTickLabelFont().getSize()).intValue());
102 assertEquals(12, new Double(AxisShim.get_measure(yaxis).getFont().getSize()).intValue());
103 assertEquals(12, new Double(AxisShim.TickMark_get_textNode(tm).getFont().getSize()).intValue());
104 }
105
106 @Test public void testSetTickLabelFill() {
107 startApp();
108 pulse();
109 yaxis.setTickLabelFill(Color.web("#444444"));
|