Exemple #1
0
  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;
  }
Exemple #2
0
  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;
  }
Exemple #3
0
  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;
  }
Exemple #4
0
  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;
  }
  public void loadComponent() {
    this.removeAll();
    JLabel sep2 = new JLabel();
    sep2.setBounds(0, 40, FRAME_WIDTH, 1);
    sep2.setBorder(BorderFactory.createLineBorder(ColorUtils.Separator));
    this.add(sep2);

    JLabel title = new JLabel();
    title.setBounds(FRAME_WIDTH / 8, 0, FRAME_WIDTH * 3 / 4, 40);
    title.setText("<html><h1>" + scheda.title + "</html>");
    title.setHorizontalAlignment(JLabel.CENTER);
    this.add(title);

    ImageButton backbt =
        new ImageButton(
            ImageUtils.getImage("gui/icon32px/arrow_left.png"),
            ImageUtils.getImage("gui/icon32px/arrow_left_over.png"),
            ImageUtils.getImage("gui/icon32px/arrow_left_over.png"),
            BackGui);
    backbt.setBounds(5, 5, 32, 32);
    backbt.setToolTipText("Indietro");
    this.add(backbt);

    ImageButton homePage =
        new ImageButton(
            ImageUtils.getImage("gui/icon32px/home.png"),
            ImageUtils.getImage("gui/icon32px/home_over.png"),
            ImageUtils.getImage("gui/icon32px/home_over.png"),
            OpenHomePage);
    homePage.setBounds(40, 5, 32, 32);
    homePage.setToolTipText("Home");
    this.add(homePage);

    if (cover == null) cover = new JLabel();

    if ((int) ((FRAME_WIDTH / 4) * 1.49) < FRAME_HEIGHT / 2)
      cover.setBounds(20, 80, FRAME_WIDTH / 4, (int) ((FRAME_WIDTH / 4) * 1.5));
    else cover.setBounds(20, 80, (int) ((FRAME_HEIGHT / 2) * 0.67), FRAME_HEIGHT / 2);

    cover.setBorder(BorderFactory.createEtchedBorder());
    cover.setIcon(
        ImageUtils.getIcon(
            ImageUtils.scaleImage(
                scheda.initPoster_w500(cover), cover.getWidth(), cover.getHeight())));

    add(cover);

    text = new JEditorPane();
    text.setEditable(false);
    text.setHighlighter(null);
    text.setOpaque(false);
    text.setContentType("text/html");
    text.setText("<html><h2>" + scheda.desc + "</html>");
    text.setBorder(BorderFactory.createEmptyBorder());
    text.setBackground(ColorUtils.Trasparent);

    scroll = new JScrollPane(text);
    scroll.setFocusable(true);
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setBackground(ColorUtils.Trasparent);

    if ((int) ((FRAME_WIDTH / 4) * 1.49) < FRAME_HEIGHT / 2)
      scroll.setBounds(
          FRAME_WIDTH / 4 + 60,
          80,
          FRAME_WIDTH - (FRAME_WIDTH / 4 + 80),
          (int) ((FRAME_WIDTH / 4) * 1.49) - 35);
    else
      scroll.setBounds(
          (int) ((FRAME_HEIGHT / 2) * 0.67) + 60,
          80,
          FRAME_WIDTH - ((int) ((FRAME_HEIGHT / 2) * 0.67) + 80),
          FRAME_HEIGHT / 2 - 35);

    scroll.setOpaque(false);
    scroll.setVisible(false);
    this.add(scroll);
    ThreadManager.submitCacheTask(UpdateText);

    info = new JLabel();
    if ((int) ((FRAME_WIDTH / 4) * 1.49) < FRAME_HEIGHT / 2)
      info.setBounds(
          FRAME_WIDTH / 4 + 60,
          (int) ((FRAME_WIDTH / 4) * 1.49) + 50,
          FRAME_WIDTH - (FRAME_WIDTH / 4 + 80),
          30);
    else
      info.setBounds(
          (int) ((FRAME_HEIGHT / 2) * 0.67) + 60,
          FRAME_HEIGHT / 2 + 50,
          FRAME_WIDTH - ((int) ((FRAME_HEIGHT / 2) * 0.67) + 80),
          30);

    info.setText(
        "<html><h4> "
            + "Data di Uscita: "
            + scheda.relese
            + "<br>"
            + "Generi: "
            + scheda.getGeneri()
            + "</html>");
    info.setVisible(true);
    this.add(info);
    drawRating();

    downloads =
        new ImageButton(
            ImageUtils.getImage("gui/icon64px/download.png"),
            ImageUtils.getImage("gui/icon64px/download_over.png"),
            ImageUtils.getImage("gui/icon64px/download_over.png"),
            OpenDownloads);
    downloads.setBounds((FRAME_WIDTH - 64) / 2, FRAME_HEIGHT - 100, 64, 64);
    downloads.setVisible(!syncRunning);
    downloads.setToolTipText("Scarica");
    this.add(downloads);

    sync = new AnimatedImageButton("SyncBig(n)", 5, null, 500);
    sync.setBounds((FRAME_WIDTH - 64) / 2, FRAME_HEIGHT - 100, 64, 64);
    sync.setToolTipText("Sincronizzazione con il server Attedere qualche secondo");
    sync.setVisible(syncRunning);
    this.add(sync);

    if (backGround == null) {
      backGround = new JLabel();
      scheda.initBack_w1920(backGround);
    }

    backGround.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT);

    if (scheda.back_w1920 != null) {
      if (backGround.getWidth() > backGround.getHeight()) {
        BufferedImage img =
            ImageUtils.scaleWithAspectHeight(scheda.back_w1920, backGround.getHeight());
        if (img.getWidth() < backGround.getWidth())
          img = ImageUtils.scaleWithAspectWidth(scheda.back_w1920, backGround.getWidth());
        backGround.setIcon(ImageUtils.getIcon(img));
      } else {
        BufferedImage img =
            ImageUtils.scaleWithAspectWidth(scheda.back_w1920, backGround.getWidth());
        if (img.getHeight() < backGround.getHeight())
          img = ImageUtils.scaleWithAspectHeight(scheda.back_w1920, backGround.getHeight());
        backGround.setIcon(ImageUtils.getIcon(img));
      }
    }
    this.add(backGround);
    super.loadComponent();
  }