1027 syncNode(c); 1028 assertFalse(sg.isVisible()); 1029 1030 final Rectangle r = new Rectangle(); 1031 g.getChildren().add(r); 1032 c.setRadius(100); 1033 1034 syncNode(g); 1035 syncNode(c); 1036 assertEquals(1, sg.getChildren().size()); 1037 assertEquals(50.0, sc.getRadius(), 0.01); 1038 1039 g.setVisible(true); 1040 1041 syncNode(g); 1042 syncNode(c); 1043 assertEquals(2, sg.getChildren().size()); 1044 assertEquals(100.0, sc.getRadius(), 0.01); 1045 1046 } 1047 1048 @Test 1049 public void testLocalToScreen() { 1050 Rectangle rect = new Rectangle(); 1051 1052 rect.setTranslateX(10); 1053 rect.setTranslateY(20); 1054 1055 TestScene scene = new TestScene(new Group(rect)); 1056 final TestStage testStage = new TestStage(""); 1057 testStage.setX(100); 1058 testStage.setY(200); 1059 scene.set_window(testStage); 1060 Point2D p = rect.localToScreen(new Point2D(1, 2)); 1061 assertEquals(111.0, p.getX(), 0.0001); 1062 assertEquals(222.0, p.getY(), 0.0001); 1063 Bounds b = rect.localToScreen(new BoundingBox(1, 2, 3, 4)); 1064 assertEquals(111.0, b.getMinX(), 0.0001); 1065 assertEquals(222.0, b.getMinY(), 0.0001); 1066 assertEquals(3.0, b.getWidth(), 0.0001); | 1027 syncNode(c); 1028 assertFalse(sg.isVisible()); 1029 1030 final Rectangle r = new Rectangle(); 1031 g.getChildren().add(r); 1032 c.setRadius(100); 1033 1034 syncNode(g); 1035 syncNode(c); 1036 assertEquals(1, sg.getChildren().size()); 1037 assertEquals(50.0, sc.getRadius(), 0.01); 1038 1039 g.setVisible(true); 1040 1041 syncNode(g); 1042 syncNode(c); 1043 assertEquals(2, sg.getChildren().size()); 1044 assertEquals(100.0, sc.getRadius(), 0.01); 1045 1046 } 1047 1048 @Test 1049 public void testSynchronizationOfInvisibleNodes_2() { 1050 final Group g = new Group(); 1051 final Circle c = new CircleTest.StubCircle(50); 1052 1053 Scene s = new Scene(g); 1054 Stage st = new Stage(); 1055 st.show(); 1056 st.setScene(s); 1057 1058 final NGGroup sg = g.impl_getPeer(); 1059 final CircleTest.StubNGCircle sc = c.impl_getPeer(); 1060 1061 g.getChildren().add(c); 1062 1063 s.scenePulseListener.pulse(); 1064 1065 g.setVisible(false); 1066 1067 s.scenePulseListener.pulse(); 1068 1069 assertFalse(sg.isVisible()); 1070 assertTrue(sc.isVisible()); 1071 1072 c.setCenterX(10); // Make the circle dirty. It won't be synchronized as it is practically invisible (through the parent) 1073 1074 s.scenePulseListener.pulse(); 1075 1076 c.setVisible(false); // As circle is invisible and dirty, this won't trigger a synchronization 1077 1078 s.scenePulseListener.pulse(); 1079 1080 assertFalse(sg.isVisible()); 1081 assertTrue(sc.isVisible()); // This has not been synchronized, as it's not necessary 1082 // The rendering will stop at the Group, which is invisible 1083 1084 g.setVisible(true); 1085 1086 s.scenePulseListener.pulse(); 1087 1088 assertTrue(sg.isVisible()); 1089 assertFalse(sc.isVisible()); // Now the group is visible again, we need to synchronize also 1090 // the Circle 1091 } 1092 1093 @Test 1094 public void testSynchronizationOfInvisibleNodes_2_withClip() { 1095 final Group g = new Group(); 1096 final Circle c = new CircleTest.StubCircle(50); 1097 1098 Scene s = new Scene(g); 1099 Stage st = new Stage(); 1100 st.show(); 1101 st.setScene(s); 1102 1103 final NGGroup sg = g.impl_getPeer(); 1104 final CircleTest.StubNGCircle sc = c.impl_getPeer(); 1105 1106 g.setClip(c); 1107 1108 s.scenePulseListener.pulse(); 1109 1110 g.setVisible(false); 1111 1112 s.scenePulseListener.pulse(); 1113 1114 assertFalse(sg.isVisible()); 1115 assertTrue(sc.isVisible()); 1116 1117 c.setCenterX(10); // Make the circle dirty. It won't be synchronized as it is practically invisible (through the parent) 1118 1119 s.scenePulseListener.pulse(); 1120 1121 c.setVisible(false); // As circle is invisible and dirty, this won't trigger a synchronization 1122 1123 s.scenePulseListener.pulse(); 1124 1125 assertFalse(sg.isVisible()); 1126 assertTrue(sc.isVisible()); // This has not been synchronized, as it's not necessary 1127 // The rendering will stop at the Group, which is invisible 1128 1129 g.setVisible(true); 1130 1131 s.scenePulseListener.pulse(); 1132 1133 assertTrue(sg.isVisible()); 1134 assertFalse(sc.isVisible()); // Now the group is visible again, we need to synchronize also 1135 // the Circle 1136 } 1137 1138 @Test 1139 public void testLocalToScreen() { 1140 Rectangle rect = new Rectangle(); 1141 1142 rect.setTranslateX(10); 1143 rect.setTranslateY(20); 1144 1145 TestScene scene = new TestScene(new Group(rect)); 1146 final TestStage testStage = new TestStage(""); 1147 testStage.setX(100); 1148 testStage.setY(200); 1149 scene.set_window(testStage); 1150 Point2D p = rect.localToScreen(new Point2D(1, 2)); 1151 assertEquals(111.0, p.getX(), 0.0001); 1152 assertEquals(222.0, p.getY(), 0.0001); 1153 Bounds b = rect.localToScreen(new BoundingBox(1, 2, 3, 4)); 1154 assertEquals(111.0, b.getMinX(), 0.0001); 1155 assertEquals(222.0, b.getMinY(), 0.0001); 1156 assertEquals(3.0, b.getWidth(), 0.0001); |