private void listFilesForFolder(final File folder) { for (final File fileEntry : folder.listFiles()) { if (fileEntry.isDirectory()) { listFilesForFolder(fileEntry); } else { Image img = new Image(fileEntry.toURI().toString()); imgMan.images.add( new ImageInformation( img, fileEntry.toURI().toString(), new ImageInformation.Type[] { ImageInformation.Type.SAND, ImageInformation.Type.FISH, ImageInformation.Type.ALGA, ImageInformation.Type.CORAL, ImageInformation.Type.SAND }, new Point[] { new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.25)), new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.25)), new Point((int) (img.getWidth() * 0.5), (int) (img.getHeight() * 0.5)), new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.75)), new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.75)) }, new double[] {0.86, 0.76, 0.99, 0.65, 0.54})); } } }
@FXML private void handleImportItemAction(ActionEvent event) { File fileLocation = new FileChooser().showOpenDialog(Main.stage); try (BufferedReader br = new BufferedReader(new FileReader(fileLocation))) { String line; while ((line = br.readLine()) != null) { final File folder = new File(line); if (folder.isDirectory()) { listFilesForFolder(folder); } else { Image img = new Image(folder.toURI().toString()); imgMan.images.add( new ImageInformation( img, folder.toURI().toString(), new ImageInformation.Type[] { ImageInformation.Type.SAND, ImageInformation.Type.FISH, ImageInformation.Type.ALGA, ImageInformation.Type.CORAL, ImageInformation.Type.SAND }, new Point[] { new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.25)), new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.25)), new Point((int) (img.getWidth() * 0.5), (int) (img.getHeight() * 0.5)), new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.75)), new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.75)) }, new double[] {0.86, 0.76, 0.99, 0.65, 0.54})); } } } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } imgMan.NextImage(); }
/** * opens existing file * * @param a_file */ public GlyphFile(File a_file) { super(); m_fileName = a_file; URL url = null; try { url = a_file.toURI().toURL(); } catch (MalformedURLException e) { e.printStackTrace(); } init(url); }