Package de.gurkenlabs.litiengine
Class GameWindow
java.lang.Object
de.gurkenlabs.litiengine.GameWindow
public final class GameWindow
extends java.lang.Object
The
It provides the possibility to set a title, provide an icon, configure the cursor or get information about the resolution.
GameWindow
class is a wrapper for the game's visual window in which the RenderComponent
lives.It provides the possibility to set a title, provide an icon, configure the cursor or get information about the resolution.
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GameWindow.ResolutionChangedListener
This listener interface receives resolution changed events of the game window.Method Summary
Modifier and Type Method Description MouseCursor
cursor()
Gets the visual representation of the mouse cursor on theGameWindow
.java.awt.geom.Point2D
getCenter()
Gets the current resolution scale.int
getHeight()
Gets the window height.java.awt.Container
getHostControl()
Gets theGameWindow
's JFrame, abstracted as a Container.java.awt.Point
getLocationOnScreen()
Gets the screen location of the window's top left corner.RenderComponent
getRenderComponent()
Gets the AWT canvas that is used to render the game's content on.java.awt.Dimension
getResolution()
Gets the window resolution wrapped in aDimension
object.float
getResolutionScale()
Gets the current resolution scale.java.awt.Dimension
getSize()
Gets the window width and height wrapped in aDimension
object.int
getWidth()
Gets the window width.boolean
isFocusOwner()
Returns true if the GameWindow is the focus owner.void
onResolutionChanged(GameWindow.ResolutionChangedListener listener)
Adds the specified resolution changed listener to receive events when the dimensions of this game window are changed.void
removeResolutionChangedListener(GameWindow.ResolutionChangedListener listener)
Removes the specified resolution changed listener.void
setIcon(java.awt.Image image)
Sets the icon image for the window's hostingJFrame
.void
setIcons(java.util.List<? extends java.awt.Image> images)
Sets the icons for the window's hostingJFrame
.void
setResolution(Resolution res)
Sets the resolution for the GameWindow.void
setTitle(java.lang.String title)
Sets the title for this window to the specified string.
Method Details
isFocusOwner
public boolean isFocusOwner()Returns true if the GameWindow is the focus owner.- Returns:
- true if the GameWindow is the focus owner; false otherwise
onResolutionChanged
Adds the specified resolution changed listener to receive events when the dimensions of this game window are changed.- Parameters:
listener
- The listener to add.
removeResolutionChangedListener
Removes the specified resolution changed listener.- Parameters:
listener
- The listener to remove.
setResolution
Sets the resolution for the GameWindow.- Parameters:
res
- The desired Resolution to set for the GameWindow.- See Also:
Resolution
getResolutionScale
public float getResolutionScale()Gets the current resolution scale. The resolution scale is a float value dictating how much larger or smaller each pixel is rendered on screen.- Returns:
- The GameWindow's current resolution scale.
getCenter
public java.awt.geom.Point2D getCenter()Gets the current resolution scale. The resolution scale is a float value dictating how much larger or smaller each pixel is rendered on screen.- Returns:
- The
GameWindow
's current resolution scale.
getHostControl
public java.awt.Container getHostControl()Gets theGameWindow
's JFrame, abstracted as a Container.- Returns:
- The
GameWindow
'sJFrame
as an abstract AWTContainer
.
getSize
public java.awt.Dimension getSize()Gets the window width and height wrapped in aDimension
object.- Returns:
- The
GameWindow
's size as aDimension
.
getWidth
public int getWidth()Gets the window width.- Returns:
- The window width.
getHeight
public int getHeight()Gets the window height.- Returns:
- The window height.
getRenderComponent
Gets the AWT canvas that is used to render the game's content on.- Returns:
- The AWT render component onto which the game contents are rendered.
cursor
Gets the visual representation of the mouse cursor on theGameWindow
.This can be used to provide a custom cursor image, define its visibility or specify a rendering offset from the actual position.
- Returns:
- The mouse cursor of the game.
getResolution
public java.awt.Dimension getResolution()Gets the window resolution wrapped in aDimension
object.- Returns:
- The
GameWindow
's internal resolution as aDimension
.
getLocationOnScreen
public java.awt.Point getLocationOnScreen()Gets the screen location of the window's top left corner.- Returns:
- The
Point
of the window's top left corner. - See Also:
Component.getLocationOnScreen()
setIcon
public void setIcon(java.awt.Image image)Sets the icon image for the window's hostingJFrame
.- Parameters:
image
- TheImage
to be used as the window icon.- See Also:
JFrame.setIconImage(java.awt.Image)
setIcons
public void setIcons(java.util.List<? extends java.awt.Image> images)Sets the icons for the window's hostingJFrame
. Depending on the platform specifications, one or severalIcon
s with the correct Dimension will be chosen automatically from the list.- Parameters:
images
- A list ofImages
to be used as the window icons.- See Also:
Window.setIconImages(java.util.List<? extends java.awt.Image>)
setTitle
public void setTitle(java.lang.String title)Sets the title for this window to the specified string.- Parameters:
title
- the window title to be displayed in the frame's border. Anull
value is treated as an empty string, "".- See Also:
Frame.setTitle(java.lang.String)