List of usage examples for org.apache.commons.imaging Imaging getBufferedImage
public static BufferedImage getBufferedImage(final File file) throws ImageReadException, IOException
From source file:com.github.pitzcarraldo.dissimilar.Dissimilar.java
/** * Calculate the SSIM between two files// ww w. j a va 2 s .com * @param pOne first image to compare * @param pTwo second image to compare * @param pHeatMapFilename ssim heat map image filename (can be null) * @param pMin list for return value - ssim minimum (can be null) * @param pVariance list for return value - ssim variance (can be null) * @return calculated ssim */ public static double calcSSIM(final File pOne, final File pTwo, final String pHeatMapFilename, List<Double> pMin, List<Double> pVariance) { BufferedImage imageOne = null; try { imageOne = Imaging.getBufferedImage(pOne); } catch (IOException e) { printError(pOne, false, false, pTwo, false); return -1; } catch (NullPointerException e) { printError(pOne, false, false, pTwo, false); return -1; } catch (ImageReadException e) { printError(pOne, false, false, pTwo, false); return -1; } //getRGB only returns 8 bits per component, so what about 16-bit images? final int[] oneA = imageOne.getRGB(0, 0, imageOne.getWidth(), imageOne.getHeight(), null, 0, imageOne.getWidth()); final int width = imageOne.getWidth(); final int height = imageOne.getHeight(); final boolean greyscale = (imageOne.getType() == BufferedImage.TYPE_BYTE_GRAY || imageOne.getType() == BufferedImage.TYPE_USHORT_GRAY); imageOne = null; BufferedImage imageTwo = null; try { imageTwo = Imaging.getBufferedImage(pTwo); } catch (IOException e) { printError(pOne, true, true, pTwo, false); return -1; } catch (NullPointerException e) { printError(pOne, true, true, pTwo, false); return -1; } catch (ImageReadException e) { printError(pOne, true, true, pTwo, false); return -1; } //getRGB only returns 8 bits per component, so what about 16-bit images? final int[] twoA = imageTwo.getRGB(0, 0, imageTwo.getWidth(), imageTwo.getHeight(), null, 0, imageTwo.getWidth()); imageTwo = null; final double ssim = calcSSIM(oneA, twoA, width, height, greyscale, pHeatMapFilename, pMin, pVariance); return ssim; }
From source file:com.pronoiahealth.olhie.server.services.BookCoverImageService.java
/** * Create a back cover// w ww .ja v a2s .c o m * * @param coverId * @param titleStr * @param textColor * @param width * @param height * @param type * @param imgFormat * @param macColors * - for PNG images reduce the color palette (must be greater * than 2) * @return * @throws Exception */ public byte[] createBackCover(String coverId, String titleStr, String spineColor, String textColor, int width, int height, int type, ImageFormat imgFormat, int maxColors) throws Exception { Graphics2D g2D = null; try { // Front cover first // Read in base cover image BufferedImage coverImg = Imaging.getBufferedImage(coverMap.get(coverId)); // Resize cover image to the basic 300 X 400 for front cover BufferedImage backCoverImg = resize(coverImg, 300, 400, type); g2D = (Graphics2D) backCoverImg.getGraphics(); // Add title if present if (titleStr != null && titleStr.length() > 0) { BufferedImage titleTextImg = createText(82, 220, titleStr, textColor, true, backTitleFontMap, type); g2D.drawImage(titleTextImg, 40, 35, null); } // Add spine if present if (spineColor != null && spineColor.length() > 0) { g2D.setColor(Color.decode(spineColor)); g2D.fillRect(backCoverImg.getWidth() - 2, 0, 2, backCoverImg.getHeight()); } // If the requested size is not 300X400 convert the image BufferedImage outImg = null; if (width != 300 || height != 400) { outImg = resize(backCoverImg, width, height, type); } else { outImg = backCoverImg; } // Do we want a PNG with a fixed number of colors if (maxColors >= 2 && imgFormat == ImageFormat.IMAGE_FORMAT_PNG) { outImg = ImageUtils.reduce32(outImg, maxColors); } // Return bytes Map<String, Object> params = new HashMap<String, Object>(); byte[] outBytes = Imaging.writeImageToBytes(outImg, imgFormat, params); return outBytes; } finally { if (g2D != null) { g2D.dispose(); } } }
From source file:com.github.pitzcarraldo.dissimilar.Dissimilar.java
/** * Compare two files, according to parameters passed via command line * @param pOne first file to compare/* w w w . ja v a 2 s .c om*/ * @param pTwo second file to compare * @param pHeatMapImage file to save ssim heat map image to * @param pCalcSSIM whether or not to calculate ssim * @param pCalcPSNR whether or not to calculate psnr */ private static void compare(final File pOne, final File pTwo, final String pHeatMapImage, final boolean pCalcSSIM, final boolean pCalcPSNR) { //just load the images once and use the internal methods for calculating ssim/psnr long time = System.currentTimeMillis(); BufferedImage imageOne = null; try { imageOne = Imaging.getBufferedImage(pOne); } catch (IOException e) { printError(pOne, false, false, pTwo, false); return; } catch (NullPointerException e) { printError(pOne, false, false, pTwo, false); return; } catch (ImageReadException e) { printError(pOne, false, false, pTwo, false); return; } final long oneLoadTime = System.currentTimeMillis() - time; //getRGB only returns 8 bits per component, so what about 16-bit images? final int[] oneA = imageOne.getRGB(0, 0, imageOne.getWidth(), imageOne.getHeight(), null, 0, imageOne.getWidth()); final int width = imageOne.getWidth(); final int height = imageOne.getHeight(); final boolean greyscale = (imageOne.getType() == BufferedImage.TYPE_BYTE_GRAY || imageOne.getType() == BufferedImage.TYPE_USHORT_GRAY); imageOne = null; time = System.currentTimeMillis(); BufferedImage imageTwo = null; try { imageTwo = Imaging.getBufferedImage(pTwo); } catch (IOException e) { printError(pOne, true, true, pTwo, false); return; } catch (NullPointerException e) { printError(pOne, true, true, pTwo, false); return; } catch (ImageReadException e) { printError(pOne, true, true, pTwo, false); return; } final long twoLoadTime = System.currentTimeMillis() - time; //getRGB only returns 8 bits per component, so what about 16-bit images? final int[] twoA = imageTwo.getRGB(0, 0, imageTwo.getWidth(), imageTwo.getHeight(), null, 0, imageTwo.getWidth()); imageTwo = null; //calculate psnr if wanted time = System.currentTimeMillis(); double psnr = 0; long psnrCalc = 0; if (pCalcPSNR) { psnr = calcPSNR(oneA, twoA, greyscale); psnrCalc = System.currentTimeMillis() - time; } //calculate ssim if wanted time = System.currentTimeMillis(); List<Double> ssimMin = new LinkedList<Double>(); List<Double> ssimVariance = new LinkedList<Double>(); double ssim = 0; long ssimCalc = 0; if (pCalcSSIM) { ssim = calcSSIM(oneA, twoA, width, height, greyscale, pHeatMapImage, ssimMin, ssimVariance); ssimCalc = System.currentTimeMillis() - time; } System.out.println("<dissimilar version=\"" + version + "\">"); System.out.println(" <file loadTimeMS=\"" + oneLoadTime + "\">" + pOne + "</file>"); System.out.println(" <file loadTimeMS=\"" + twoLoadTime + "\">" + pTwo + "</file>"); if (pCalcSSIM) { System.out.println(" <ssim calcTimeMS=\"" + ssimCalc + "\">"); if (ssim > 0) { System.out.println(" <mean>" + new DecimalFormat("0.0000000").format(ssim) + "</mean>"); System.out.println( " <min>" + new DecimalFormat("0.0000000").format(ssimMin.get(0)) + "</min>"); System.out.println(" <variance>" + new DecimalFormat("0.0000000").format(ssimVariance.get(0)) + "</variance>"); } else { System.out.println("failed"); } System.out.println(" </ssim>"); } if (pCalcPSNR) { System.out.println(" <psnr calcTimeMS=\"" + psnrCalc + "\">" + new DecimalFormat("0.0000").format(psnr) + "</psnr>"); } System.out.println("</dissimilar>"); }
From source file:net.windward.android.imageio.ImageIO.java
public static BufferedImage read(File input) throws IOException { if (input == null) { throw new IllegalArgumentException(Messages.getString("imageio.52")); }//from w ww .j a v a 2 s.c o m /* String name=input.getName().toLowerCase(); if(name.endsWith(".png")) { PngImageParser parser = new PngImageParser(); try { return parser.getBufferedImage(input, new HashMap()); } catch (ImageReadException e) { throw new IOException(e); } } else if(name.endsWith(".gif")) { GifImageParser parser = new GifImageParser(); try { return parser.getBufferedImage(input, new HashMap()); } catch (ImageReadException e) { throw new IOException(e); } }*/ try { return Imaging.getBufferedImage(input); } catch (ImageReadException e) { // TODO Auto-generated catch block throw new IOException(e); } /* ImageInputStream stream = createImageInputStream(input); return read(stream);*/ }
From source file:net.windward.android.imageio.ImageIO.java
public static BufferedImage read(InputStream input) throws IOException { if (input == null) { throw new IllegalArgumentException(Messages.getString("imageio.52")); }//from w w w. jav a 2 s. c o m try { return Imaging.getBufferedImage(input); } catch (ImageReadException e) { // TODO Auto-generated catch block throw new IOException(e); } //ImageParser parser=new getBufferedImage /* PngImageParser parser = new PngImageParser(); try { return parser.getBufferedImage(new ByteSourceInputStream(input, "file.png"), Collections.emptyMap()); } catch (ImageReadException e) { throw new IOException(e); }*/ }
From source file:org.apache.commons.imaging.examples.ImageWriteExample.java
public static byte[] imageWriteExample(final File file) throws ImageReadException, ImageWriteException, IOException { // read image final BufferedImage image = Imaging.getBufferedImage(file); final ImageFormat format = ImageFormats.TIFF; final Map<String, Object> params = new HashMap<>(); // set optional parameters if you like params.put(ImagingConstants.PARAM_KEY_COMPRESSION, Integer.valueOf(TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED)); final byte[] bytes = Imaging.writeImageToBytes(image, format, params); return bytes; }
From source file:org.apache.commons.imaging.examples.SampleUsage.java
@SuppressWarnings("unused") public SampleUsage() { try {//from w w w . ja va 2 s .c o m // <b>Code won't work unless these variables are properly // initialized. // Imaging works equally well with File, byte array or InputStream // inputs.</b> final BufferedImage someImage = null; final byte someBytes[] = null; final File someFile = null; final InputStream someInputStream = null; final OutputStream someOutputStream = null; // <b>The Imaging class provides a simple interface to the library. // </b> // <b>how to read an image: </b> final byte imageBytes[] = someBytes; final BufferedImage image_1 = Imaging.getBufferedImage(imageBytes); // <b>methods of Imaging usually accept files, byte arrays, or // inputstreams as arguments. </b> final BufferedImage image_2 = Imaging.getBufferedImage(imageBytes); final File file = someFile; final BufferedImage image_3 = Imaging.getBufferedImage(file); final InputStream is = someInputStream; final BufferedImage image_4 = Imaging.getBufferedImage(is); // <b>Write an image. </b> final BufferedImage image = someImage; final File dst = someFile; final ImageFormat format = ImageFormats.PNG; final Map<String, Object> optionalParams = new HashMap<>(); Imaging.writeImage(image, dst, format, optionalParams); final OutputStream os = someOutputStream; Imaging.writeImage(image, os, format, optionalParams); // <b>get the image's embedded ICC Profile, if it has one. </b> final byte iccProfileBytes[] = Imaging.getICCProfileBytes(imageBytes); final ICC_Profile iccProfile = Imaging.getICCProfile(imageBytes); // <b>get the image's width and height. </b> final Dimension d = Imaging.getImageSize(imageBytes); // <b>get all of the image's info (ie. bits per pixel, size, // transparency, etc.) </b> final ImageInfo imageInfo = Imaging.getImageInfo(imageBytes); if (imageInfo.getColorType() == ImageInfo.ColorType.GRAYSCALE) { System.out.println("Grayscale image."); } if (imageInfo.getHeight() > 1000) { System.out.println("Large image."); } // <b>try to guess the image's format. </b> final ImageFormat imageFormat = Imaging.guessFormat(imageBytes); imageFormat.equals(ImageFormats.PNG); // <b>get all metadata stored in EXIF format (ie. from JPEG or // TIFF). </b> final ImageMetadata metadata = Imaging.getMetadata(imageBytes); // <b>print a dump of information about an image to stdout. </b> Imaging.dumpImageFile(imageBytes); // <b>get a summary of format errors. </b> final FormatCompliance formatCompliance = Imaging.getFormatCompliance(imageBytes); } catch (final Exception e) { } }
From source file:org.imaging.CommonsImagingVariousExamples.java
public CommonsImagingVariousExamples() { try {/*from ww w .j a v a2s .co m*/ // <b>Code won't work unless these variables are properly // initialized. // Imaging works equally well with File, byte array or InputStream // inputs.</b> final BufferedImage someImage = null; final byte someBytes[] = null; final File someFile = null; final InputStream someInputStream = null; final OutputStream someOutputStream = null; // <b>The Imaging class provides a simple interface to the library. // </b> // <b>how to read an image: </b> final byte imageBytes[] = someBytes; final BufferedImage image_1 = Imaging.getBufferedImage(imageBytes); // <b>methods of Imaging usually accept files, byte arrays, or // inputstreams as arguments. </b> final BufferedImage image_2 = Imaging.getBufferedImage(imageBytes); final File file = someFile; final BufferedImage image_3 = Imaging.getBufferedImage(file); final InputStream is = someInputStream; final BufferedImage image_4 = Imaging.getBufferedImage(is); // <b>Write an image. </b> final BufferedImage image = someImage; final File dst = someFile; final ImageFormat format = ImageFormats.PNG; final Map<String, Object> optionalParams = new HashMap<String, Object>(); Imaging.writeImage(image, dst, format, optionalParams); final OutputStream os = someOutputStream; Imaging.writeImage(image, os, format, optionalParams); // <b>get the image's embedded ICC Profile, if it has one. </b> final byte iccProfileBytes[] = Imaging.getICCProfileBytes(imageBytes); final ICC_Profile iccProfile = Imaging.getICCProfile(imageBytes); // <b>get the image's width and height. </b> final Dimension d = Imaging.getImageSize(imageBytes); // <b>get all of the image's info (ie. bits per pixel, size, // transparency, etc.) </b> final ImageInfo imageInfo = Imaging.getImageInfo(imageBytes); if (imageInfo.getColorType() == ImageInfo.ColorType.GRAYSCALE) { System.out.println("Grayscale image."); } if (imageInfo.getHeight() > 1000) { System.out.println("Large image."); } // <b>try to guess the image's format. </b> final ImageFormat imageFormat = Imaging.guessFormat(imageBytes); imageFormat.equals(ImageFormats.PNG); // <b>get all metadata stored in EXIF format (ie. from JPEG or // TIFF). </b> final ImageMetadata metadata = Imaging.getMetadata(imageBytes); // <b>print a dump of information about an image to stdout. </b> Imaging.dumpImageFile(imageBytes); // <b>get a summary of format errors. </b> final FormatCompliance formatCompliance = Imaging.getFormatCompliance(imageBytes); } catch (final Exception e) { e.printStackTrace(); } }
From source file:org.xlrnet.tibaija.tools.fontgen.FontgenApplication.java
private Symbol importFile(Path path, Font font, String fontIdentifier) throws IOException, ImageReadException { LOGGER.info("Importing file {} ...", path.toAbsolutePath()); BufferedImage image = Imaging.getBufferedImage(Files.newInputStream(path)); int width = image.getWidth(); int height = image.getHeight(); int finalWidth = width / 2; int finalHeight = height / 2; if (width % 2 != 0 || height % 2 != 0) { LOGGER.warn("Width and height must be multiple of 2"); return null; }//from w w w . j a v a2 s.com Symbol symbol = new Symbol(); PixelState[][] pixelStates = new PixelState[finalHeight][finalWidth]; Raster imageData = image.getData(); for (int y = 0; y < finalHeight; y++) { for (int x = 0; x < finalWidth; x++) { int sample = imageData.getSample(x * 2, y * 2, 0); PixelState pixelState = sample == 0 ? PixelState.ON : PixelState.OFF; pixelStates[y][x] = pixelState; } } symbol.setData(pixelStates); return symbol; }
From source file:tachyon.view.ProjectProperties.java
public ProjectProperties(JavaProject project, Window w) { this.project = project; stage = new Stage(); stage.initOwner(w);//from w ww.j av a 2s . c o m stage.initModality(Modality.APPLICATION_MODAL); stage.setWidth(600); stage.setTitle("Project Properties - " + project.getProjectName()); stage.getIcons().add(tachyon.Tachyon.icon); stage.setResizable(false); HBox mai, libs, one, two, thr, fou; ListView<String> compileList, runtimeList; Button compileAdd, compileRemove, preview, selectIm, runtimeAdd, runtimeRemove; TextField iconField; stage.setScene(new Scene(new VBox(5, pane = new TabPane( new Tab("Library Settings", box1 = new VBox(15, libs = new HBox(10, new Label("External Libraries"), libsView = new ListView<>(), new VBox(5, addJar = new Button("Add Jar"), removeJar = new Button("Remove Jar"))))), new Tab("Program Settings", new ScrollPane(box2 = new VBox(15, one = new HBox(10, new Label("Main-Class"), mainClass = new TextField(project.getMainClassName()), select = new Button("Select")), two = new HBox(10, new Label("Compile-Time Arguments"), compileList = new ListView<>(), new VBox(5, compileAdd = new Button("Add Argument"), compileRemove = new Button("Remove Argument")))))), new Tab("Deployment Settings", box3 = new VBox(15, thr = new HBox(10, new Label("Icon File"), iconField = new TextField(project.getFileIconPath()), preview = new Button("Preview Image"), selectIm = new Button("Select Icon")), fou = new HBox(10, new Label("Runtime Arguments"), runtimeList = new ListView<>(), new VBox(5, runtimeAdd = new Button("Add Argument"), runtimeRemove = new Button("Remove Argument")))))), new VBox(15, mai = new HBox(10, cancel = new Button("Cancel"), confirm = new Button("Confirm")))))); if (applyCss.get()) { stage.getScene().getStylesheets().add(css); } for (Tab b : pane.getTabs()) { b.setClosable(false); } mainClass.setPromptText("Main-Class"); box1.setPadding(new Insets(5, 10, 5, 10)); mai.setAlignment(Pos.CENTER_RIGHT); mai.setPadding(box1.getPadding()); libs.setAlignment(Pos.CENTER); one.setAlignment(Pos.CENTER); two.setAlignment(Pos.CENTER); thr.setAlignment(Pos.CENTER); fou.setAlignment(Pos.CENTER); box1.setAlignment(Pos.CENTER); box2.setPadding(box1.getPadding()); box2.setAlignment(Pos.CENTER); box3.setPadding(box1.getPadding()); box3.setAlignment(Pos.CENTER); mainClass.setEditable(false); mainClass.setPrefWidth(200); for (JavaLibrary lib : project.getAllLibs()) { libsView.getItems().add(lib.getBinaryAbsolutePath()); } for (String sa : project.getCompileTimeArguments().keySet()) { compileList.getItems().add(sa + ":" + project.getCompileTimeArguments().get(sa)); } for (String sa : project.getRuntimeArguments()) { runtimeList.getItems().add(sa); } compileAdd.setOnAction((e) -> { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Compiler Argument"); dialog.initOwner(stage); dialog.setHeaderText("Entry the argument"); ButtonType loginButtonType = new ButtonType("Done", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField username = new TextField(); username.setPromptText("Key"); TextField password = new TextField(); password.setPromptText("Value"); grid.add(new Label("Key:"), 0, 0); grid.add(username, 1, 0); grid.add(new Label("Value:"), 0, 1); grid.add(password, 1, 1); Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); username.textProperty().addListener((observable, oldValue, newValue) -> { loginButton.setDisable(newValue.trim().isEmpty()); }); dialog.getDialogPane().setContent(grid); Platform.runLater(() -> username.requestFocus()); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { return new Pair<>(username.getText(), password.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); if (result.isPresent()) { compileList.getItems().add(result.get().getKey() + ":" + result.get().getValue()); } }); compileRemove.setOnAction((e) -> { if (compileList.getSelectionModel().getSelectedItem() != null) { compileList.getItems().remove(compileList.getSelectionModel().getSelectedItem()); } }); runtimeAdd.setOnAction((e) -> { TextInputDialog dia = new TextInputDialog(); dia.setTitle("Add Runtime Argument"); dia.setHeaderText("Enter an argument"); dia.initOwner(stage); Optional<String> res = dia.showAndWait(); if (res.isPresent()) { runtimeList.getItems().add(res.get()); } }); runtimeRemove.setOnAction((e) -> { if (runtimeList.getSelectionModel().getSelectedItem() != null) { runtimeList.getItems().remove(runtimeList.getSelectionModel().getSelectedItem()); } }); preview.setOnAction((e) -> { if (!iconField.getText().isEmpty()) { if (iconField.getText().endsWith(".ico")) { List<BufferedImage> read = new ArrayList<>(); try { read.addAll(ICODecoder.read(new File(iconField.getText()))); } catch (IOException ex) { } if (read.size() >= 1) { Image im = SwingFXUtils.toFXImage(read.get(0), null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } else if (iconField.getText().endsWith(".icns")) { try { BufferedImage ima = Imaging.getBufferedImage(new File(iconField.getText())); if (ima != null) { Image im = SwingFXUtils.toFXImage(ima, null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } catch (ImageReadException | IOException ex) { } } else { Image im = new Image(new File(iconField.getText()).toURI().toString()); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } }); selectIm.setOnAction((e) -> { FileChooser fc = new FileChooser(); fc.setTitle("Icon File"); String OS = System.getProperty("os.name").toLowerCase(); fc.getExtensionFilters().add(new ExtensionFilter("Icon File", OS.contains("win") ? getWindowsImageExtensions() : getMacImageExtensions())); fc.setSelectedExtensionFilter(fc.getExtensionFilters().get(0)); File lf = fc.showOpenDialog(stage); if (lf != null) { iconField.setText(lf.getAbsolutePath()); } }); addJar.setOnAction((e) -> { FileChooser f = new FileChooser(); f.setTitle("External Libraries"); f.setSelectedExtensionFilter(new ExtensionFilter("Jar Files", "*.jar")); List<File> showOpenMultipleDialog = f.showOpenMultipleDialog(stage); if (showOpenMultipleDialog != null) { for (File fi : showOpenMultipleDialog) { if (!libsView.getItems().contains(fi.getAbsolutePath())) { libsView.getItems().add(fi.getAbsolutePath()); } } } }); removeJar.setOnAction((e) -> { String selected = libsView.getSelectionModel().getSelectedItem(); if (selected != null) { libsView.getItems().remove(selected); } }); select.setOnAction((e) -> { List<String> all = getAll(); ChoiceDialog<String> di = new ChoiceDialog<>(project.getMainClassName(), all); di.setTitle("Select Main Class"); di.initOwner(stage); di.setHeaderText("Select A Main Class"); Optional<String> show = di.showAndWait(); if (show.isPresent()) { mainClass.setText(show.get()); } }); cancel.setOnAction((e) -> { stage.close(); }); confirm.setOnAction((e) -> { project.setMainClassName(mainClass.getText()); project.setFileIconPath(iconField.getText()); project.setRuntimeArguments(runtimeList.getItems()); HashMap<String, String> al = new HashMap<>(); for (String s : compileList.getItems()) { String[] spl = s.split(":"); al.put(spl[0], spl[1]); } project.setCompileTimeArguments(al); project.setAllLibs(libsView.getItems()); stage.close(); }); }