public ProcessingAnimationView( ProcessingAnimationModel animationModel) { // ProcessingAnimationModel animationModel, MachineTestController // testController) { this.processingAnimationModel = animationModel; // this.machineTestController = testController; imageViewTop = new ImageView(); imageViewTop.setFitWidth(270); imageViewTop.setFitHeight(100); imageViewTop.setX(200); imgTop = new Image("file:Image\\animation\\presTop.png"); imageViewTop.setImage(imgTop); imageViewBot = new ImageView(); imageViewBot.setTranslateY(40); imageViewBot.setFitWidth(270); imageViewBot.setFitHeight(300); imgBot = new Image("file:Image\\animation\\presBot.png"); imageViewBot.setPreserveRatio(true); imageViewBot.setX(200); imageViewBot.setImage(imgBot); Image imgStorage = new Image("file:Image\\animation\\storage.png"); imageViewLeftStorage = new ImageView(); imageViewLeftStorage.setFitWidth(200); imageViewLeftStorage.setFitHeight(80); imageViewLeftStorage.setY(185); imageViewLeftStorage.setImage(imgStorage); imageViewRightStorage = new ImageView(); imageViewRightStorage.setFitWidth(200); imageViewRightStorage.setFitHeight(80); imageViewRightStorage.setY(185); imageViewRightStorage.setX(500); imageViewRightStorage.setImage(imgStorage); rectangle = new Rectangle(340, 185, 15, 5); // rectangle.setVisible(false); rectangle.setFill(Color.CORAL); circle = new Circle(190, 180, 10); circle.setFill(Color.CORAL); this.getChildren() .addAll( imageViewLeftStorage, imageViewRightStorage, rectangle, circle, imageViewBot, imageViewTop); this.setMinSize(300, 300); timeline = new Timeline(); transitionCircle = new TranslateTransition(); transitionRect = new TranslateTransition(); products = new Stack<>(); }
/* * Resize the image, preserving the aspect ratio if only the height or width is provided, otherwise scale * based on the height and width provided. */ private void resizeImage(ImageView imageView, Integer widthSize, Integer heightSize) { if (widthSize == null && heightSize != null) { iv1.setPreserveRatio(true); imageView.setFitHeight(heightSize); } else if (widthSize != null && heightSize == null) { iv1.setPreserveRatio(true); imageView.setFitWidth(widthSize); } else { imageView.setFitWidth(widthSize); imageView.setFitHeight(heightSize); } }
private void fitToScreen() { if (mImage.getWidth() < 1100 || mImage.getHeight() < 1100) { mImageView.setFitWidth(1100); mImageView.setFitHeight(1100); } else { mImageView.setFitWidth(mImage.getWidth()); mImageView.setFitHeight(mImage.getHeight()); } mImageView.setPreserveRatio(true); mImageView.setSmooth(true); mImageView.setCache(true); mImageView.setImage(mImage); }
private void configureButton(final ImageView imageView) { imageView.setFitHeight(32); imageView.setFitWidth(32); imageView.setPreserveRatio(true); imageView.setSmooth(true); imageView.getStyleClass().add("launcherIcon"); }
public void openImageFile(Resource resource) { Tab tab = new Tab(); tab.setClosable(true); if (resource == null) { Dialogs.create() .owner(tabPane) .title("Datei nicht vorhanden") .message( "Die angeforderte Datei ist nicht vorhanden und kann deshalb nicht geöffnet werden.") .showError(); return; } tab.setText(resource.getFileName()); ImageResource imageResource = (ImageResource) resource; ImageViewerPane pane = new ImageViewerPane(); pane.setImageResource(imageResource); ImageView imageView = pane.getImageView(); imageView.setImage(imageResource.asNativeFormat()); imageView.setFitHeight(-1); imageView.setFitWidth(-1); Label imagePropertiesLabel = pane.getImagePropertiesLabel(); imagePropertiesLabel.setText(imageResource.getImageDescription()); tab.setContent(pane); tab.setUserData(resource); tabPane.getTabs().add(tab); tabPane.getSelectionModel().select(tab); }
@SuppressWarnings("JavadocMethod") public ProjectSettingsEditor( Parent root, ProjectSettings projectSettings, AppSettings appSettings) { super(); VBox content = new VBox( new CustomPropertySheet(BeanPropertyUtils.getProperties(projectSettings)), new Separator(), new CustomPropertySheet(BeanPropertyUtils.getProperties(appSettings))); content.setSpacing(5.0); DialogPane pane = getDialogPane(); pane.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); pane.setContent(content); pane.styleProperty().bind(root.styleProperty()); pane.getStylesheets().addAll(root.getStylesheets()); pane.setPrefSize(DPIUtility.SETTINGS_DIALOG_SIZE, DPIUtility.SETTINGS_DIALOG_SIZE); ImageView graphic = new ImageView(new Image(getClass().getResourceAsStream("icons/settings.png"))); graphic.setFitWidth(DPIUtility.SMALL_ICON_SIZE); graphic.setFitHeight(DPIUtility.SMALL_ICON_SIZE); setTitle("Settings"); setHeaderText("Settings"); setGraphic(graphic); setResizable(true); }
public ImageView getIcon() { Image image = FileFetch.getImageFromFile("pin56_small.svg", 22, 22, true, true); ImageView imageView = new ImageView(image); imageView.setFitHeight(22); imageView.setFitWidth(22); return imageView; }
public AlertHandler(String message, EventHandler<ActionEvent> confirmHandler) { super(14); // add controls to the popup. final Label promptMessage = new Label(message); final ImageView alertImage = new ImageView(ResourceUtil.getImage("alert_48.png")); alertImage.setFitHeight(32); alertImage.setPreserveRatio(true); promptMessage.setGraphic(alertImage); promptMessage.setWrapText(true); promptMessage.setPrefWidth(350); // action button text setup. HBox buttonBar = new HBox(20); final Button confirmButton = new Button(getString("dialog.continue")); confirmButton.setDefaultButton(true); buttonBar.getChildren().addAll(confirmButton); // layout the popup. setPadding(new Insets(10)); getStyleClass().add("alert-dialog"); getChildren().addAll(promptMessage, buttonBar); final DropShadow dropShadow = new DropShadow(); setEffect(dropShadow); // confirm and close the popup. confirmButton.setOnAction(confirmHandler); }
private ImageView createDropboxIconView() { Image dropboxIcon = new Image(dropboxIconPath); ImageView dropboxIconView = new ImageView(dropboxIcon); dropboxIconView.setFitWidth(imageWidth); dropboxIconView.setFitHeight(imageHeight); return dropboxIconView; }
private void instanciateWidgets() { eventHandler = new DocumentConfigurationScreenEventHandler(this); btnAddFromFS = new Button(properties.getProperty("add_from_hard_drive")); btnAddFromFS.setPrefSize(300, 80); btnAddFromFS.setOnAction(eventHandler); Image i = new Image(getClass().getResourceAsStream(properties.getProperty("ico_library_root"))); ImageView iv = new ImageView(i); iv.setSmooth(true); iv.setFitWidth(64); iv.setFitHeight(64); btnAddFromFS.setGraphic(iv); btnAddFromScanner = new Button(properties.getProperty("add_scan")); btnAddFromScanner.setPrefSize(300, 80); btnAddFromScanner.setOnAction(eventHandler); Image i2 = new Image(getClass().getResourceAsStream(properties.getProperty("ico_scan"))); ImageView iv2 = new ImageView(i2); iv2.setSmooth(true); iv2.setFitWidth(64); iv2.setFitHeight(64); btnAddFromScanner.setGraphic(iv2); docInfoEditor = new DocumentInfoEditor(); docInfoEditor.getEventHandler().addDocumentInfoEditorListener(eventHandler); btnSubmit = new Button(properties.getProperty("save")); btnSubmit.setPrefSize(250, 80); btnSubmit.setOnAction(eventHandler); Image i3 = new Image(getClass().getResourceAsStream(properties.getProperty("ico_save"))); ImageView iv3 = new ImageView(i3); iv3.setSmooth(true); iv3.setFitWidth(64); iv3.setFitHeight(64); btnSubmit.setGraphic(iv3); btnSubmit.setDisable(true); documentPreviewer = new DocumentPreviewer(this); documentPreviewer.getEventHandler().addDocumentPreviewListener(eventHandler); documentPreviewer.setEditionMode(true); }
private void gamePicture() throws FileNotFoundException { ImageView coloredBoxImg = new ImageView(new Image(new FileInputStream("lib/" + selectedGame + ".png"))); coloredBoxImg.setFitHeight(gamePicture.getPrefHeight() - 25); coloredBoxImg.setFitWidth(gamePicture.getPrefWidth() - 25); gamePicture.setGraphic(coloredBoxImg); gamePicture.setStyle(buttonStyle); }
/** * Method to configure the {@link ButtonBase} size and graphic to use the {@link Image} in a * consistent style for toolbox buttons. * * @param button the {@link ButtonBase} to configure. * @param image the {@link Image} to apply. */ public void styleButtonSize(ButtonBase button, Image image) { ImageView view = new ImageView(image); view.setFitHeight(BUTTON_WIDTH); view.setFitWidth(BUTTON_HEIGHT); button.setGraphic(view); button.setPrefSize(BUTTON_WIDTH, BUTTON_HEIGHT); button.setMaxWidth(BUTTON_WIDTH); button.setMaxHeight(BUTTON_HEIGHT); button.setAlignment(Pos.CENTER); } // End Method
private BuddyCell() { iconLabel = new ImageView(); iconLabel.setFitHeight(20); iconLabel.setFitWidth(20); getChildren().add(iconLabel); nameLabel = new Label(); nameLabel.setMaxWidth(Double.MAX_VALUE); HBox.setHgrow(nameLabel, Priority.ALWAYS); getChildren().add(nameLabel); onlineCheckBox = new CheckBox(); getChildren().add(onlineCheckBox); }
/** * Update the GUI to show a specified page. * * @param page */ private void showPage(int page) { // Check in range if (page > pdf.getPageCount()) { return; } if (page < 1) { return; } // Store pageNumber = page; // Show/hide buttons as neccessary if (page == pdf.getPageCount()) { next.setVisible(false); } else { next.setVisible(true); } if (page == 1) { back.setVisible(false); } else { back.setVisible(true); } // Calculate scale int pW = pdf.getPdfPageData().getCropBoxWidth(page); int pH = pdf.getPdfPageData().getCropBoxHeight(page); Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); s.setSize(maxSize.getWidth(), maxSize.getHeight()); double xScale = (double) s.width / pW; double yScale = (double) s.height / pH; double scale = xScale < yScale ? xScale : yScale; // Work out target size pW *= scale; pH *= scale; // Get image and set Image i = getPageAsImage(page, pW, pH); imageView.setImage(i); // Set size of components imageView.setFitWidth(pW); imageView.setFitHeight(pH); }
private void markNodeAsInvalid(Node node) { TreeItem<Node> invalidItem = findItem(node); if (invalidItem != null) { ImageView exclaimImage = new ImageView("/images/red_exclamation.png"); exclaimImage.setFitHeight(20); exclaimImage.setFitWidth(5); Tooltip exclaimTooltip = new Tooltip(TextFactory.getText(Labels.LabelKey.PROPERTY_MISSING_LABEL)); Tooltip.install(exclaimImage, exclaimTooltip); invalidItem.setGraphic(exclaimImage); } }
// wyœwietla wszystkie piosenki w postaci listy private void drawAllFiles() { ObservableList<Song> allSongs = FXCollections.observableArrayList(); for (File file : fileList) { allSongs.add(new Song(file.getAbsolutePath())); } // obrazek ImageView allFilesCover = new ImageView(new Image(new File("allfiles_cover.jpg").toURI().toString())); allFilesCover.setFitWidth(700); allFilesCover.setFitHeight(200); allFilesCover.setSmooth(true); flowPane.getChildren().add(allFilesCover); loadSongs(allSongs); }
public static void filtering(int[][] mask) { // blur int height = (int) image.getHeight(); int width = (int) image.getWidth(); initializeRGBMATRIX(height, width); setRGBMatrix(); imgR = countSum(mask, imgR); imgB = countSum(mask, imgB); imgG = countSum(mask, imgG); WritableImage wi = new WritableImage(width, height); PixelWriter pw = wi.getPixelWriter(); writePixels(pw, imgR, imgB, imgG, height, width); imageView.setRotate(angle); imageView.setImage(wi); imageView.setFitHeight(height); imageView.setFitWidth(width); }
@Override public boolean update() { int speed = 1; if (myImageView.getFitWidth() <= 300) { myImageView.setVisible(true); myImageView.setFitHeight(myImageView.getFitHeight() + speed); myImageView.relocate( myWidth / 2 - myImageView.getFitWidth() / 2, myHeight / 2 - myImageView.getFitHeight() / 2); myImageView.setFitWidth(myImageView.getFitWidth() + speed); myImageView.setRotate(myImageView.getRotate() + speed); } else if (myImageView.getRotate() <= 360) { myImageView.setRotate(myImageView.getRotate() + speed); } return (myImageView.getFitHeight() <= 300 || myImageView.getRotate() <= 300); }
public void refreshImageViewer(Resource resourceToUpdate) { List<Tab> tabs = tabPane.getTabs(); for (Tab tab : tabs) { Resource resource = (Resource) tab.getUserData(); if (resourceToUpdate.equals(resource)) { ImageResource imageResource = (ImageResource) resourceToUpdate; logger.info("refreshing image resource"); ImageViewerPane imageViewerPane = (ImageViewerPane) tab.getContent(); ImageView imageView = imageViewerPane.getImageView(); imageView.setImage(imageResource.asNativeFormat()); imageView.setFitHeight(-1); imageView.setFitWidth(-1); Label imagePropertiesLabel = imageViewerPane.getImagePropertiesLabel(); imagePropertiesLabel.setText(imageResource.getImageDescription()); } } }
private VBox createImageQuestion(QuestionSubmit submit) { imageQuestionText.setText(submit.getQuestion()); if (pictureForQuestion.containsKey(submit.getQuestionId())) { Image i = pictureForQuestion.get(submit.getQuestionId()).getImage(); imageQuestionView.setImage(i); imageQuestionView.setFitWidth(i.getWidth()); imageQuestionView.setFitHeight(i.getHeight()); } if (answerForQuestion.containsKey(submit)) { imageAnswer.setText(answerForQuestion.get(submit).getAnswer()); } else { imageAnswer.setText(""); } return imageQuestionVbox; }
/** * Instantiates the tileSet images using an image selected by the user. Given the number of rows * that the user input at the program startup, this automatically calculates the positions of the * individual tile images, and sets the tileSize for all tiles. * * <p>Note: tiles must be designed to be squares. * * @param file The image file containing what will be the map tiles */ public void openTileSet(File file) { try { origTileImage = ImageIO.read(file); tileSize = (int) origTileImage.getHeight() / numTileRows; // Minus 1 because tileSet matrix starts at index 0 numTileColumns = (int) origTileImage.getWidth() / tileSize; tileSet = new BufferedImage[numTileRows][numTileColumns]; for (int row = 0; row < numTileRows; row++) { for (int col = 0; col < numTileColumns; col++) { tileSet[row][col] = origTileImage.getSubimage(col * tileSize, row * tileSize, tileSize, tileSize); } } } catch (Exception ex) { ex.printStackTrace(); } // add tileSet to tileMap so that it is shown on screen for (int i = 0; i < numTileRows; i++) { for (int j = 0; j < numTileColumns; j++) { Image image = SwingFXUtils.toFXImage(tileSet[i][j], null); ImageView imageView = new ImageView(image); imageView.setX(j * tileSize); imageView.setY(i * tileSize); imageView.setFitWidth(tileSize); imageView.setFitHeight(tileSize); tileMap.getChildren().add(imageView); } } // Make the first tile selected currentTile = 0; double tx = ((ImageView) tileMap.getChildren().get(0)).getX(); double ty = ((ImageView) tileMap.getChildren().get(0)).getY(); double tw = ((ImageView) tileMap.getChildren().get(0)).getFitWidth(); double th = ((ImageView) tileMap.getChildren().get(0)).getFitHeight(); tileOutline = new Rectangle(tx, ty, tw, th); tileOutline.setStroke(Color.RED); tileOutline.setFill(null); tileMap.getChildren().add(tileOutline); }
/** * Loads a map from file: converts the values from the passed int matrix into images given by the * tileSet. The value in the map is the tile number. The matrix is passed to this method by {@code * loadMap()} in the KeyPressedListener class. * * @param oldMap int matrix holding tile numbers that correspond to a specific tile. */ public void loadOldMap(int[][] oldMap) { constructedMap.getChildren().clear(); mapX = tileSize; mapY = tileSize; mapW = oldMap[0].length; mapH = oldMap.length; mapOutline.setX(mapX); mapOutline.setY(mapY); mapOutline.setWidth(mapW * tileSize); mapOutline.setHeight(mapH * tileSize); map = new int[mapH][mapW]; for (int row = 0; row < mapH; row++) { for (int col = 0; col < mapW; col++) { currentTile = map[row][col] = oldMap[row][col]; // Get the right tile from tileSet int tileRow = (int) currentTile / numTileColumns; int tileCol = currentTile % numTileColumns; // Get the right image Image image = SwingFXUtils.toFXImage(tileSet[tileRow][tileCol], null); ImageView imageView = new ImageView(image); // Add the selected tile to the screen double imageX = mapOutline.getX() + col * tileSize; double imageY = mapOutline.getY() + row * tileSize; imageView.setX(imageX); imageView.setY(imageY); imageView.setFitWidth(tileSize); imageView.setFitHeight(tileSize); updateConstructedMap(imageView); } } currentTile = 0; updateCurrentTile(); }
/** Adds the icon and name of application to the grid. */ private void addPlugins() { if (isPlugins()) { loadPlugins(); // Going through the plugin 2d Arraylist for (int i = 0; i < plugins.size(); i++) { File files; ImageView view; files = icons.get(i).get(0); if (!files.exists()) { view = new ImageView(defaultimage); } else { File[] listFiles = files.listFiles(); File file = listFiles[0]; Image image; try { BufferedImage bufimage = ImageIO.read(file); image = SwingFXUtils.toFXImage(bufimage, null); } catch (IOException ioe) { image = defaultimage; } view = new ImageView(image); } // adds name of application for each plugin. if (!change) { labels.add(new Label(newAppData.get(i).get(0))); } else { labels.add(new Label(appData.get(i).get(0))); } gridPane.add(labels.get(i), 1, i); // adds icon of application for each plugin view.setFitHeight(100); view.setPreserveRatio(true); iconsView.add(view); gridPane.add(view, 0, i); } } }
public void setWidthAndHeight(double width, double height) { _box._setWidthAndHeight(width, height); _elementView.setFitWidth(width); _elementView.setFitHeight(height); }
@Override public void start(Stage stage) { sun.setFitHeight(100); sun.setFitWidth(100); sun.setX(200); sun.setY(200); quas.setFitHeight(50); quas.setFitWidth(50); wex.setFitHeight(50); wex.setFitWidth(50); exort.setFitHeight(50); exort.setFitWidth(50); Circle orbit1 = new Circle(); orbit1.setRotate(-90); orbit1.setRadius(100); orbit1.setCenterX(250); orbit1.setCenterY(250); PathTransition path1 = new PathTransition(); path1.setPath(orbit1); path1.setNode(quas); path1.setDuration(Duration.seconds(5)); path1.setCycleCount(Timeline.INDEFINITE); Circle orbit2 = new Circle(); orbit2.setRotate(30); orbit2.setRadius(100); orbit2.setCenterX(250); orbit2.setCenterY(250); PathTransition path2 = new PathTransition(); path2.setPath(orbit2); path2.setNode(wex); path2.setDuration(Duration.seconds(5)); path2.setCycleCount(Timeline.INDEFINITE); Circle orbit3 = new Circle(); orbit3.setRotate(150); orbit3.setRadius(100); orbit3.setCenterX(250); orbit3.setCenterY(250); PathTransition path3 = new PathTransition(); path3.setPath(orbit3); path3.setNode(exort); path3.setDuration(Duration.seconds(5)); path3.setCycleCount(Timeline.INDEFINITE); ComboBox<String> invoke = new ComboBox<String>(); invoke.setEditable(false); invoke .getItems() .addAll( "Cold Snap", "Ghost Walk", "Tornado", "EMP", "Alacrity", "Chaos Meteor", "Sun Strike", "Forge Spirit", "Ice Wall", "Deafening Blast"); invoke.setOnAction( e -> { switch (invoke.getValue()) { case "Cold Snap": path1.setNode(quas); path2.setNode(quas); path3.setNode(quas); break; case "Ghost Walk": path1.setNode(quas); path2.setNode(quas); path3.setNode(wex); break; case "Tornado": path1.setNode(wex); path2.setNode(wex); path3.setNode(quas); break; case "EMP": path1.setNode(wex); path2.setNode(wex); path3.setNode(wex); break; case "Alacrity": path1.setNode(wex); path2.setNode(wex); path3.setNode(exort); break; case "Chaos Meteor": path1.setNode(exort); path2.setNode(exort); path3.setNode(wex); break; case "Sun Strike": path1.setNode(exort); path2.setNode(exort); path3.setNode(exort); break; case "Forge Spirit": path1.setNode(exort); path2.setNode(exort); path3.setNode(quas); break; case "Ice Wall": path1.setNode(quas); path2.setNode(quas); path3.setNode(exort); break; case "Deafening Blast": path1.setNode(quas); path2.setNode(wex); path3.setNode(exort); break; default: path1.setNode(quas); path2.setNode(wex); path3.setNode(exort); break; } }); path1.play(); path2.play(); path3.play(); Pane pane = new Pane(); pane.getChildren().addAll(quas, wex, exort, sun, invoke); stage.setScene(new Scene(pane, 500, 500)); stage.setTitle("Spell Combinations"); stage.show(); }
public void zoomOut() { if (mImageView.getFitWidth() > 450 || mImageView.getFitHeight() > 600) { mImageView.setFitWidth(mImageView.getFitWidth() * .9); mImageView.setFitHeight(mImageView.getFitHeight() * .9); } }
public void zoomIn() { if (mImageView.getFitWidth() < 3000 || mImageView.getFitHeight() < 3000) { mImageView.setFitWidth(mImageView.getFitWidth() * 1.1); mImageView.setFitHeight(mImageView.getFitHeight() * 1.1); } }
private void configureWidthHeightForImageViews() { // Restaurant restaurantIMV.setFitWidth(51); restaurantIMV.setFitHeight(41); // reservations reservationsIMV.setFitWidth(63); reservationsIMV.setFitHeight(84); reservationsSelectedIMV.setFitWidth(63); reservationsSelectedIMV.setFitHeight(84); // customers customersIMV.setFitWidth(53); customersIMV.setFitHeight(65); customersSelectedIMV.setFitWidth(53); customersSelectedIMV.setFitHeight(65); // employees employeesIMV.setFitWidth(53); employeesIMV.setFitHeight(53); employeesSelectedIMV.setFitWidth(53); employeesSelectedIMV.setFitHeight(53); // rating ratingIMV.setFitWidth(32); ratingIMV.setFitHeight(69); ratingSelectedIMV.setFitWidth(32); ratingSelectedIMV.setFitHeight(69); // archive archiveIMV.setFitWidth(37); archiveIMV.setFitHeight(51); archiveSelectedIMV.setFitWidth(37); archiveSelectedIMV.setFitHeight(51); }
@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); } }
public static void launchForm() { loginForm.setTitle("Welcome to GEEK - Log in or Register"); loginForm.setResizable(false); loginForm .getIcons() .add(new Image(LoginForm.class.getResource("../style_elements/logo.png").toExternalForm())); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); ImageView logo = new ImageView((LoginForm.class.getResource("../style_elements/logo.png").toExternalForm())); logo.setFitHeight(100); logo.setFitWidth(100); grid.setMargin(logo, new Insets(0, 0, 0, 72)); grid.add(logo, 1, 1); username.setId("input_field"); username.setPromptText("Username"); username.setMinWidth(250); username.setFocusTraversable(false); grid.add(username, 1, 2); password.setId("input_field"); password.setPromptText("Password"); password.setMinWidth(250); password.setFocusTraversable(false); grid.add(password, 1, 3); sign_in_button.setId("sign_in_button"); sign_in_button.setPrefHeight(35); sign_in_button.setCursor(Cursor.HAND); register_button.setId("register_button"); register_button.setPrefHeight(35); register_button.setCursor(Cursor.HAND); HBox buttons = new HBox(10); buttons.setAlignment(Pos.CENTER); buttons.getChildren().addAll(sign_in_button, register_button); grid.add(buttons, 1, 4); HBox text = new HBox(3); text.setAlignment(Pos.CENTER); error_message_field.setFill(Color.WHITE); error_message_field.setId("error"); text.getChildren().add(error_message_field); grid.add(text, 1, 6); setButtonsActions(); Scene scene = new Scene(grid, 500, 500); scene .getStylesheets() .add(LoginForm.class.getResource("../style_elements/login_form.css").toExternalForm()); loginForm.setScene(scene); loginForm.show(); isOpen = true; }