/* This file is part of SlumDroid <https://code.google.com/p/slumdroid/>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License <http://www.gnu.org/licenses/gpl-3.0.txt>
* for more details.
*
* Copyright (C) 2013-2015 Gennaro Imparato
*/
package it.slumdroid.utilities.module.guianalyzer;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
// TODO: Auto-generated Javadoc
/**
* The Class ImagePanel.
*/
public class ImagePanel extends JPanel {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The image. */
private Image image;
/**
* Instantiates a new image panel.
*
* @param image the image
*/
public ImagePanel(String image) {
this(new ImageIcon(image).getImage());
}
/**
* Instantiates a new image panel.
*
* @param image the image
*/
public ImagePanel(Image image) {
this.image = image;
Dimension size = new Dimension(image.getWidth(null), image.getHeight(null));
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
setSize(size);
setLayout(null);
}
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
@Override
public void paintComponent(Graphics graph) {
graph.drawImage(image, 0, 0, null);
}
}