Crossfire JXClient, Trunk  R20561
GUIPicture.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.gui.misc;
23 
27 import java.awt.Dimension;
28 import java.awt.Graphics;
29 import java.awt.Image;
30 import java.awt.Transparency;
31 import java.awt.image.BufferedImage;
32 import org.jetbrains.annotations.NotNull;
33 
38 public class GUIPicture extends AbstractGUIElement {
39 
43  private static final long serialVersionUID = 1;
44 
48  @NotNull
49  private final Image image;
50 
54  @NotNull
55  private final Dimension preferredSize;
56 
67  public GUIPicture(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final BufferedImage image, final float alpha, final int preferredWidth, final int preferredHeight) {
68  super(tooltipManager, elementListener, name, alpha < 1.0F ? Transparency.TRANSLUCENT : image.getTransparency());
69  this.image = image;
70  preferredSize = new Dimension(preferredWidth, preferredHeight);
71  }
72 
76  @Override
77  public void paintComponent(@NotNull final Graphics g) {
78  super.paintComponent(g);
79  g.drawImage(image, 0, 0, null);
80  }
81 
85  @NotNull
86  @Override
87  public Dimension getPreferredSize() {
88  return new Dimension(preferredSize);
89  }
90 
94  @NotNull
95  @Override
96  public Dimension getMinimumSize() {
97  return new Dimension(preferredSize);
98  }
99 
103  @NotNull
104  @Override
105  public Dimension getMaximumSize() {
106  return new Dimension(preferredSize);
107  }
108 
109 }
final TooltipManager tooltipManager
The TooltipManager to update.
void paintComponent(@NotNull final Graphics g)
Definition: GUIPicture.java:77
final Image image
The picture to paint.
Definition: GUIPicture.java:49
final GUIElementListener elementListener
The GUIElementListener to notify.
GUIPicture(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final BufferedImage image, final float alpha, final int preferredWidth, final int preferredHeight)
Creates a new instance.
Definition: GUIPicture.java:67
static final long serialVersionUID
The serial version UID.
Definition: GUIPicture.java:43
Abstract base class for GUI elements to be shown in Guis.
final Dimension preferredSize
The preferred size of this component.
Definition: GUIPicture.java:55
A AbstractGUIElement that displays a picture.
Definition: GUIPicture.java:38