You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0 KiB

2 years ago
  1. package playground;
  2. import java.awt.image.BufferedImage;
  3. import javax.imageio.ImageIO;
  4. import java.io.File;
  5. import java.io.*;
  6. import java.io.FileNotFoundException;
  7. import java.util.LinkedList;
  8. import java.util.Locale;
  9. import java.util.Scanner;
  10. import java.nio.file.Path;
  11. import java.nio.file.Paths;
  12. import org.apache.logging.log4j.Logger;
  13. import org.apache.logging.log4j.LogManager;
  14. public class Animation {
  15. public LinkedList<String> fileList = null;
  16. public LinkedList<Double> showtimeList = null;
  17. public LinkedList<BufferedImage> imageList = null;
  18. private static Logger logger = LogManager.getLogger(Animation.class);
  19. public Animation(String datName) {
  20. Scanner scanner;
  21. this.fileList = new LinkedList<String>();
  22. this.showtimeList = new LinkedList<Double>();
  23. this.imageList = new LinkedList<BufferedImage>();
  24. try {
  25. scanner = new Scanner(new File(datName), "UTF-8");
  26. scanner.useLocale(Locale.GERMANY);
  27. String zeile;
  28. double zeit;
  29. int it = 0;
  30. while (scanner.hasNext()) {
  31. if (scanner.hasNextDouble()) {
  32. zeit = scanner.nextDouble();
  33. showtimeList.add(zeit);
  34. } else {
  35. zeile = scanner.next();
  36. Path basePath = Paths.get(datName);
  37. String file = basePath.getParent().toString() + "/" + zeile;
  38. fileList.add(file);
  39. try {
  40. this.imageList.add(ImageIO.read(new File(file)));
  41. logger.info("img added " + file);
  42. } catch (IOException e) {
  43. logger.warn(file + " not found!!");
  44. }
  45. it++;
  46. logger.trace(basePath.getParent().toString() + "/" + zeile);
  47. }
  48. }
  49. scanner.close();
  50. } catch (FileNotFoundException e) {
  51. e.printStackTrace();
  52. }
  53. }
  54. public LinkedList<String> getFileList() {
  55. return this.fileList;
  56. }
  57. public LinkedList<Double> getShowtimeList() {
  58. return this.showtimeList;
  59. }
  60. public LinkedList<BufferedImage> getImageList() {
  61. return this.imageList;
  62. }
  63. }