22 package com.realtime.crossfire.jxclient.gui.misc;
27 import java.awt.AlphaComposite;
28 import java.awt.Dimension;
29 import java.awt.Graphics;
30 import java.awt.Graphics2D;
31 import java.awt.Image;
32 import java.awt.Transparency;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
143 public GUIDialogBackground(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final String
name,
final float alpha, @NotNull
final Image frameNW, @NotNull
final Image frameN, @NotNull
final Image frameNE, @NotNull
final Image frameW, @NotNull
final Image frameC, @NotNull
final Image frameE, @NotNull
final Image frameSW, @NotNull
final Image frameS, @NotNull
final Image frameSE) {
144 super(tooltipManager, elementListener, name, alpha < 1.0F ? Transparency.TRANSLUCENT : Transparency.OPAQUE);
155 heightN = frameN.getHeight(null);
156 heightS = frameS.getHeight(null);
157 widthW = frameW.getWidth(null);
158 widthE = frameE.getWidth(null);
159 if (frameNW.getWidth(null) !=
widthW) {
160 throw new IllegalArgumentException(
"frameNW.width="+frameNW.getWidth(null)+
" != "+widthW+
"=widthW");
162 if (frameSW.getWidth(null) !=
widthW) {
163 throw new IllegalArgumentException(
"frameSW.width="+frameSW.getWidth(null)+
" != "+widthW+
"=widthW");
165 if (frameNE.getWidth(null) !=
widthE) {
166 throw new IllegalArgumentException(
"frameNE.width="+frameNE.getWidth(null)+
" != "+widthE+
"=widthE");
168 if (frameSE.getWidth(null) !=
widthE) {
169 throw new IllegalArgumentException(
"frameSE.width="+frameSE.getWidth(null)+
" != "+widthE+
"=widthE");
171 if (frameNW.getHeight(null) !=
heightN) {
172 throw new IllegalArgumentException(
"frameNW.height="+frameNW.getHeight(null)+
" != "+heightN+
"heightN");
174 if (frameSW.getHeight(null) !=
heightS) {
175 throw new IllegalArgumentException(
"frameSW.height="+frameSW.getHeight(null)+
" != "+heightS+
"=heightS");
177 if (frameNE.getHeight(null) !=
heightN) {
178 throw new IllegalArgumentException(
"frameNE.height="+frameNE.getHeight(null)+
" != "+heightN+
"=heightN");
180 if (frameSE.getHeight(null) !=
heightS) {
181 throw new IllegalArgumentException(
"frameSE.height="+frameSE.getHeight(null)+
" != "+heightS+
"=heightS");
190 final Graphics paint;
192 final Graphics2D g2d = (Graphics2D)g.create();
193 g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
199 super.paintComponent(paint);
200 final int w = Math.max(1, getWidth()-widthW-widthE);
201 final int h = Math.max(1, getHeight()-heightN-heightS);
202 paint.drawImage(frameNW, 0, 0, null);
203 paint.drawImage(frameN, widthW, 0, widthW+w, heightN, 0, 0, w, heightN, null);
204 paint.drawImage(frameNE, widthW+w, 0, null);
205 paint.drawImage(frameW, 0, heightN, widthW, heightN+h, 0, 0, widthW, h, null);
206 paint.drawImage(frameC, widthW, heightN, widthW+w, heightN+h, 0, 0, w, h, null);
207 paint.drawImage(frameE, widthW+w, heightN, widthW+w+widthE, heightN+h, 0, 0, widthE, h, null);
208 paint.drawImage(frameSW, 0, heightN+h, null);
209 paint.drawImage(frameS, widthW, heightN+h, widthW+w, heightN+h+heightS, 0, 0, w, heightS, null);
210 paint.drawImage(frameSE, widthW+w, heightN+h, null);
231 return new Dimension(widthW+1+widthE, heightN+1+heightS);
Listener for GUIElement related events.
Dimension getPreferredSize()
final int widthW
The width of the west border in pixel.
final TooltipManager tooltipManager
The TooltipManager to update.
final Image frameE
The east frame picture.
final int heightN
The width of the north border in pixel.
A background image for dialog windows.
final Image frameNW
The north-west frame picture.
void paintComponent(@NotNull final Graphics g)
final GUIElementListener elementListener
The GUIElementListener to notify.
GUIDialogBackground(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, final float alpha, @NotNull final Image frameNW, @NotNull final Image frameN, @NotNull final Image frameNE, @NotNull final Image frameW, @NotNull final Image frameC, @NotNull final Image frameE, @NotNull final Image frameSW, @NotNull final Image frameS, @NotNull final Image frameSE)
Creates a new instance.
final String name
The name of this element.
Dimension getMinimumSize()
final Image frameSE
The south-east frame picture.
static final long serialVersionUID
The serial version UID.
final Image frameN
The north frame picture.
final float alpha
The alpha value for the background, 1 opaque 0 full transparent.
final Image frameC
The center frame picture.
final Image frameW
The west frame picture.
Abstract base class for GUI elements to be shown in Guis.
final Image frameSW
The south-west frame picture.
final Image frameNE
The north-east frame picture.
final Image frameS
The south frame picture.
final int widthE
The width of the east border in pixel.
final int heightS
The width of the south border in pixel.