Package de.gurkenlabs.litiengine
Class GameWindow
java.lang.Object
de.gurkenlabs.litiengine.GameWindow
public final class GameWindow
extends java.lang.ObjectThe
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 interfaceGameWindow.ResolutionChangedListenerThis listener interface receives resolution changed events of the game window.Method Summary
Modifier and Type Method Description MouseCursorcursor()Gets the visual representation of the mouse cursor on theGameWindow.java.awt.geom.Point2DgetCenter()Gets the current resolution scale.intgetHeight()Gets the window height.java.awt.ContainergetHostControl()Gets theGameWindow's JFrame, abstracted as a Container.java.awt.PointgetLocationOnScreen()Gets the screen location of the window's top left corner.RenderComponentgetRenderComponent()Gets the AWT canvas that is used to render the game's content on.java.awt.DimensiongetResolution()Gets the window resolution wrapped in aDimensionobject.floatgetResolutionScale()Gets the current resolution scale.java.awt.DimensiongetSize()Gets the window width and height wrapped in aDimensionobject.intgetWidth()Gets the window width.booleanisFocusOwner()Returns true if the GameWindow is the focus owner.voidonResolutionChanged(GameWindow.ResolutionChangedListener listener)Adds the specified resolution changed listener to receive events when the dimensions of this game window are changed.voidremoveResolutionChangedListener(GameWindow.ResolutionChangedListener listener)Removes the specified resolution changed listener.voidsetIcon(java.awt.Image image)Sets the icon image for the window's hostingJFrame.voidsetIcons(java.util.List<? extends java.awt.Image> images)Sets the icons for the window's hostingJFrame.voidsetResolution(Resolution res)Sets the resolution for the GameWindow.voidsetTitle(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'sJFrameas an abstract AWTContainer.
getSize
public java.awt.Dimension getSize()Gets the window width and height wrapped in aDimensionobject.- 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 aDimensionobject.- 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
Pointof 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- TheImageto 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 severalIcons with the correct Dimension will be chosen automatically from the list.- Parameters:
images- A list ofImagesto 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. Anullvalue is treated as an empty string, "".- See Also:
Frame.setTitle(java.lang.String)
