//
// Core Program for TETDM
// ImagePanel2.java Version 1.00
// Copyright(C) 2011-2018 TETDM CORE MEMBER ALL RIGHTS RESERVED.
// This program is provided under the license.
//

package source.Tutorial;


import source.*;
import source.TextData.*;
import source.Utility.*;
import source.GameMode.*;
import source.Tutorial.*;

import java.io.File;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.GroupLayout.Alignment;
import java.awt.image.*;
import javax.imageio.ImageIO;
import java.applet.* ;
import static java.awt.BorderLayout.* ;


public class ImagePanel2 extends JFrame
{
    int widhtMax = 700;
    int heightMax = 450;
    
    public ImagePanel2(String absolutePath, String filename)
    {
        setBounds(100,100,widhtMax+20,heightMax+50);
        
        JPanel p = new JPanel();
        p.setBackground(Color.white);
        p.setOpaque(true);
        
        ImageIcon icon1 = new ImageIcon(absolutePath+"source"+File.separator+"Tutorial"+File.separator+"image"+File.separator+filename);
//        Image smallImg = icon1.getImage().getScaledInstance((int) (icon1.getIconWidth()*0.48), -1, Image.SCALE_SMOOTH);

        double scale = widhtMax/(double)icon1.getIconWidth();
        Image smallImg;

        System.out.println("scale, widht, height = "+scale+" : "+icon1.getIconWidth()+" : "+icon1.getIconHeight());
        
        if(icon1.getIconHeight()*scale <= heightMax)
            smallImg = icon1.getImage().getScaledInstance(widhtMax, -1, Image.SCALE_SMOOTH);
        else
            smallImg = icon1.getImage().getScaledInstance(-1, heightMax, Image.SCALE_SMOOTH);
        
        ImageIcon smallIcon = new ImageIcon(smallImg);
        
        JLabel label1 = new JLabel(smallIcon);
        label1.setPreferredSize(new Dimension(widhtMax,heightMax));
        
        p.add(label1);
        
        Container contentPane = getContentPane();
        contentPane.add(p, BorderLayout.CENTER);
    }
}
