15 * accompanied this code).
16 *
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 javafx.scene.chart;
27
28
29 import org.junit.Test;
30 import javafx.collections.*;
31 import javafx.scene.chart.Axis.TickMark;
32 import javafx.css.ParsedValue;
33 import javafx.css.CssMetaData;
34 import javafx.css.StyleableProperty;
35 import com.sun.javafx.css.parser.CSSParser;
36 import javafx.scene.Node;
37 import javafx.scene.Scene;
38 import javafx.scene.layout.StackPane;
39 import javafx.scene.paint.Color;
40
41 import javafx.scene.text.Font;
42 import javafx.scene.text.Text;
43 import javafx.stage.Stage;
44 import org.junit.Assert;
45 import static org.junit.Assert.assertEquals;
46 import static org.junit.Assert.assertSame;
47
48
49 public class XYChartTest extends ChartTestBase {
50
51 NumberAxis yaxis;
52 CategoryAxis cataxis;
53 AreaChart<?, ?> areachart;
54
55 protected Chart createChart() {
62 return areachart;
63 }
64
65 @Test
66 public void testTickMarksToString() {
67 startApp();
68 pulse();
69 yaxis.getTickMarks().toString();
70 System.out.println(" --- "+yaxis.getTickMarks().toString());
71 }
72
73 // RT-22166
74 @Test public void testTickLabelFont() {
75 startApp();
76 Font f = yaxis.getTickLabelFont();
77 // default caspian value for font size = 10
78 assertEquals(10, new Double(f.getSize()).intValue());
79 assertEquals(10, new Double(yaxis.measure.getFont().getSize()).intValue());
80
81 // set tick label font via css and test if ticklabelfont, measure and tick textnode follow.
82 ParsedValue pv = CSSParser.getInstance().parseExpr("-fx-tick-label-font","0.916667em System");
83 Object val = pv.convert(null);
84 CssMetaData prop = ((StyleableProperty)yaxis.tickLabelFontProperty()).getCssMetaData();
85 try {
86 prop.set(yaxis, val, null);
87 // confirm tickLabelFont, measure and tick's textnode all are in sync with -fx-tick-label-font
88 assertEquals(11, new Double(yaxis.getTickLabelFont().getSize()).intValue());
89 assertEquals(11, new Double(yaxis.measure.getFont().getSize()).intValue());
90 final ObservableList<Axis.TickMark<Number>> yaTickMarks = yaxis.getTickMarks();
91 TickMark tm = yaTickMarks.get(0);
92 assertEquals(11, new Double(tm.textNode.getFont().getSize()).intValue());
93 } catch (Exception e) {
94 Assert.fail(e.toString());
95 }
96 // set tick label font programmatically and test.
97 yaxis.setTickLabelFont(new Font(12.0f));
98 assertEquals(12, new Double(yaxis.getTickLabelFont().getSize()).intValue());
99 assertEquals(12, new Double(yaxis.measure.getFont().getSize()).intValue());
100 final ObservableList<Axis.TickMark<Number>> yaTickMarks = yaxis.getTickMarks();
101 TickMark tm = yaTickMarks.get(0);
102 assertEquals(12, new Double(tm.textNode.getFont().getSize()).intValue());
|
15 * accompanied this code).
16 *
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 javafx.scene.chart;
27
28
29 import org.junit.Test;
30 import javafx.collections.*;
31 import javafx.scene.chart.Axis.TickMark;
32 import javafx.css.ParsedValue;
33 import javafx.css.CssMetaData;
34 import javafx.css.StyleableProperty;
35 import javafx.css.CssParser;
36 import javafx.scene.Node;
37 import javafx.scene.Scene;
38 import javafx.scene.layout.StackPane;
39 import javafx.scene.paint.Color;
40
41 import javafx.scene.text.Font;
42 import javafx.scene.text.Text;
43 import javafx.stage.Stage;
44 import org.junit.Assert;
45 import static org.junit.Assert.assertEquals;
46 import static org.junit.Assert.assertSame;
47
48
49 public class XYChartTest extends ChartTestBase {
50
51 NumberAxis yaxis;
52 CategoryAxis cataxis;
53 AreaChart<?, ?> areachart;
54
55 protected Chart createChart() {
62 return areachart;
63 }
64
65 @Test
66 public void testTickMarksToString() {
67 startApp();
68 pulse();
69 yaxis.getTickMarks().toString();
70 System.out.println(" --- "+yaxis.getTickMarks().toString());
71 }
72
73 // RT-22166
74 @Test public void testTickLabelFont() {
75 startApp();
76 Font f = yaxis.getTickLabelFont();
77 // default caspian value for font size = 10
78 assertEquals(10, new Double(f.getSize()).intValue());
79 assertEquals(10, new Double(yaxis.measure.getFont().getSize()).intValue());
80
81 // set tick label font via css and test if ticklabelfont, measure and tick textnode follow.
82 ParsedValue pv = new CssParser().parseExpr("-fx-tick-label-font","0.916667em System");
83 Object val = pv.convert(null);
84 CssMetaData prop = ((StyleableProperty)yaxis.tickLabelFontProperty()).getCssMetaData();
85 try {
86 prop.set(yaxis, val, null);
87 // confirm tickLabelFont, measure and tick's textnode all are in sync with -fx-tick-label-font
88 assertEquals(11, new Double(yaxis.getTickLabelFont().getSize()).intValue());
89 assertEquals(11, new Double(yaxis.measure.getFont().getSize()).intValue());
90 final ObservableList<Axis.TickMark<Number>> yaTickMarks = yaxis.getTickMarks();
91 TickMark tm = yaTickMarks.get(0);
92 assertEquals(11, new Double(tm.textNode.getFont().getSize()).intValue());
93 } catch (Exception e) {
94 Assert.fail(e.toString());
95 }
96 // set tick label font programmatically and test.
97 yaxis.setTickLabelFont(new Font(12.0f));
98 assertEquals(12, new Double(yaxis.getTickLabelFont().getSize()).intValue());
99 assertEquals(12, new Double(yaxis.measure.getFont().getSize()).intValue());
100 final ObservableList<Axis.TickMark<Number>> yaTickMarks = yaxis.getTickMarks();
101 TickMark tm = yaTickMarks.get(0);
102 assertEquals(12, new Double(tm.textNode.getFont().getSize()).intValue());
|