/* * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any */ package test.scenegraph.app; import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.layout.GridPane; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class BugAppGrid1 extends Application { Group root = new Group(); private void init(Stage primaryStage) { primaryStage.setScene(new Scene(root)); primaryStage.setHeight(200); } @Override public void start(Stage primaryStage) throws Exception { init(primaryStage); primaryStage.show(); root.getChildren().add(drawNode()); } GridPane pane; public static Color nodeColors[] = {Color.RED, Color.YELLOW, Color.BLUE, Color.GREEN, Color.BROWN, Color.MAGENTA}; public static Pane stFill(Pane pane) { GridPane gridPane = (GridPane) pane; for (int i = 1; i < nodeColors.length; ++i) { int k = i - 1; Circle nonresizeable = new Circle(5 + 3 * ((i) % 4)); //Node nonresizeable.setFill(nodeColors[i]); GridPane.setColumnIndex(nonresizeable, k % 4); GridPane.setRowIndex(nonresizeable, k < 4 ? 0 : 1); gridPane.getChildren().add(nonresizeable); } // add first circle Circle nonresizeable0 = new Circle(5 + 3 * ((0) % 4)); //Node nonresizeable0.setFill(nodeColors[0]); GridPane.setColumnIndex(nonresizeable0, (nodeColors.length - 1) % 4); GridPane.setRowIndex(nonresizeable0, (nodeColors.length - 1) < 4 ? 0 : 1); gridPane.getChildren().add(nonresizeable0); StackPane sp = new StackPane(); sp.setPadding(new Insets(4,4,4,4)); Rectangle b2 = new Rectangle(0, 0, 40, 12); b2.setFill(Color.GREEN); sp.getChildren().add(b2); GridPane.setColumnIndex(sp, (nodeColors.length % 4)); GridPane.setRowIndex(sp, (nodeColors.length < 4)? 0 : 1); gridPane.getChildren().add(sp); return pane; } protected GridPane baseFill(GridPane pane) { pane.setPrefSize(130, 130); pane.setGridLinesVisible(true); stFill(pane); // if (withStyle) { pane.setStyle("-fx-border-color: darkgray;"); // } return pane; } public Node drawNode() { pane = baseFill(new GridPane()); pane.setAlignment(Pos.CENTER_RIGHT); StackPane sp = new StackPane(); sp.setPadding(new Insets(4, 4, 4, 4)); Rectangle b2 = new Rectangle(0, 0, 14, 16); b2.setFill(Color.GREEN); sp.getChildren().add(b2); GridPane.setRowIndex(sp, 0); GridPane.setColumnIndex(sp, 4); GridPane.setRowSpan(sp, 2); pane.getChildren().add(sp); return pane; } public static void main(String[] args) { launch(args); } }