下面列出了javax.swing.ImageIcon#getImage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Returns the JFreeChart logo (a picture of a gorilla).
*
* @return The JFreeChart logo.
*/
public Image getLogo() {
Image logo = super.getLogo();
if (logo == null) {
URL imageURL = this.getClass().getClassLoader().getResource(
"org/jfree/chart/gorilla.jpg");
if (imageURL != null) {
ImageIcon temp = new ImageIcon(imageURL);
// use ImageIcon because it waits for the image to load...
logo = temp.getImage();
setLogo(logo);
}
}
return logo;
}
/**
* Returns a scaled down image if the height or width is smaller than the
* image size.
*
* @param icon
* the image icon.
* @param newHeight
* the preferred height.
* @param newWidth
* the preferred width.
* @return the icon.
*/
public static ImageIcon scaleImageIcon(ImageIcon icon, int newHeight,
int newWidth) {
Image img = icon.getImage();
int height = icon.getIconHeight();
int width = icon.getIconWidth();
if (height > newHeight) {
height = newHeight;
}
if (width > newWidth) {
width = newWidth;
}
img = img.getScaledInstance(width, height, Image.SCALE_SMOOTH);
return new ImageIcon(img);
}
public MessageWindow(Rectangle rect) {
this.rect = rect;
innerRect = new Rectangle(
rect.x + EDGE_WIDTH,
rect.y + EDGE_WIDTH,
rect.width - EDGE_WIDTH * 2,
rect.height - EDGE_WIDTH * 2);
textRect = new Rectangle(
innerRect.x + 16,
innerRect.y + 16,
320,
120);
// ���b�Z�[�W�G���W�����쐬
messageEngine = new MessageEngine();
// �J�[�\���C���[�W�����[�h
ImageIcon icon = new ImageIcon(getClass().getResource("image/cursor.gif"));
cursorImage = icon.getImage();
timer = new Timer();
}
public MessageWindow(Rectangle rect) {
this.rect = rect;
innerRect = new Rectangle(
rect.x + EDGE_WIDTH,
rect.y + EDGE_WIDTH,
rect.width - EDGE_WIDTH * 2,
rect.height - EDGE_WIDTH * 2);
textRect = new Rectangle(
innerRect.x + 16,
innerRect.y + 16,
320,
120);
// ���b�Z�[�W�G���W�����쐬
messageEngine = new MessageEngine();
// �J�[�\���C���[�W�����[�h
ImageIcon icon = new ImageIcon(getClass().getResource("image/cursor.gif"));
cursorImage = icon.getImage();
timer = new Timer();
}
/**
* Validates if the image is one of the following types: jpg, png, gif.
*
* @param imageData
* @param contentType
* @throws ValidationException
* Is thrown if the image data is not of the expected type.
*/
public static void validateImageType(byte[] imageData, String contentType)
throws ValidationException {
if (contentType == null || contentType.length() == 0) {
throw new ValidationException(ReasonEnum.IMAGE_TYPE, "image type",
null);
}
final ImageIcon image = new ImageIcon(imageData);
if (image.getImage() == null) {
throw new ValidationException(ReasonEnum.IMAGE_TYPE,
"image format", null);
}
if (!contentType.equalsIgnoreCase("image/jpeg")
&& !contentType.equalsIgnoreCase("image/jpg")
&& !contentType.equalsIgnoreCase("image/pjpeg")
&& !contentType.equalsIgnoreCase("image/png")
&& !contentType.equalsIgnoreCase("image/x-png")
&& !contentType.equalsIgnoreCase("image/gif")) {
throw new ValidationException(ReasonEnum.IMAGE_TYPE, "image type",
new Object[] { contentType });
}
}
/**
* Returns the JFreeChart logo (a picture of a gorilla).
*
* @return The JFreeChart logo.
*/
public Image getLogo() {
Image logo = super.getLogo();
if (logo == null) {
URL imageURL = this.getClass().getClassLoader().getResource(
"org/jfree/chart/gorilla.jpg");
if (imageURL != null) {
ImageIcon temp = new ImageIcon(imageURL);
// use ImageIcon because it waits for the image to load...
logo = temp.getImage();
setLogo(logo);
}
}
return logo;
}
/**
* Cr茅e un panneau anim茅 contenant l'image pass茅e en param猫tre. L'animation
* ne d茅marre que par un appel 脿 start().
*
* @param message Le message 脿 afficher
* @param icon L'image 脿 afficher et 脿 animer
* @author Romain Guy
*/
public AnimatedPanel(String message, ImageIcon icon) {
this.message = message;
this.font = getFont().deriveFont(14.0f);
Image image = icon.getImage();
originalImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
convolvedImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = originalImage.createGraphics();
g.drawImage(image, 0, 0, this);
g.dispose();
setBrightness(1.0f);
setOpaque(false);
}
/**
* �C���[�W�����[�h����
*
*/
private void loadImage() {
ImageIcon icon = new ImageIcon(getClass().getResource("image/beam.gif"));
image = icon.getImage();
// ���ƍ������Z�b�g
width = image.getWidth(panel);
height = image.getHeight(panel);
}
/**
* �C���[�W�����[�h����
*
*/
private void loadImage() {
// �G�C���A���̃C���[�W��ǂݍ���
// ImageIcon���g����MediaTracker���g��Ȃ��Ă���
ImageIcon icon = new ImageIcon(getClass()
.getResource("image/alien.gif"));
image = icon.getImage();
// ���ƍ������Z�b�g
width = image.getWidth(panel);
height = image.getHeight(panel);
}
private void loadImage(String filename) {
ImageIcon icon = new ImageIcon(getClass().getResource(filename));
image = icon.getImage();
}
/**
* �C���[�W�����[�h����
* @param filename �C���[�W�t�@�C����
*/
private void loadImage(String filename) {
ImageIcon icon = new ImageIcon(getClass().getResource(
"image/" + filename));
image = icon.getImage();
}
/**
* �u���b�N�̃C���[�W�����[�h
*
* @param filename
*/
private void loadImage(String filename) {
// �u���b�N�̃C���[�W��ǂݍ���
ImageIcon icon = new ImageIcon(getClass().getResource(filename));
blockImage = icon.getImage();
}
private void loadImage(String filename) {
ImageIcon icon = new ImageIcon(getClass().getResource(filename));
image = icon.getImage();
}
private void loadImage() {
// �L�����N�^�[�̃C���[�W�����[�h
ImageIcon icon = new ImageIcon(getClass().getResource("image/chara.gif"));
charaImage = icon.getImage();
}
private void loadImage(String filename) {
ImageIcon icon = new ImageIcon(getClass().getResource(filename));
image = icon.getImage();
}
private void loadImage() {
// �}�b�v�`�b�v�̃C���[�W�����[�h
ImageIcon icon = new ImageIcon(getClass().getResource("image/mapchip.gif"));
chipImage = icon.getImage();
}
/**
* �C���[�W�����[�h����
*/
private void loadImage() {
ImageIcon icon = new ImageIcon(getClass().getResource("image/block.gif"));
blockImage = icon.getImage();
}
private void loadImage() {
// �}�b�v�`�b�v�̃C���[�W�����[�h
ImageIcon icon = new ImageIcon(getClass().getResource("image/mapchip.gif"));
chipImage = icon.getImage();
}
private void loadImage() {
// �L�����N�^�[�̃C���[�W�����[�h
ImageIcon icon = new ImageIcon(getClass().getResource("image/chara.gif"));
charaImage = icon.getImage();
}
private void loadImage() {
// �L�����N�^�[�̃C���[�W�����[�h
ImageIcon icon = new ImageIcon(getClass().getResource("image/chara.gif"));
charaImage = icon.getImage();
}