 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
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;
final Image frameSW
The south-west frame picture.
final GuiFactory guiFactory
The global GuiFactory instance.
boolean isAutoSize()
Returns whether this dialog is an auto-size dialog.
boolean right
Whether the right border is being dragged.
boolean opaque
Whether the background is opaque.
Combines a list of GUIElements to for a gui.
final int heightN
The width of the north border in pixel.
Gui getGui(@NotNull final AbstractGUIElement element)
Returns the Gui an element is part of.
int startX2
The x coordinate of the right border of the dialog when resizing started.
final Image frameN
The north frame picture.
final float alpha
The alpha value for the background, 1 opaque 0 full transparent.
boolean top
Whether the top border is being dragged.
final Image frameW
The west frame picture.
final Image frameE
The east frame picture.
int getDialogBorderLeft()
Returns the size of the dialog's left border.
Abstract base class for GUI elements to be shown in Guis.
final GUIElementListener elementListener
The GUIElementListener to notify.
final int heightS
The width of the south border in pixel.
final Image frameS
The south frame picture.
final int widthE
The width of the east border in pixel.
final Image frameNW
The north-west frame picture.
final Image frameNE
The north-east frame picture.
int getWindowHeight()
Returns the height of the client area.
boolean isUserResizable()
Returns whether the dialog is user-resizable.
int getDialogBorderBottom()
Returns the size of the dialog's bottom border.
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)
Creates a new instance.
int getDialogBorderRight()
Returns the size of the dialog's right border.
int startY1
The y coordinate of the top border of the dialog when resizing started.
int getWindowWidth()
Returns the width of the client area.
boolean left
Whether the left border is being dragged.
Dimension getPreferredSize()
int startX1
The x coordinate of the left border of the dialog when resizing started.
final JXCWindowRenderer windowRenderer
The JXCWindowRenderer this element belongs to.
Renders a Gui instance into a Frame.
void setBounds(final int x, final int y, final int width, final int height, final int windowWidth, final int windowHeight)
Sets the position and size of this dialog.
boolean dragging
Whether the dialog is currently being resized.
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
JComponent getComponent()
Returns the JComponent for this instance.
void mouseDragged(@NotNull final MouseEvent e)
Will be called when the mouse moves within this component while the button is pressed.
static final long serialVersionUID
The serial version UID.
Information for displaying tooltips.
int mouseY
The relative mouse y position while resizing the dialog.
Factory for creating Gui instances.
final String name
The name of this element.
void setOpaqueDialogBackground(final boolean opaque)
Sets whether the dialog's background is opaque.
void moveTo(@NotNull final MouseEvent e)
Moves the dialog the given point.
A background image for dialog windows.
TooltipText getTooltip()
Returns the current tooltip text.
final Image frameC
The center frame picture.
final int widthW
The width of the west border in pixel.
final TooltipManager tooltipManager
The TooltipManager to update.
final Image frameSE
The south-east frame picture.
int startY2
The y coordinate of the bottom border of the dialog when resizing started.
int mouseX
The relative mouse x position while resizing the dialog.
void mousePressed(@NotNull final MouseEvent e)
Will be called when the user has pressed the mouse inside this element.
Dimension getMinimumSize()
void paintComponent(@NotNull final Graphics g)
boolean bottom
Whether the bottom border is being dragged.
void mouseReleased(@NotNull final MouseEvent e)
Will be called when the user has released the mouse.
Listener for GUIElement related events.
int getDialogBorderTop()
Returns the size of the dialog's top border.