Class ClientUI


  • @Singleton
    public class ClientUI
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.awt.image.BufferedImage ICON_128  
      static java.awt.image.BufferedImage ICON_16  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void flashTaskbar()
      Request user attention to the window (flash the taskbar)
      void forceFocus()
      Attempt to forcibly bring the client frame to front
      java.awt.Point getCanvasOffset()
      Get offset of game canvas in game window
      java.awt.Cursor getCurrentCursor()
      Returns current cursor set on game container
      java.awt.Cursor getDefaultCursor()
      Returns current custom cursor or default system cursor if cursor is not set
      java.awt.GraphicsConfiguration getGraphicsConfiguration()  
      int getHeight()
      Gets component height.
      java.awt.Insets getInsets()  
      java.awt.TrayIcon getTrayIcon()  
      int getWidth()
      Gets component width.
      void init()
      Initialize UI.
      boolean isFocused()
      Returns true if this component has focus.
      void paint​(java.awt.Graphics graphics)
      Paint this component to target graphics
      void paintOverlays​(java.awt.Graphics2D graphics)
      Paint UI related overlays to target graphics
      void requestFocus()
      Request focus on this component and then on client component
      void resetCursor()
      Resets client window cursor to default one.
      void setCursor​(java.awt.Cursor cursor)
      Changes cursor for client window.
      void setCursor​(java.awt.image.BufferedImage image, java.lang.String name)
      Changes cursor for client window.
      void show()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ICON_128

        public static final java.awt.image.BufferedImage ICON_128
      • ICON_16

        public static final java.awt.image.BufferedImage ICON_16
    • Method Detail

      • init

        public void init()
                  throws java.lang.Exception
        Initialize UI.
        Throws:
        java.lang.Exception
      • show

        public void show()
      • paint

        public void paint​(java.awt.Graphics graphics)
        Paint this component to target graphics
        Parameters:
        graphics - the graphics
      • getWidth

        public int getWidth()
        Gets component width.
        Returns:
        the width
      • getHeight

        public int getHeight()
        Gets component height.
        Returns:
        the height
      • isFocused

        public boolean isFocused()
        Returns true if this component has focus.
        Returns:
        true if component has focus
      • requestFocus

        public void requestFocus()
        Request focus on this component and then on client component
      • forceFocus

        public void forceFocus()
        Attempt to forcibly bring the client frame to front
      • flashTaskbar

        public void flashTaskbar()
        Request user attention to the window (flash the taskbar)
      • getCurrentCursor

        public java.awt.Cursor getCurrentCursor()
        Returns current cursor set on game container
        Returns:
        awt cursor
      • getDefaultCursor

        public java.awt.Cursor getDefaultCursor()
        Returns current custom cursor or default system cursor if cursor is not set
        Returns:
        awt cursor
      • setCursor

        public void setCursor​(java.awt.image.BufferedImage image,
                              java.lang.String name)
        Changes cursor for client window. Requires $init() to be called first. FIXME: This is working properly only on Windows, Linux and Mac are displaying cursor incorrectly
        Parameters:
        image - cursor image
        name - cursor name
      • setCursor

        public void setCursor​(java.awt.Cursor cursor)
        Changes cursor for client window. Requires $init() to be called first.
        Parameters:
        cursor - awt cursor
      • getCanvasOffset

        public java.awt.Point getCanvasOffset()
        Get offset of game canvas in game window
        Returns:
        game canvas offset
      • getInsets

        public java.awt.Insets getInsets()
      • paintOverlays

        public void paintOverlays​(java.awt.Graphics2D graphics)
        Paint UI related overlays to target graphics
        Parameters:
        graphics - target graphics
      • getGraphicsConfiguration

        public java.awt.GraphicsConfiguration getGraphicsConfiguration()
      • getTrayIcon

        public java.awt.TrayIcon getTrayIcon()