Class TacticalSymbolResourceFactory

java.lang.Object
de.turnertech.tz.symbol.TacticalSymbolResourceFactory

public class TacticalSymbolResourceFactory extends Object

A static factory class for creating and accessing the tactical symbols provided in this module via a programmer friendly method.

Make sure to call initialise() early in your application startup to get the most expensive part of starting up out of the way. This triggers the reading of the index file and will create an ArrayList of TacticalSymbol with instances for every symbol. If not explicitely called, it will be called on the first attempt to access the symbols. This may cause a slight stutter in your application, as on my machine the initialisation takes over 100ms

Since:
1.2
  • Field Details

    • LOGGER_NAME

      public static final String LOGGER_NAME
      We use java.util logging. This is the name of the logger we are using.
      Since:
      1.1
      See Also:
  • Method Details

    • initialise

      public static boolean initialise()

      Reads the index file and populates an internal storage of TacticalSymbolResource instances. Note, that thes instances do not have the images in memory, only URLs to the assets so that you can easily load them using your system of choice.

      Returns:
      if the initialisation was successfull or not.
      Since:
      1.2
    • reset

      public static void reset()

      Resets the cache back to a default state. After calling clear, a subsequent call to isInitialised() will return false.

      Since:
      1.2
    • isInitialised

      public static boolean isInitialised()
      Simple check to see if the internal storage has been initialised.
      Returns:
      if the symbols instances have been prepared.
      Since:
      1.2
    • getTacticalSymbols

      public static Collection<TacticalSymbolResource> getTacticalSymbols(TacticalSymbolTag... tags)

      A search mechanism using "AND" logic to retrieve all TacticalSymbolResources with all of the desired TacticalSymbolTags

      Parameters:
      tags - The TacticalSymbolTags to be used to search for the symbols
      Returns:
      A collection of symbols matching all tags
      Since:
      1.2
    • getTacticalSymbols

      public static Collection<TacticalSymbolResource> getTacticalSymbols()
      Simply returns the internal storage wrapped in an unmodifiable list.
      Returns:
      All of the loaded TacticalSymbolResources
      Since:
      1.2