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.

82 lines
2.0 KiB

  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. while (scanner.hasNext()) {
  30. if (scanner.hasNextDouble()) {
  31. zeit = scanner.nextDouble();
  32. showtimeList.add(zeit);
  33. } else {
  34. zeile = scanner.next();
  35. Path basePath = Paths.get(datName);
  36. String file = basePath.getParent().toString() + "/" + zeile;
  37. fileList.add(file);
  38. try {
  39. this.imageList.add(ImageIO.read(new File(file)));
  40. logger.info("img added " + file);
  41. } catch (IOException e) {
  42. logger.warn(file + " not found!!");
  43. }
  44. logger.trace(basePath.getParent().toString() + "/" + zeile);
  45. }
  46. }
  47. scanner.close();
  48. } catch (FileNotFoundException e) {
  49. e.printStackTrace();
  50. }
  51. }
  52. public LinkedList<String> getFileList() {
  53. return this.fileList;
  54. }
  55. public LinkedList<Double> getShowtimeList() {
  56. return this.showtimeList;
  57. }
  58. public LinkedList<BufferedImage> getImageList() {
  59. return this.imageList;
  60. }
  61. }