23 package com.realtime.crossfire.jxclient.gui.misc;
31 import java.awt.AlphaComposite;
32 import java.awt.Dimension;
33 import java.awt.Graphics;
34 import java.awt.Graphics2D;
35 import java.awt.Image;
36 import java.awt.Point;
37 import java.awt.event.MouseEvent;
38 import javax.swing.JComponent;
39 import org.jetbrains.annotations.NotNull;
40 import org.jetbrains.annotations.Nullable;
226 public GUIDialogBackground(@NotNull
final TooltipManager tooltipManager, @NotNull
final JXCWindowRenderer windowRenderer, @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, @NotNull
final GuiFactory guiFactory) {
245 throw new IllegalArgumentException(
"frameNW.width="+
frameNW.getWidth(
null)+
" != "+
widthW+
"=widthW");
248 throw new IllegalArgumentException(
"frameSW.width="+
frameSW.getWidth(
null)+
" != "+
widthW+
"=widthW");
251 throw new IllegalArgumentException(
"frameNE.width="+
frameNE.getWidth(
null)+
" != "+
widthE+
"=widthE");
254 throw new IllegalArgumentException(
"frameSE.width="+
frameSE.getWidth(
null)+
" != "+
widthE+
"=widthE");
257 throw new IllegalArgumentException(
"frameNW.height="+
frameNW.getHeight(
null)+
" != "+
heightN+
"heightN");
260 throw new IllegalArgumentException(
"frameSW.height="+
frameSW.getHeight(
null)+
" != "+
heightS+
"=heightS");
263 throw new IllegalArgumentException(
"frameNE.height="+
frameNE.getHeight(
null)+
" != "+
heightN+
"=heightN");
266 throw new IllegalArgumentException(
"frameSE.height="+
frameSE.getHeight(
null)+
" != "+
heightS+
"=heightS");
275 if (this.opaque ==
opaque) {
286 final Graphics paint;
290 final Graphics2D g2d = (Graphics2D)g.create();
291 g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
alpha));
295 super.paintComponent(paint);
298 paint.drawImage(
frameNW, 0, 0,
null);
314 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
321 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
337 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
339 return frameN.getHeight(
null);
343 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
345 return frameW.getWidth(
null);
349 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
351 return frameE.getWidth(
null);
355 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
357 return frameS.getHeight(
null);
362 super.mousePressed(e);
374 final Point point = e.getLocationOnScreen();
378 right = e.getX() >= getWidth()-
frameE.getWidth(
null);
380 bottom = e.getY() >= getHeight()-
frameS.getHeight(
null);
393 super.mouseReleased(e);
402 super.mouseDragged(e);
412 private void moveTo(@NotNull
final MouseEvent e) {
423 final Point point = e.getLocationOnScreen();
425 final Dimension minimumSize = gui.
getComponent().getMinimumSize();
426 final Dimension maximumSize = gui.
getComponent().getMaximumSize();
433 if (minimumSize !=
null && x2-x1 < minimumSize.width) {
434 x1 = x2-minimumSize.width;
436 if (maximumSize !=
null && x2-x1 > maximumSize.width) {
437 x1 = x2-maximumSize.width;
442 if (minimumSize !=
null && x2-x1 < minimumSize.width) {
443 x2 = x1+minimumSize.width;
445 if (maximumSize !=
null && x2-x1 > maximumSize.width) {
446 x2 = x1+maximumSize.width;
458 if (minimumSize !=
null && y2-y1 < minimumSize.height) {
459 y1 = y2-minimumSize.height;
461 if (maximumSize !=
null && y2-y1 > maximumSize.height) {
462 y1 = y2-maximumSize.height;
467 if (minimumSize !=
null && y2-y1 < minimumSize.height) {
468 y2 = y1+minimumSize.height;
470 if (maximumSize !=
null && y2-y1 > maximumSize.height) {
471 y2 = y1+maximumSize.height;