12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
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 test.javafx.scene.chart;
27
28 import org.junit.Before;
29
30 import test.com.sun.javafx.pgstub.StubToolkit;
31 import com.sun.javafx.tk.Toolkit;
32 import javafx.scene.Scene;
33 import javafx.scene.chart.Chart;
34 import javafx.stage.Stage;
35 import javafx.scene.layout.Region;
36 import javafx.scene.shape.*;
37
38
39 public abstract class ChartTestBase {
40 private Scene scene;
41 private Stage stage;
42 StubToolkit toolkit = (StubToolkit) Toolkit.getToolkit();
43 private Chart chart;
44
45 @Before
46 public void setUp() {
47 chart = createChart();
48 chart.setAnimated(false);
49 }
50
51 protected void startApp() {
52 scene = new Scene(chart,800,600);
53 stage = new Stage();
54 stage.setScene(scene);
55 stage.show();
56 toolkit.setAnimationTime(0);
57 pulse();
62 }
63
64 protected Scene getTestScene() {
65 return this.scene;
66 }
67
68 protected void setTestScene(Scene scene) {
69 this.scene = scene;
70 }
71
72 protected Stage getTestStage() {
73 return this.stage;
74 }
75
76 protected void setTestStage(Stage stage) {
77 this.stage = stage;
78 }
79
80 protected abstract Chart createChart();
81
82 StringBuffer computeSVGPath(Path line) {
83 StringBuffer str = new StringBuffer();
84 for(PathElement pe : line.getElements()) {
85 if (pe instanceof LineTo) {
86 str.append("L"+((LineTo)pe).getX()+" "+((LineTo)pe).getY()+" ");
87 }
88 }
89 return str;
90 }
91
92 StringBuffer computeBoundsString(Region r1, Region r2, Region r3) {
93 StringBuffer str = new StringBuffer();
94 str.append(Math.round(r1.getLayoutX())
95 +" "+Math.round(r1.getLayoutY())+" "+Math.round(r1.getWidth())+
96 " "+Math.round(r1.getHeight())+" ");
97 str.append(Math.round(r2.getLayoutX())
98 +" "+Math.round(r2.getLayoutY())+" "+Math.round(r2.getWidth())+
99 " "+Math.round(r2.getHeight())+" ");
100 str.append(Math.round(r3.getLayoutX())
101 +" "+Math.round(r3.getLayoutY())+" "+Math.round(r3.getWidth())+
102 " "+Math.round(r3.getHeight())+" ");
103 return str;
104 }
105 }
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
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 test.javafx.scene.chart;
27
28 import org.junit.Before;
29
30 import test.com.sun.javafx.pgstub.StubToolkit;
31 import com.sun.javafx.tk.Toolkit;
32 import java.util.Arrays;
33 import javafx.scene.Node;
34 import javafx.scene.Scene;
35 import javafx.scene.chart.Chart;
36 import javafx.stage.Stage;
37 import javafx.scene.layout.Region;
38 import javafx.scene.shape.*;
39 import static org.junit.Assert.assertTrue;
40
41 public abstract class ChartTestBase {
42 private Scene scene;
43 private Stage stage;
44 StubToolkit toolkit = (StubToolkit) Toolkit.getToolkit();
45 private Chart chart;
46
47 @Before
48 public void setUp() {
49 chart = createChart();
50 chart.setAnimated(false);
51 }
52
53 protected void startApp() {
54 scene = new Scene(chart,800,600);
55 stage = new Stage();
56 stage.setScene(scene);
57 stage.show();
58 toolkit.setAnimationTime(0);
59 pulse();
64 }
65
66 protected Scene getTestScene() {
67 return this.scene;
68 }
69
70 protected void setTestScene(Scene scene) {
71 this.scene = scene;
72 }
73
74 protected Stage getTestStage() {
75 return this.stage;
76 }
77
78 protected void setTestStage(Stage stage) {
79 this.stage = stage;
80 }
81
82 protected abstract Chart createChart();
83
84 String computeSVGPath(Path line) {
85 StringBuilder str = new StringBuilder();
86 for (PathElement pe : line.getElements()) {
87 if (pe instanceof LineTo) {
88 str.append("L").append(((LineTo)pe).getX()).append(" ")
89 .append(((LineTo)pe).getY()).append(" ");
90 }
91 }
92 return str.toString();
93 }
94
95 String computeBoundsString(Region r1, Region r2, Region r3) {
96 StringBuilder str = new StringBuilder();
97 str.append(Math.round(r1.getLayoutX())).append(" ")
98 .append(Math.round(r1.getLayoutY())).append(" ")
99 .append(Math.round(r1.getWidth())).append(" ")
100 .append(Math.round(r1.getHeight())).append(" ");
101 str.append(Math.round(r2.getLayoutX())).append(" ")
102 .append(Math.round(r2.getLayoutY())).append(" ")
103 .append(Math.round(r2.getWidth())).append(" ")
104 .append(Math.round(r2.getHeight())).append(" ");
105 str.append(Math.round(r3.getLayoutX())).append(" ")
106 .append(Math.round(r3.getLayoutY())).append(" ")
107 .append(Math.round(r3.getWidth())).append(" ")
108 .append(Math.round(r3.getHeight())).append(" ");
109 return str.toString();
110 }
111
112 void checkStyleClass(Node item, String... styleClass) {
113 assertTrue("\"" + item.getStyleClass() + "\" doesn't contain all of the " +
114 Arrays.toString(styleClass),
115 item.getStyleClass().containsAll(Arrays.asList(styleClass)));
116 }
117 }
|