Class UiModule

java.lang.Object
gaiasky.script.v2.impl.APIModule
gaiasky.script.v2.impl.UiModule
All Implemented Interfaces:
UiAPI

public class UiModule extends APIModule implements UiAPI
The UI module contains calls and methods to access, modify, and query the user interface.
  • Constructor Details

    • UiModule

      public UiModule(EventManager em, APIv2 api, String name)
      Create a new module with the given attributes.
      Parameters:
      api - Reference to the API class.
      name - Name of the module.
  • Method Details

    • display_message

      public void display_message(int id, String msg, float x, float y, float r, float g, float b, float a, float size)
      Description copied from interface: UiAPI
      Add a new one-line message in the screen with the given id and the given coordinates. If an object already exists with the given id, it is removed. However, if a message object already exists with the same id, its properties are updated. The messages placed with this method will not appear in the screenshots/frames in advanced mode. This is intended for running interactively only.
      Specified by:
      display_message in interface UiAPI
      Parameters:
      id - A unique identifier, used to identify this message when you want to remove it.
      msg - The string message, to be displayed in one line. But explicit newline breaks the line.
      x - The x coordinate of the bottom-left corner, in [0,1] from left to right. This is not resolution-dependant.
      y - The y coordinate of the bottom-left corner, in [0,1] from bottom to top. This is not resolution-dependant.
      r - The red component of the color in [0,1].
      g - The green component of the color in [0,1].
      b - The blue component of the color in [0,1].
      a - The alpha component of the color in [0,1].
      size - The size of the font. The system will use the existing font closest to the chosen size and scale it up or down to match the desired size. Scaling can cause artifacts, so to ensure the best font quality, stick to the existing sizes.
    • display_message

      public void display_message(int id, String msg, double x, double y, double[] color, double size)
      Description copied from interface: UiAPI
      Same as UiAPI.display_image(int, String, float, float, float, float, float, float) but using an array for the color instead of giving each component separately.
      Specified by:
      display_message in interface UiAPI
      Parameters:
      id - A unique identifier, used to identify this message when you want to remove it.
      msg - The string message, to be displayed in one line. But explicit newline breaks the line.
      x - The x coordinate of the bottom-left corner, in [0,1] from left to right. This is not resolution-dependant.
      y - The y coordinate of the bottom-left corner, in [0,1] from bottom to top. This is not resolution-dependant.
      color - The color as an array of RGBA (red, green, blue, alpha) values in [0,1].
      size - The size of the font. The system will use the existing font closest to the chosen size and scale it up or down to match the desired size. Scaling can cause artifacts, so to ensure the best font quality, stick to the existing sizes.
    • display_message

      public void display_message(int id, String message, double x, double y, List<?> color, double fontSize)
    • display_message

      public void display_message(int id, String message, float x, float y, float r, float g, float b, float a, int fontSize)
    • display_text

      public void display_text(int id, String msg, float x, float y, float max_w, float max_h, float r, float g, float b, float a, float size)
      Description copied from interface: UiAPI
      Add a new multi-line text in the screen with the given id, coordinates and size. If an object already exists with the given id, it is removed. However, if a text object already exists with the same id, its properties are updated. The texts placed with this method will not appear in the screenshots/frames in advanced mode. This is intended for running interactively only.
      Specified by:
      display_text in interface UiAPI
      Parameters:
      id - A unique identifier, used to identify this message when you want to remove it.
      msg - The string message, to be displayed line-wrapped in the box defined by maxWidth and maxHeight. Explicit newline still breaks the line.
      x - The x coordinate of the bottom-left corner, in [0,1] from left to right. This is not resolution-dependant.
      y - The y coordinate of the bottom-left corner, in [0,1] from bottom to top. This is not resolution-dependant.
      max_w - The maximum width in screen percentage [0,1]. Set to 0 to let the system decide.
      max_h - The maximum height in screen percentage [0,1]. Set to 0 to let the system decide.
      r - The red component of the color in [0,1].
      g - The green component of the color in [0,1].
      b - The blue component of the color in [0,1].
      a - The alpha component of the color in [0,1].
      size - The size of the font. The system will use the existing font closest to the chosen size.
    • display_text

      public void display_text(int id, String text, float x, float y, float maxWidth, float maxHeight, float r, float g, float b, float a, int fontSize)
    • display_image

      public void display_image(int id, String path, float x, float y, float r, float g, float b, float a)
      Description copied from interface: UiAPI
      Add a new image object at the given coordinates. If an object already exists with the given id, it is removed. However, if an image object already exists with the same id, its properties are updated.
      Warning: This method will only work in the asynchronous mode. Run the script with the "asynchronous" check box activated!
      Specified by:
      display_image in interface UiAPI
      Parameters:
      id - A unique identifier, used to identify this message when you want to remove it.
      path - The path to the image. It can either be an absolute path (not recommended) or a path relative to the Gaia Sky work directory.
      x - The x coordinate of the bottom-left corner, in [0,1] from left to right. This is not resolution-dependant.
      y - The y coordinate of the bottom-left corner, in [0,1] from bottom to top. This is not resolution-dependant.
      r - The red component of the color in [0,1].
      g - The green component of the color in [0,1].
      b - The blue component of the color in [0,1].
      a - The alpha component of the color in [0,1].
    • display_image

      public void display_image(int id, String path, double x, double y, double[] color)
      Description copied from interface: UiAPI
      Same as UiAPI.display_image(int, String, float, float, float, float, float, float) but using a double array for the color instead of each component separately.
      Specified by:
      display_image in interface UiAPI
      Parameters:
      id - A unique identifier, used to identify this message when you want to remove it.
      path - The path to the image. It can either be an absolute path (not recommended) or a path relative to the Gaia Sky work directory.
      x - The x coordinate of the bottom-left corner, in [0,1] from left to right. This is not resolution-dependant.
      y - The y coordinate of the bottom-left corner, in [0,1] from bottom to top. This is not resolution-dependant.
      color - The color as an array of RGBA (red, green, blue, alpha) values in [0,1].
    • display_image

      public void display_image(int id, String path, double x, double y, List<?> color)
    • display_image

      public void display_image(int id, String path, float x, float y)
      Description copied from interface: UiAPI
      Add a new image object at the given coordinates. If an object already exists with the given id, it is removed. However, if an image object already exists with the same id, its properties are updated.
      The messages placed with this method will not appear in the screenshots/frames in advanced mode. This is intended for running interactively only.
      Specified by:
      display_image in interface UiAPI
      Parameters:
      id - A unique identifier, used to identify this message when you want to remove it.
      path - The path to the image. It can either be an absolute path (not recommended) or a path relative to the Gaia Sky work directory.
      x - The x coordinate of the bottom-left corner, in [0,1] from left to right. This is not resolution-dependant.
      y - The y coordinate of the bottom-left corner, in [0,1] from bottom to top. This is not resolution-dependant.
    • remove_all_objects

      public void remove_all_objects()
      Description copied from interface: UiAPI
      Remove all objects (messages, texts and images).
      Specified by:
      remove_all_objects in interface UiAPI
    • remove_object

      public void remove_object(int id)
      Description copied from interface: UiAPI
      Specified by:
      remove_object in interface UiAPI
      Parameters:
      id - Integer with the integer id of the object to remove.
    • remove_objects

      public void remove_objects(int[] ids)
      Description copied from interface: UiAPI
      Remove the items with the given ids. They can either be messages, images or whatever else.

      The objects to remove are assumed to have been added with UiAPI.display_message(int, String, float, float, float, float, float, float, float), UiAPI.display_text(int, String, float, float, float, float, float, float, float, float, float), or UiAPI.display_image(int, String, float, float).

      Specified by:
      remove_objects in interface UiAPI
      Parameters:
      ids - Vector with the integer ids of the objects to remove.
    • remove_objects

      public void remove_objects(List<?> ids)
    • enable

      public void enable()
      Description copied from interface: UiAPI
      Enable the GUI rendering. This makes the user interface to be rendered and updated again if it was previously disabled. Otherwise, it has no effect.
      Specified by:
      enable in interface UiAPI
    • disable

      public void disable()
      Description copied from interface: UiAPI
      Disable the GUI rendering. This causes the user interface to no longer be rendered or updated.
      Specified by:
      disable in interface UiAPI
    • get_client_width

      public int get_client_width()
      Description copied from interface: UiAPI
      Return the width of the client area in logical pixels.
      Specified by:
      get_client_width in interface UiAPI
      Returns:
      The width in logical pixels.
    • get_client_height

      public int get_client_height()
      Description copied from interface: UiAPI
      Return the height of the client area in logical pixels.
      Specified by:
      get_client_height in interface UiAPI
      Returns:
      The height in logical pixels.
    • get_position_and_size

      public float[] get_position_and_size(String name)
      Description copied from interface: UiAPI
      Return the size and position of the GUI actor that goes by the given name, or null if such element does not exist.

      The actor names are given at creation, and are internal to the Gaia Sky source code. You need to dive into the source code if you want to manipulate GUI actors.

      Warning: This will only work in asynchronous mode.

      Specified by:
      get_position_and_size in interface UiAPI
      Parameters:
      name - The name of the gui element.
      Returns:
      A vector of floats with the position (0, 1) of the bottom left corner in pixels from the bottom-left of the screen and the size (2, 3) in pixels of the element.
    • get_ui_scale_factor

      public float get_ui_scale_factor()
      Description copied from interface: UiAPI
      Get the current scale factor applied to the UI.
      Specified by:
      get_ui_scale_factor in interface UiAPI
      Returns:
      The scale factor.
    • expand_pane

      public void expand_pane(String name)
      Description copied from interface: UiAPI
      Expand the UI pane with the given name. Possible names are:
      • Time
      • Camera
      • Visibility
      • VisualSettings
      • Datasets
      • Bookmarks
      • LocationLog

      Please, mind the case!

      Specified by:
      expand_pane in interface UiAPI
    • collapse_pane

      public void collapse_pane(String name)
      Description copied from interface: UiAPI
      Collapse the UI pane with the given name. Possible names are:
      • Time
      • Camera
      • Visibility
      • VisualSettings
      • Datasets
      • Bookmarks
      • LocationLog

      Please, mind the case!

      Specified by:
      collapse_pane in interface UiAPI
    • display_popup_notification

      public void display_popup_notification(String msg)
      Description copied from interface: UiAPI
      Display a popup notification on the screen with the given contents for the default duration of 8 seconds. The notification appears at the top-right of the screen and stays there until the duration time elapses, then it disappears.
      Specified by:
      display_popup_notification in interface UiAPI
      Parameters:
      msg - The notification text.
    • display_popup_notification

      public void display_popup_notification(String msg, float duration)
      Description copied from interface: UiAPI
      Display a popup notification on the screen for the given duration. The notification appears at the top-right of the screen and stays there until the duration time elapses, then it disappears.
      Specified by:
      display_popup_notification in interface UiAPI
      Parameters:
      msg - The notification text.
      duration - The duration, in seconds, until the notification automatically disappears. Set this to a negative number so that the notification never expires. If this is the case, the notification must be manually closed by the user.
    • display_popup_notification

      public void display_popup_notification(String message, Double duration)
    • set_headline_message

      public void set_headline_message(String msg)
      Description copied from interface: UiAPI
      Set the contents of the headline message. The headline message appears in the middle of the screen with a big font.
      Specified by:
      set_headline_message in interface UiAPI
      Parameters:
      msg - The headline text.
    • set_subhead_message

      public void set_subhead_message(String msg)
      Description copied from interface: UiAPI
      Set the contents of the sub-header message. The sub-header message appears just below the headline message, in the middle of the screen, with a somewhat smaller font.
      Specified by:
      set_subhead_message in interface UiAPI
      Parameters:
      msg - The sub-header text.
    • clear_headline_message

      public void clear_headline_message()
      Description copied from interface: UiAPI
      Clear the content of the headline message. After this method is called, the headline message disappears from screen.
      Specified by:
      clear_headline_message in interface UiAPI
    • clear_subhead_message

      public void clear_subhead_message()
      Description copied from interface: UiAPI
      Clear the content of the sub-header message. After this method is called, the sub-header message disappears from screen.
      Specified by:
      clear_subhead_message in interface UiAPI
    • clear_all_messages

      public void clear_all_messages()
      Description copied from interface: UiAPI
      Clear both the headline and the sub-header messages. After this method is called, both the headline and the sub-header messages disappear from screen.
      Specified by:
      clear_all_messages in interface UiAPI
    • set_crosshair_visibility

      public void set_crosshair_visibility(boolean visible)
      Description copied from interface: UiAPI
      Set the visibility of all crosshairs. Affects the visibility of the focus, closest, and home objects' crosshairs.
      Specified by:
      set_crosshair_visibility in interface UiAPI
      Parameters:
      visible - The visibility state, which applies to all cross-hairs.
    • set_focus_crosshair_visibility

      public void set_focus_crosshair_visibility(boolean visible)
      Description copied from interface: UiAPI
      Set the visibility of the focus object crosshair.
      Specified by:
      set_focus_crosshair_visibility in interface UiAPI
      Parameters:
      visible - The visibility state.
    • set_closest_crosshair_visibility

      public void set_closest_crosshair_visibility(boolean visible)
      Description copied from interface: UiAPI
      Set the visibility of the closest object crosshair.
      Specified by:
      set_closest_crosshair_visibility in interface UiAPI
      Parameters:
      visible - The visibility state.
    • set_home_crosshair_visibility

      public void set_home_crosshair_visibility(boolean visible)
      Description copied from interface: UiAPI
      Set the visibility of the home object crosshair.
      Specified by:
      set_home_crosshair_visibility in interface UiAPI
      Parameters:
      visible - The visibility state.
    • set_minimap_visibility

      public void set_minimap_visibility(boolean visible)
      Description copied from interface: UiAPI
      Set the visibility of the minimap.
      Specified by:
      set_minimap_visibility in interface UiAPI
      Parameters:
      visible - The visibility state.
    • preload_texture

      public void preload_texture(String path)
      Description copied from interface: UiAPI
      Preload the given image as a texture for later use. The texture will be cached for later use.
      Specified by:
      preload_texture in interface UiAPI
      Parameters:
      path - The path of the image file to preload as a string.
    • preload_textures

      public void preload_textures(String[] paths)
      Description copied from interface: UiAPI
      Preload the given image file paths as textures for later use. They will be cached for the subsequent uses.
      Specified by:
      preload_textures in interface UiAPI
      Parameters:
      paths - The texture paths as an array of strings.
    • reload

      public void reload()
      Description copied from interface: UiAPI
      Forces a re-initialization of the entire user interface of Gaia Sky. This causes all elements in the UI to be disposed and re-created.
      Specified by:
      reload in interface UiAPI