public static Node createIconContent() { StackPane sp = new StackPane(); TilePane iconTilePane = new TilePane(); iconTilePane.setAlignment(Pos.CENTER); Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY); rectangle.setStroke(Color.BLACK); iconTilePane.setPrefSize(rectangle.getWidth(), rectangle.getHeight()); Rectangle[] rec = new Rectangle[9]; for (int i = 0; i < rec.length; i++) { rec[i] = new Rectangle(14, 14, Color.web("#349b00")); TilePane.setMargin(rec[i], new Insets(2, 2, 2, 2)); } iconTilePane.getChildren().addAll(rec); sp.getChildren().addAll(rectangle, iconTilePane); return new Group(sp); }
@Override public void start(Stage stage) throws Exception { TilePane field = generateField(); Scene scene = new Scene(field); stage.setScene(scene); stage.setResizable(false); stage.show(); field.addEventFilter(LightningEvent.PLASMA_STRIKE, event -> log.info("Field filtered strike: " + event.getI() + ", " + event.getJ())); field.addEventHandler(LightningEvent.PLASMA_STRIKE, event -> log.info("Field handled strike: " + event.getI() + ", " + event.getJ())); periodicallyStrikeRandomNodes(field); }
private void periodicallyStrikeRandomNodes(TilePane field) { Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0), event -> strikeRandomNode(field)), new KeyFrame(Duration.seconds(2))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.play(); }
static public void setup_note_pane(ScrollPane scroll_pane, TilePane tile_pane, AnchorPane overlay ){ Note[] list_of_notes = new Note[7]; list_of_notes[0] = new Note("Assign 1", "M rao", "src/GUI/resources/main/writing.png"); list_of_notes[1] = new Note("Assign 1", "M rao", "src/GUI/resources/main/networking.png"); list_of_notes[2] = new Note("Assign 1", "M rao", "src/GUI/resources/main/group.png"); list_of_notes[3] = new Note("Assign 1", "M rao", "src/GUI/resources/main/writing.png"); list_of_notes[4] = new Note("Assign 1", "M rao", "src/GUI/resources/main/group.png"); list_of_notes[5] = new Note("Assign 1", "M rao", "src/GUI/resources/main/networking.png"); list_of_notes[6] = new Note("Assign 1", "M rao", "src/GUI/resources/main/writing.png"); notePane.make_note_pane(scroll_pane, tile_pane); notePane.populate_pane(tile_pane, list_of_notes, overlay); }
@Override public Node drawNode() { tilePane = baseFill(new TilePane()); tilePane.setHgap(5); if (5 != tilePane.getHgap()) { //TODO: we don't verify here that hgap is applied to graphic reportGetterFailure("tilePane.getHgap()"); } tilePane.setVgap(20); if (20 != tilePane.getVgap()) { //TODO: we don't verify here that vgap is applied to graphic reportGetterFailure("tilePane.getVgap()"); } return tilePane; }
@Override public Node drawNode() { tilePane = baseFill(new TilePane()); tilePane.setPadding(new Insets(15, 15, 15, 15)); tilePane.setOrientation(Orientation.VERTICAL); tilePane.setAlignment(Pos.BOTTOM_LEFT);; if (Pos.BOTTOM_LEFT != tilePane.getAlignment()) { reportGetterFailure("tilePane.getVpos()"); } tilePane.setPrefRows(2);// was:.setRows(2); if (2 != tilePane.getPrefRows()) { reportGetterFailure("tilePane.getRows()"); } return tilePane; }
@Override public Node drawNode() { tilePane = baseFill(new TilePane()); // true == vertical tilePane.setPrefColumns(3); tilePane.setAlignment(Pos.BOTTOM_CENTER); for (Node _n : tilePane.getChildren()) { TilePane.setAlignment(_n, Pos.BOTTOM_RIGHT); } /* todo tilePane.setNodeHpos(HPos.RIGHT); if (HPos.RIGHT != tilePane.getNodeHpos()) { reportGetterFailure("tilePane.getNodeHpos()"); } tilePane.setNodeVpos(VPos.BOTTOM); if (VPos.BOTTOM != tilePane.getNodeVpos()) { reportGetterFailure("tilePane.getNodeVpos()"); } */ tilePane.setPrefColumns(3); // was: .setColumns(3); if (3 != tilePane.getPrefColumns()) { reportGetterFailure("tilePane.getColumns()"); } return tilePane; }
public Collection<? extends Node> draw() { List<Node> resultList = new ArrayList<Node>(); Node node; if (0 == actionHolderList.size()) { node = drawNode(); } else { TilePane tilePane = new TilePane(); for (ActionHolder ah : actionHolderList) { Collection<? extends Node> childnodes = ah.draw(); //was: // tilePane.getChildren().add(ah.drawNode()); if (null != childnodes && 0 != childnodes.size()) { tilePane.getChildren().addAll(ah.draw()); } else { tilePane.getChildren().add(ah.drawNode()); } } node = tilePane; } resultList.add(node); return resultList; }
private void initRootLayout() { try { // Load root layout from fxml file. FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("/fiji/plugin/filamentdetector/gui/view/RootLayout.fxml")); rootLayout = (TilePane) loader.load(); // Show the scene containing the root layout. Scene scene = new Scene(rootLayout); this.primaryStage.setScene(scene); this.primaryStage.show(); } catch (IOException e) { e.printStackTrace(); } }
public void initFX(JFXPanel fxPanel) { // Init the root layout try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("/net/imagej/plugin/minimalJavaFXPlugin/gui/view/RootLayout.fxml")); TilePane rootLayout = (TilePane) loader.load(); // Get the controller and add an ImageJ context to it. RootLayoutController controller = loader.getController(); controller.setContext(ij.context()); // Show the scene containing the root layout. Scene scene = new Scene(rootLayout); this.fxPanel.setScene(scene); this.fxPanel.show(); // Resize the JFrame to the JavaFX scene this.setSize((int) scene.getWidth(), (int) scene.getHeight()); } catch (IOException e) { e.printStackTrace(); } }
@Override public void initialize(URL url, ResourceBundle resourceBundle) { peonTile = new TilePane(8, 8); peonScroll = new ScrollPane(peonTile); peonTile.setMaxHeight(500); peonTile.setMaxWidth(300); peonTile.getStylesheets().add("css/PeonInterface.css"); peonTile.getStyleClass().add("Tilepane"); peonScroll.getStylesheets().add("css/PeonInterface.css"); peonScroll.getStyleClass().add("Scrollpane"); peonScroll.setPrefViewportHeight(412); peonScroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); // Horizontal scroll bar peonScroll.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); // Vertical scroll bar peonScroll.setFitToHeight(true); peonScroll.setFitToWidth(true); peonScroll.setContent(peonTile); toggleAllPeons.setToggleGroup(group); toggleAllIdle.setToggleGroup(group); toggleAllMiners.setToggleGroup(group); toggleAllGuards.setToggleGroup(group); toggleAllGatherers.setToggleGroup(group); KeyboardHandler.getInstance().setPeonSelectHandler(this); instance = this; }
/** * update the list of items displayed to user * @param items * @param container * @param handler */ public void updateView(ArrayList<FSItem> items, TilePane container, EventHandler<MouseEvent> handler) { container.getChildren().clear(); for (FSItem item : items) { if(!item.getItemProperties().isHidden()){ VBox tile = new VBox(); tile.setAlignment(Pos.CENTER); tile.addEventHandler(MouseEvent.MOUSE_CLICKED, handler); Label l = new Label(item.getItemProperties().getItemName()); l.setAlignment(Pos.CENTER); l.setCenterShape(true); l.setMaxWidth(120); l.setMaxHeight(100); //l.setWrapText(true); ImageView i = new ImageView(item.getIcon().getIconImage()); i.setFitHeight(32); i.setFitWidth(32); tile.getChildren().addAll(i, l); container.getChildren().add(tile); } } }
/** Create a TilePane for each WidgetCategory * @param parent Parent Pane * @return Map of panes for each category */ private Map<WidgetCategory, Pane> createWidgetCategoryPanes(final Pane parent) { final Map<WidgetCategory, Pane> palette_groups = new HashMap<>(); for (final WidgetCategory category : WidgetCategory.values()) { final TilePane palette_group = new TilePane(); palette_group.getStyleClass().add("palette_group"); palette_group.setPrefColumns(1); palette_group.setMaxWidth(Double.MAX_VALUE); palette_groups.put(category, palette_group); palette_group.setHgap(2); palette_group.setVgap(2); final TitledPane pane = new TitledPane(category.getDescription(), palette_group); pane.getStyleClass().add("palette_category"); parent.getChildren().add(pane); } return palette_groups; }
@Override public void start(final Stage stage) { final TilePane layout = new TilePane(); layout.setPrefColumns(3); final RGBFactory colors = new RGBFactory(); int index = 0; for (int row=0; row<20; ++row) for (int col=0; col<3; ++col) { final Color color = colors.next(); final Label text = new Label("COLOR " + (++index) + ": " + color); text.setTextFill(color); layout.getChildren().add(text); } final Scene scene = new Scene(layout); stage.setScene(scene); stage.show(); }
@Override public Node adjust(Node node, double scale) { requireNonNull(node); requireValidScale(scale); if (node instanceof TilePane) { TilePane tilePane = (TilePane) node; tilePane.prefTileWidthProperty().set(multiplyByScale(tilePane.prefTileWidthProperty().get(), scale)); tilePane.prefTileHeightProperty().set(multiplyByScale(tilePane.prefTileHeightProperty().get(), scale)); tilePane.hgapProperty().set(tilePane.hgapProperty().multiply(scale).get()); tilePane.vgapProperty().set(tilePane.vgapProperty().multiply(scale).get()); } return super.adjust(node, scale); }
private ScrollPane buildContent() { final ScrollPane scrollPane = new ScrollPane(); scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER); scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS); scrollPane.setFitToHeight(true); scrollPane.setFitToWidth(true); final TilePane pane = new TilePane(); pane.setOnScroll(scrollEvent -> { final double deltaY = scrollEvent.getDeltaY() * 2.0D; final double height = BrowserTab.this.getCustomContent().getBoundsInLocal().getHeight(); final double vValue = BrowserTab.this.getCustomContent().getVvalue(); BrowserTab.this.getCustomContent().setVvalue(vValue - deltaY / height); }); pane.setPrefColumns(PREFERED_COLUMNS); pane.setVgap(ITEM_GAP); pane.setHgap(ITEM_GAP); pane.setPadding(new Insets(ITEM_GAP)); this.activeItemsProperty().addListener((ListChangeListener.Change<? extends ITwitchItem> c) -> pane .getChildren().setAll(convertToNodeList(this.activeItemsProperty().get()))); scrollPane.setContent(pane); return scrollPane; }
@Override public void start(Stage stage) throws Exception { Group root = new Group(); root.getStyleClass().add("mainStage"); Scene scene = new Scene(root, 1024, 600, Color.CORNSILK); scene.getStylesheets().add("styles/geometrydemo.css"); TilePane tp = new TilePane(); tp.setPrefColumns(2); tp.setVgap(30); tp.setHgap(15); tp.setPadding(new Insets(10)); tp.getChildren().addAll(getNode1()); tp.getChildren().addAll(getNode2()); tp.getChildren().addAll(getNode3()); root.getChildren().addAll( tp ); stage.setTitle("JavaFx Geometry Demo"); stage.setScene(scene); stage.show(); }
private TilePane createButtonRow() { // Let buttons grow, otherwise they will be different sizes based // on the length of the label btnApply.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); btnContinue.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); btnExit.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); TilePane tileButtons = new TilePane(Orientation.HORIZONTAL); tileButtons.setPadding(new Insets(20, 10, 20, 0)); tileButtons.setHgap(10.0); tileButtons.setVgap(8.0); // In case window is reduced and buttons // require another row tileButtons.getChildren().addAll(btnApply, btnContinue, btnExit); return tileButtons; }
@Override public void start(Stage stage) throws Exception { Group root = new Group(); Scene scene = new Scene(root, 1050, 600, Color.BISQUE); scene.getStylesheets().add("styles/sample.css"); TilePane tp = new TilePane(); tp.setPrefColumns(3); tp.getChildren().add( ScrollBarElement.getScrollPane()); //tp.getChildren().add( ListElement.getSimpleList()); //tp.getChildren().add( ListElement.getHSimpleList()); tp.getChildren().add( TableElement.getTable()); //tp.getChildren().add( getForm()); //tp.getChildren().add( TableElement.getSimpleTable()); root.getChildren().addAll(tp); stage.setTitle("JavaFx UI Controls Demo"); stage.setScene(scene); stage.show(); }
MultiKeyPopup() { buttonPane = new TilePane(); buttonPane.getStyleClass().add(DEFAULT_STYLE_CLASS); buttonPane.setFocusTraversable(false); buttonPane.getChildren().addListener((ListChangeListener<Node>) c -> { while (c.next()) { if (c.wasPermutated() || !c.wasAdded()) { continue; } c.getAddedSubList().forEach(node -> { node.setFocusTraversable(false); if (node instanceof ButtonBase) { ((ButtonBase) node).setOnAction(event -> hide()); } }); } }); getContent().add(buttonPane); setAutoFix(true); setAutoHide(true); }
/** * Initializes utilities buttons. */ private void initUtilButtons() { // Create Buttons and Pane createCentricButtons(); createPauseButton(); createRefreshButton(); TilePane utilButtonsPane = createUtilPane(); // Align and assign to Layout Pane AnchorPane.setLeftAnchor(utilButtonsPane, BORDER_SPACING); AnchorPane.setRightAnchor(utilButtonsPane, BORDER_SPACING); AnchorPane.setBottomAnchor(utilButtonsPane, BORDER_SPACING_BOTTOM); utilButtonsPane.setAlignment(Pos.BOTTOM_CENTER); m_layoutPane.getChildren().add(utilButtonsPane); }
private Node createLoadPane() { loadPane = new TilePane(5, 5); loadPane.setPrefColumns(3); loadPane.setPadding(new Insets(5)); for (int i = 0; i < 9; i++) { StackPane waitingPane = new StackPane(); Rectangle background = new Rectangle((380) / 3, (380) / 3, Color.WHITE); indicators[i] = new ProgressIndicator(); indicators[i].setPrefSize(50, 50); indicators[i].setMaxSize(50, 50); indicators[i].setTranslateY(-25); indicators[i].setTranslateX(-10); loading[i] = new Label(); loading[i].setTranslateY(25); waitingPane.getChildren().addAll(background, indicators[i], loading[i]); loadPane.getChildren().add(waitingPane); } return loadPane; }
public CursorSample() { TilePane tilePaneRoot = new TilePane(5, 5); tilePaneRoot.setHgap(2); tilePaneRoot.setVgap(2); tilePaneRoot.getChildren().addAll( createBox(Cursor.DEFAULT), createBox(Cursor.CROSSHAIR), createBox(Cursor.TEXT), createBox(Cursor.WAIT), createBox(Cursor.SW_RESIZE), createBox(Cursor.SE_RESIZE), createBox(Cursor.NW_RESIZE), createBox(Cursor.NE_RESIZE), createBox(Cursor.N_RESIZE), createBox(Cursor.S_RESIZE), createBox(Cursor.W_RESIZE), createBox(Cursor.E_RESIZE), createBox(Cursor.OPEN_HAND), createBox(Cursor.CLOSED_HAND), createBox(Cursor.HAND), createBox(Cursor.DISAPPEAR), createBox(Cursor.MOVE), createBox(Cursor.H_RESIZE), createBox(Cursor.V_RESIZE), createBox(Cursor.NONE) ); getChildren().add(tilePaneRoot); }
public TilePaneSample() { TilePane tilePane = new TilePane(); tilePane.setPrefColumns(3); //preferred columns Button[] buttons = new Button[18]; for (int j = 0; j < buttons.length; j++) { buttons[j] = new Button("button" + (j + 1), new ImageView(ICON_48)); tilePane.getChildren().add(buttons[j]); } getChildren().add(tilePane); }
protected void setTabView(String path, TilePane tP, TextField tF) { this.tilePane = tP; this.txtDirPath = tF; tilePane.getChildren().clear(); txtDirPath.setText(path); generateIcons(); }
private void strikeRandomNode(TilePane field) { LightningReactor struckNode = (LightningReactor) field.getChildren() .get(random.nextInt(FIELD_SIZE * FIELD_SIZE)); LightningEvent lightningStrike = new LightningEvent(this, struckNode); struckNode.fireEvent(lightningStrike); }
private TilePane generateField() { TilePane field = new TilePane(); field.setPrefColumns(10); field.setMinWidth(TilePane.USE_PREF_SIZE); field.setMaxWidth(TilePane.USE_PREF_SIZE); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { field.getChildren().add(new LightningReactor(i, j, new StrikeEventHandler())); } } return field; }
static public void setup_course_pane(ScrollPane scroll_pane, TilePane tile_pane, AnchorPane overlay ){ ArrayList<Course> list_of_courses = new ArrayList<Course>(); /* backend get List of courses */ /* get Courses info from backend */ List<HashMap<String,String>> backend_course_list = Backend.getcourses(); System.out.println(backend_course_list); String[] course_icon_list = {"src/GUI/resources/main/courseIcons/cpp.png", "src/GUI/resources/main/courseIcons/chemistry.png", "src/GUI/resources/main/courseIcons/electronics.png", "src/GUI/resources/main/courseIcons/java.png", "src/GUI/resources/main/courseIcons/biology.png"}; Random r = new Random(); for (HashMap<String, String> entry : backend_course_list) { String course_name = entry.get("NAME"); String course_id = entry.get("COURSEID"); String course_icon = course_icon_list[ r.nextInt(course_icon_list.length) ]; System.out.println(course_icon); System.out.println(course_name); Course crs = new Course(course_name, "Instructor", course_icon, course_id ); list_of_courses.add(crs); } coursePane.make_course_pane(scroll_pane, tile_pane); coursePane.populate_pane(tile_pane, list_of_courses, overlay); /* set Tab icons */ }
public static void populate_pane(TilePane tile_pane, ArrayList<Course> list_of_courses, AnchorPane overlay){ list_of_courses.stream().map((crs) -> new courseCard(crs, overlay)).map((card) -> { card.set_on_touch_callback_default( ); return card; }).forEachOrdered((card) -> { tile_pane.getChildren().add( card ); }); }
public static void populate_pane(TilePane tile_pane, Note[] list_of_notes, AnchorPane overlay){ for (Note nt: list_of_notes) { noteCard card = new noteCard(nt, overlay); card.set_on_touch_callback_default( ); tile_pane.getChildren().add( card ); } }
public static void populate_pane(TilePane tile_pane, ArrayList<Assignment> list_of_assignments, AnchorPane overlay){ for (Assignment asn : list_of_assignments) { assignmentCard card = new assignmentCard(asn, overlay); card.set_on_touch_callback_default( ); tile_pane.getChildren().add( card ); } }
public static void populate_pane(TilePane tile_pane, ArrayList<Forum> list_of_forums){ tile_pane.getChildren().clear(); for(Forum frm: list_of_forums){ forumCard card = new forumCard(frm); tile_pane.getChildren().add( card ); } }
protected TilePane baseFill(TilePane tilePane) { controls.clear(); for ( int k=0; k<2; ++k) { controls.add(page.createNode()); } tilePane.getChildren().addAll(controls); tilePane.setPrefSize(310, 310); tilePane.setMinSize(310, 310); if (withStyle) { tilePane.setStyle("-fx-border-color: darkgray;"); } return tilePane; }
@Override public Node drawNode() { pane = baseFill(new TilePane()); pane.setHgap(5); pane.setVgap(20); return pane; }