Package megamek.client.ui.util
Class ImageAtlasMap
java.lang.Object
megamek.client.ui.util.ImageAtlasMap
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 Summary
ConstructorsConstructorDescriptionDefault constructor.ImageAtlasMap
(ImageAtlasRecords imgFileToAtlasMap) Constructor that takes an existing map. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Path key) Return true if the atlas map contains the given path, which is converted to UNIX-style path strings.Return the value for the given key, which is converted to a UNIX-style path string.void
Insert new values into the atlas map, using Paths which get converted to UNIX-style path strings.static ImageAtlasMap
Read the map from the image atlas map file.static ImageAtlasMap
readFromFile
(File filePath) Read the map from the provided file that should be an ImageAtlasMapFile.void
Write the map to the image atlas map file.void
writeToFile
(File pathToFile) Writes to a custom file for testing or custom paths.
-
Constructor Details
-
ImageAtlasMap
public ImageAtlasMap()Default constructor. -
ImageAtlasMap
Constructor that takes an existing map.- Parameters:
imgFileToAtlasMap
-
-
-
Method Details
-
put
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
Return the value for the given key, which is converted to a UNIX-style path string.- Parameters:
key
-- Returns:
-
containsKey
Return true if the atlas map contains the given path, which is converted to UNIX-style path strings.- Parameters:
key
-- Returns:
-
writeToFile
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
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
Read the map from the image atlas map file.- Returns:
-