Class ImageAtlasMap

java.lang.Object
megamek.client.ui.util.ImageAtlasMap

public class ImageAtlasMap extends Object
Class to encapsulate a map that maps old image paths to the subsequent location in an image atlas. This allows us to keep the old MekSets while still packaging the images into an atlas. There's a potential cross-platform path issue as the Java File class uses the current system's file system to do file comparisons. If we write windows-style path strings to a file and read that in with UNIX, it can cause comparisons to fail. Because of this, the internal map is stored with file paths represented as strings, but they are passed in as paths which then are explicitly converted to UNIX-style file paths.
  • Constructor Details

    • ImageAtlasMap

      public ImageAtlasMap()
      Default constructor.
    • ImageAtlasMap

      public ImageAtlasMap(ImageAtlasRecords imgFileToAtlasMap)
      Constructor that takes an existing map.
      Parameters:
      imgFileToAtlasMap -
  • Method Details

    • put

      public void put(Path originalFilePath, Path atlasFilePath)
      Insert new values into the atlas map, using Paths which get converted to UNIX-style path strings.
      Parameters:
      originalFilePath - The file path on the file system during build.
      atlasFilePath - Which file it is in for the atlas.
    • get

      public String get(Path key)
      Return the value for the given key, which is converted to a UNIX-style path string.
      Parameters:
      key -
      Returns:
    • containsKey

      public boolean containsKey(Path key)
      Return true if the atlas map contains the given path, which is converted to UNIX-style path strings.
      Parameters:
      key -
      Returns:
    • writeToFile

      public void writeToFile(File pathToFile)
      Writes to a custom file for testing or custom paths.
      Parameters:
      pathToFile - Path to write to. Primarily used for testing but can be utilized elsewhere
    • writeToFile

      public void writeToFile()
      Write the map to the image atlas map file.
    • readFromFile

      @Nullable public static ImageAtlasMap readFromFile(File filePath)
      Read the map from the provided file that should be an ImageAtlasMapFile.
      Parameters:
      filePath - File to read from. Primarily used for testing but can be utilized elsewhere
      Returns:
    • readFromFile

      @Nullable public static ImageAtlasMap readFromFile()
      Read the map from the image atlas map file.
      Returns: