private void refresh() { tilePane.getChildren().clear(); map = LibraryLoader.getMappedItems(); for (String s : map.keySet()) { LibraryEntry e = new LibraryEntry(map.get(s), new File(s)); tilePane.getChildren().add(e); } }
private void updateChildren(boolean useButtons) { hboxLayout.getChildren().clear(); hboxLayout.getChildren().addAll(createChildren(useButtons)); vboxLayout.getChildren().clear(); vboxLayout.getChildren().addAll(createChildren(useButtons)); flowLayout.getChildren().clear(); flowLayout.getChildren().addAll(createChildren(useButtons)); List<Node> contents1 = createChildren(useButtons); gridLayout.getChildren().clear(); gridLayout.add(contents1.get(0), 0, 0); gridLayout.add(contents1.get(1), 1, 0); gridLayout.add(contents1.get(2), 0, 1, 2, 1); List<Node> contents = createChildren(useButtons); borderLayout.getChildren().clear(); borderLayout.setLeft(contents.get(0)); borderLayout.setTop(contents.get(1)); borderLayout.setRight(contents.get(2)); borderLayout.setBottom(contents.get(3)); borderLayout.setCenter(contents.get(4)); stackLayout.getChildren().clear(); stackLayout.getChildren().addAll(createChildren(useButtons)); tileLayout.getChildren().clear(); tileLayout.getChildren().addAll(createChildren(useButtons)); }
@Test public void testSceneSizeWithContentBiasOnRoot() { Rectangle r1 = new Rectangle(20, 20); Rectangle r2 = new Rectangle(20, 20); Rectangle r3 = new Rectangle(100, 20); TilePane tilePane = new TilePane(); tilePane.getChildren().addAll(r1, r2); final VBox root = new VBox(); root.getChildren().addAll(tilePane, r3); Scene scene = new Scene(root); stage.setScene(scene); assertEquals(100, (int) scene.getWidth()); assertEquals(40, (int) scene.getHeight()); }
@Override public void initialize(URL url, ResourceBundle rb) { // TODO // tilePane.setPrefColumns(4); tilePane.setHgap(5); tilePane.setVgap(15); tilePane.setPrefTileHeight(85); tilePane.setPrefTileWidth(150); tilePane.setPadding(new Insets(5, 5, 15, 5)); map = LibraryLoader.getMappedItems(); for (String s : map.keySet()) { LibraryEntry e = new LibraryEntry(map.get(s), new File(s)); libEntries.add(e); } tilePane.getChildren().addAll(libEntries); }
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; }
@FXML public void handleOk() { String tituloAux = titulo.getText().replaceAll(" ", "+").toLowerCase(); String toJson = readUrl(BASE + tituloAux + "&type=series" + "&r=json"); resultados.getChildren().clear(); try { JSONObject busqueda = new JSONObject(toJson); if (busqueda.getString("Response").equals("True")) { JSONArray res = busqueda.getJSONArray("Search"); resultados.setPrefRows(res.length()); for (int i = 0; i < res.length(); i++) { JSONObject resActual = new JSONObject(res.get(i).toString()); HBox resultadoActual = new HBox(50); resultadoActual.setMaxWidth(Double.MAX_VALUE); resultadoActual.setAlignment(Pos.CENTER_LEFT); ImageView posterActual = new ImageView(); try { Image image = new Image(resActual.getString("Poster")); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } catch (IllegalArgumentException e) { // System.out.println("Bad url"); Image image = new Image(MainApp.class.getResource("resources/no-image.png").toExternalForm()); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } String details; String nomSerie = new String(resActual.getString("Title").getBytes(), "UTF-8"); String anoSerie = new String(resActual.getString("Year").getBytes(), "UTF-8"); if (nomSerie.length() > 15) { details = "%-12.12s...\t\t Año: %-10s"; } else { details = "%-12s\t\t Año: %-10s"; } details = String.format(details, nomSerie, anoSerie); Label elemento = new Label(details); elemento.setMaxWidth(Double.MAX_VALUE); elemento.setMaxHeight(Double.MAX_VALUE); resultadoActual.getChildren().add(elemento); posterActual.setId(resActual.getString("imdbID")); posterActual.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { ImageView clickedButton = (ImageView) event.getSource(); Stage stage = (Stage) clickedButton.getScene().getWindow(); Task task = new Task() { @Override protected Object call() throws Exception { mainController.mainApp.scene.setCursor(Cursor.WAIT); Serie toAdd = new Serie(clickedButton.getId()); boolean possible = true; for (Serie serie : mainController.getSeries()) { if (serie.equals(toAdd)) possible = false; } if (possible) mainController.getSeries().add(toAdd); try { mainController.populateImagenes(); mainController.showDetallesMes(mainController.getMesActual()); } catch (Exception e) { e.printStackTrace(); } finally { mainController.mainApp.scene.setCursor(Cursor.DEFAULT); return mainController.getSeries(); } } }; Thread th = new Thread(task); th.setDaemon(true); th.start(); stage.close(); } }); resultados.getChildren().add(resultadoActual); } } else { resultados.getChildren().add(new Label("La busqueda no obtuvo resultados")); } } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException ex) { Logger.getLogger(NewSerieController.class.getName()).log(Level.SEVERE, null, ex); } }