コード例 #1
0
ファイル: TMDBScheda.java プロジェクト: Daxel90/GiaraFilms
  public BufferedImage initBack_w1920(final JLabel label) {
    final String link = "http://image.tmdb.org/t/p/w1920";
    if (back_w1920 == null) {
      final File f =
          new File(
              DirUtils.getCacheDir() + File.separator + "image",
              MD5.generatemd5(link + back) + ".jpg");

      if (f.exists()) {
        back_w1920 = ImageUtils.getImage(f);
        back_w1920 = ImageUtils.FilterRescaleOp(back_w1920, 0.4f);
      } else {
        Runnable task =
            new Runnable() {
              @Override
              public void run() {
                try {
                  back_w1920 = ImageUtils.getHttpBufferedImage(link + back);
                  if (back_w1920 != null) {
                    try {
                      if (!f.getParentFile().exists()) f.getParentFile().mkdirs();

                      ImageIO.write(back_w1920, "JPG", f);
                      back_w1920 = ImageUtils.FilterRescaleOp(back_w1920, 0.4f);
                    } catch (Exception e) {
                      Log.stack(Log.IMAGE, e);
                    }
                  } else {
                    back_w1920 = null;
                  }
                } finally {
                  if (label.getWidth() > label.getHeight()) {
                    BufferedImage img =
                        ImageUtils.scaleWithAspectHeight(back_w1920, label.getHeight());
                    if (img.getWidth() < label.getWidth())
                      img = ImageUtils.scaleWithAspectWidth(back_w1920, label.getWidth());
                    label.setIcon(ImageUtils.getIcon(img));
                  } else {
                    BufferedImage img =
                        ImageUtils.scaleWithAspectWidth(back_w1920, label.getWidth());
                    if (img.getHeight() < label.getHeight())
                      img = ImageUtils.scaleWithAspectHeight(back_w1920, label.getHeight());
                    label.setIcon(ImageUtils.getIcon(img));
                  }
                }
              }
            };

        ThreadManager.submitSystemTask(task);
        back_w1920 = null;
      }
    }
    return back_w1920;
  }
コード例 #2
0
ファイル: TMDBScheda.java プロジェクト: Daxel90/GiaraFilms
  public BufferedImage initPoster_w140(final JPanel filmListPanel) {
    final String link = "http://image.tmdb.org/t/p/w148";
    if (poster_w140 == null) {
      final File f =
          new File(
              DirUtils.getCacheDir() + File.separator + "image",
              MD5.generatemd5(link + poster) + ".jpg");

      if (f.exists()) {
        poster_w140 = ImageUtils.getImage(f);
      } else {
        Runnable task =
            new Runnable() {
              @Override
              public void run() {
                try {
                  poster_w140 = ImageUtils.getHttpBufferedImage(link + poster);

                  if (poster_w140 != null) {
                    poster_w140 = ImageUtils.scaleImage(poster_w140, 140, 200);
                    try {
                      if (!f.getParentFile().exists()) f.getParentFile().mkdirs();

                      ImageIO.write(poster_w140, "JPG", f);
                    } catch (Exception e) {
                      Log.stack(Log.IMAGE, e);
                    }
                  } else {
                    poster_w140 = ImageUtils.getImage("notFound.png");
                  }
                } finally {
                  if (filmListPanel instanceof FilmListPanel) {
                    ((FilmListPanel) filmListPanel).init();
                  } else if (filmListPanel instanceof HomeListPanel) {
                    ((HomeListPanel) filmListPanel).init();
                  }
                  filmListPanel.repaint();
                }
              }
            };

        ThreadManager.submitSystemTask(task);
        poster_w140 = ImageUtils.getImage("loading.png");
      }
    }
    return poster_w140;
  }
コード例 #3
0
ファイル: TMDBScheda.java プロジェクト: Daxel90/GiaraFilms
  public BufferedImage initPoster_w500(final JLabel label) {
    final String link = "http://image.tmdb.org/t/p/w500";
    if (poster_original == null) {
      final File f =
          new File(
              DirUtils.getCacheDir() + File.separator + "image",
              MD5.generatemd5(link + poster) + ".jpg");

      if (f.exists()) {
        poster_original = ImageUtils.getImage(f);
      } else {
        Runnable task =
            new Runnable() {
              @Override
              public void run() {
                try {
                  poster_original = ImageUtils.getHttpBufferedImage(link + poster);

                  if (poster_original != null) {
                    try {
                      if (!f.getParentFile().exists()) f.getParentFile().mkdirs();

                      ImageIO.write(poster_original, "JPG", f);
                    } catch (Exception e) {
                      Log.stack(Log.IMAGE, e);
                    }
                  } else {
                    poster_original = ImageUtils.getImage("notFound.png");
                  }
                } finally {
                  label.setIcon(
                      ImageUtils.getIcon(
                          ImageUtils.scaleImage(
                              poster_original, label.getWidth(), label.getHeight())));
                }
              }
            };

        ThreadManager.submitSystemTask(task);
        poster_original = ImageUtils.getImage("loading.png");
      }
    }
    return poster_original;
  }
コード例 #4
0
ファイル: TMDBScheda.java プロジェクト: Daxel90/GiaraFilms
  public BufferedImage initHome_w500(final NewsButton news) {
    final String link = "http://image.tmdb.org/t/p/w500";
    if (home_w500 == null) {
      final File f =
          new File(
              DirUtils.getCacheDir() + File.separator + "image",
              MD5.generatemd5(link + back) + ".jpg");

      if (f.exists()) {
        home_w500 = ImageUtils.getImage(f);
      } else {
        Runnable task =
            new Runnable() {
              @Override
              public void run() {
                try {
                  home_w500 = ImageUtils.getHttpBufferedImage(link + back);

                  if (home_w500 != null) {
                    home_w500 = ImageUtils.scaleImage(home_w500, 500, 280);
                    try {
                      if (!f.getParentFile().exists()) f.getParentFile().mkdirs();

                      ImageIO.write(home_w500, "JPG", f);
                    } catch (Exception e) {
                      Log.stack(Log.IMAGE, e);
                    }
                  } else {
                    home_w500 = ImageUtils.getImage("notFound.png");
                  }
                } finally {
                  news.updateImage(home_w500);
                }
              }
            };

        ThreadManager.submitSystemTask(task);
        home_w500 = ImageUtils.getImage("loading.png");
      }
    }
    return home_w500;
  }