22 package com.realtime.crossfire.jxclient.skin.factory;
30 import java.awt.Color;
32 import java.awt.Image;
33 import java.util.ArrayList;
34 import java.util.Collection;
35 import org.jetbrains.annotations.NotNull;
36 import org.jetbrains.annotations.Nullable;
137 public DialogFactory(@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, @NotNull
final Font titleFont, @NotNull
final Color titleColor, @NotNull
final Color titleBackgroundColor,
final float frameAlpha) {
148 if (frameAlpha < 0.0F || frameAlpha > 1.0F) {
149 throw new IllegalArgumentException(
"alpha transparency should be between 0 and 1 inclusive");
151 final int sizeN = frameN.getHeight(null);
152 final int sizeS = frameS.getHeight(null);
153 final int sizeW = frameW.getWidth(null);
154 final int sizeE = frameE.getWidth(null);
155 if (frameNW.getHeight(null) != sizeN) {
156 throw new IllegalArgumentException(
"height of NW ("+frameNW.getHeight(null)+
") does not match height of N ("+sizeN+
")");
158 if (frameNE.getHeight(null) != sizeN) {
159 throw new IllegalArgumentException(
"height of NE ("+frameNE.getHeight(null)+
") does not match height of N ("+sizeN+
")");
161 if (frameSW.getHeight(null) != sizeS) {
162 throw new IllegalArgumentException(
"height of SW ("+frameSW.getHeight(null)+
") does not match height of N ("+sizeS+
")");
164 if (frameSE.getHeight(null) != sizeS) {
165 throw new IllegalArgumentException(
"height of SE ("+frameSE.getHeight(null)+
") does not match height of N ("+sizeS+
")");
167 if (frameNW.getWidth(null) != sizeW) {
168 throw new IllegalArgumentException(
"width of NW ("+frameNW.getWidth(null)+
") does not match width of W");
170 if (frameNE.getWidth(null) != sizeE) {
171 throw new IllegalArgumentException(
"width of NE ("+frameNE.getWidth(null)+
") does not match width of E");
173 if (frameSW.getWidth(null) != sizeW) {
174 throw new IllegalArgumentException(
"width of SW ("+frameSW.getWidth(null)+
") does not match width of W");
176 if (frameSE.getWidth(null) != sizeE) {
177 throw new IllegalArgumentException(
"width of SE ("+frameSE.getWidth(null)+
") does not match width of E");
179 final int contentWidth = frameC.getWidth(null);
180 final int contentHeight = frameC.getHeight(null);
181 if (frameN.getWidth(null) != contentWidth) {
182 throw new IllegalArgumentException(
"width of N ("+frameN.getWidth(null)+
") does not match width of C ("+contentWidth+
")");
184 if (frameS.getWidth(null) != contentWidth) {
185 throw new IllegalArgumentException(
"width of S ("+frameS.getWidth(null)+
") does not match width of C ("+contentWidth+
")");
187 if (frameW.getHeight(null) != contentHeight) {
188 throw new IllegalArgumentException(
"width of W ("+frameW.getHeight(null)+
") does not match height of C ("+contentHeight+
")");
190 if (frameE.getHeight(null) != contentHeight) {
191 throw new IllegalArgumentException(
"width of E ("+frameE.getHeight(null)+
") does not match height of C ("+contentHeight+
")");
195 final int intAlpha = (int)(255*frameAlpha);
196 this.titleBackgroundColor = intAlpha == 0 ? null :
new Color(titleBackgroundColor.getRed(), titleBackgroundColor.getGreen(), titleBackgroundColor.getBlue(), intAlpha);
209 final Collection<AbstractGUIElement> result =
new ArrayList<>();
210 result.add(
new GUIDialogBackground(tooltipManager, elementListener,
"dialog_background", frameAlpha, frameNW, frameN, frameNE, frameW, frameC, frameE, frameSW, frameS, frameSE));
212 if (!title.isEmpty()) {
213 result.add(
new GUIDialogTitle(tooltipManager, windowRenderer, elementListener,
"dialog_title", titleFont, titleColor, titleBackgroundColor, title));
Listener for GUIElement related events.
final Image frameE
The east frame picture.
final Image frameS
The south frame picture.
A background image for dialog windows.
final Image frameSE
The south-east frame picture.
Iterable< AbstractGUIElement > newDialog(@NotNull final TooltipManager tooltipManager, @NotNull final JXCWindowRenderer windowRenderer, @NotNull final GUIElementListener elementListener, @NotNull final String title)
Creates a new dialog.
float getFrameAlpha()
Returns the alpha value for the frame background.
final Image frameC
The center frame picture.
final Image frameN
The north frame picture.
Renders a Gui instance into a Frame.
final Image frameNE
The north-east frame picture.
final Image frameSW
The south-west frame picture.
A dialog title that allows to move the dialog.
final float frameAlpha
The alpha transparency for the dialog background, 1 is opaque and 0 is transparent.
final Image frameNW
The north-west frame picture.
final Color titleBackgroundColor
The background color for the dialog title.
Abstract base class for GUI elements to be shown in Guis.
DialogFactory(@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, @NotNull final Font titleFont, @NotNull final Color titleColor, @NotNull final Color titleBackgroundColor, final float frameAlpha)
Creates a new instance.
final Font titleFont
The font for the dialog title.
final Image frameW
The west frame picture.
A factory class to create "textbutton" instances.
final Color titleColor
The color for the dialog title.