Package VASSAL.tools
Class DataArchive
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
VASSAL.tools.DataArchive
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
ArchiveWriter,JarArchive
Wrapper around a Zip archive with methods to cache images
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileArchiveprotected List<DataArchive>static Stringstatic Stringprotected Stringprotected String[]Deprecated, for removal: This API element is subject to removal in a future version.static Stringprotected Stringstatic StringDeprecated, for removal: This API element is subject to removal in a future version.protected StringDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataArchive(String zipName)DataArchive(String zipName, String imageDir) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtension(DataArchive ext)DataArchives can extend other archives.booleanaddImageSource(String name, org.apache.xmlgraphics.image.loader.ImageSource src)Deprecated, for removal: This API element is subject to removal in a future version.protected voidbuildLocalizedDirectoryList(List<String> list)voidDeprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.voidclose()booleanprotected Class<?>static ImageDeprecated, for removal: This API element is subject to removal in a future version.static ImageDeprecated, for removal: This API element is subject to removal in a future version.UsegetImage(java.lang.String)instead.getAllLocalImageNames(boolean localized, boolean fullPath)protected voidgetAllLocalImageNamesForDirectory(SortedSet<String> s, String directory, boolean fullPath)Deprecated, for removal: This API element is subject to removal in a future version.UsegetURL()instead.static byte[]getBytes(InputStream in)Deprecated, for removal: This API element is subject to removal in a future version.UseInputStream.readAllBytes()instead.getCachedAudioClip(String name)getCachedImage(String name)Deprecated, for removal: This API element is subject to removal in a future version.UseImageOps instead.static InputStreamgetFileStream(File zip, String file)Deprecated, for removal: This API element is subject to removal in a future version.UsegetFileStream(String)instead.static InputStreamgetFileStream(File dir, String zipName, String file)Deprecated, for removal: This API element is subject to removal in a future version.UsegetFileStream(String)instead.getFileStream(String fileName)Deprecated, for removal: This API element is subject to removal in a future version.UsegetInputStream(String)instead.static ImagegetImage(InputStream in)Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.static RectanglegetImageBounds(Image im)Deprecated, for removal: This API element is subject to removal in a future version.UseImageUtils.getBounds(BufferedImage)instead.getImageInputStream(String fileName)Deprecated, for removal: This API element is subject to removal in a future version.UsegetInputStream(String)instead.String[]getImageNameSet(boolean localized, boolean fullPath)protected voidprotected voidgetImageNamesRecursively(SortedSet<String> s, boolean localized, boolean fullPath)getImageSize(String name)Deprecated, for removal: This API element is subject to removal in a future version.getImageURL(String fileName)Deprecated, for removal: This API element is subject to removal in a future version.UsegetURL(String)instead.getInputStream(String fileName)Get anInputStreamfor the given file in the archive.getName()protected PermissionCollectiongetPermissions(CodeSource codesource)getScaledImage(Image base, double scale)Deprecated, for removal: This API element is subject to removal in a future version.UseScaleOpinstead.getScaledImage(Image base, double scale, boolean reversed, boolean forceSmoothing)Deprecated, for removal: This API element is subject to removal in a future version.UseScaleOpinstead.getTransformedImage(Image base, double scale, double theta)Deprecated, for removal: This API element is subject to removal in a future version.UseRotateScaleOpinstead.getTransformedImage(Image base, double scale, double theta, boolean forceSmoothing)Deprecated, for removal: This API element is subject to removal in a future version.UseRotateScaleOpinstead.getURL()Returns a URL pointing to the archive.Returns a URL pointing to the named file.Return the writeable instance of DataArchive, either this or one of its extensions.improvedScaling(Image img, int width, int height)Deprecated, for removal: This API element is subject to removal in a future version.Don't use this.protected booleanDeprecated, for removal: This API element is subject to removal in a future version.protected voidDeprecated, for removal: This API element is subject to removal in a future version.UsegetImageNameSet())} instead.Class<?>voidremoveImageSource(String name)Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.UsegetImageNameSet()instead.voidunCacheImage(Image im)Deprecated, for removal: This API element is subject to removal in a future version.voidunCacheImage(String file)Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
archive
-
extensions
-
localImages
-
cachedLocalImages
-
IMAGE_DIR
- See Also:
- Constant Field Values
-
imageDir
-
SOUND_DIR
- See Also:
- Constant Field Values
-
soundDir
-
ICON_DIR
- See Also:
- Constant Field Values
-
SOUNDS_DIR
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
soundsDir
Deprecated, for removal: This API element is subject to removal in a future version. -
imageNames
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
DataArchive
protected DataArchive() -
DataArchive
- Throws:
IOException
-
DataArchive
- Throws:
IOException
-
-
Method Details
-
getName
- Overrides:
getNamein classClassLoader
-
getArchive
-
getImagePrefix
-
getCachedAudioClip
- Throws:
IOException
-
getImageInputStream
@Deprecated(since="2020-08-06", forRemoval=true) public InputStream getImageInputStream(String fileName) throws IOException, FileNotFoundExceptionDeprecated, for removal: This API element is subject to removal in a future version.UsegetInputStream(String)instead.Get anInputStreamfor the given image file in the archive.- Parameters:
fileName- the name of the image file- Returns:
- an
InputStreamwhich contains the image file - Throws:
IOException- if there is a problem reading the image fileFileNotFoundException- if the image file doesn't exist
-
getInputStream
Get anInputStreamfor the given file in the archive.- Parameters:
fileName- the name of the file- Returns:
- an
InputStreamwhich contains the file - Throws:
IOException- if there is a problem reading the fileFileNotFoundException- if the file doesn't exist
-
getURL
Returns a URL pointing to the archive.- Returns:
- a URL corresponding to this archive
- Throws:
IOException- if the archive has not yet been saved
-
getURL
Returns a URL pointing to the named file.- Parameters:
fileName- the name of the file- Returns:
- a URL corresponding to the file
- Throws:
FileNotFoundException- if the file doesn't existIOException- if some other problem occurs
-
getImageURL
@Deprecated(since="2020-08-06", forRemoval=true) public URL getImageURL(String fileName) throws IOException, FileNotFoundExceptionDeprecated, for removal: This API element is subject to removal in a future version.UsegetURL(String)instead.Returns a URL pointing to the named image file.- Parameters:
fileName- the name of the image file- Returns:
- a URL corresponding to the image file
- Throws:
FileNotFoundException- if the file doesn't existIOException- if some other problem occurs
-
contains
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getImageNames
-
getImageNameSet
-
getImageNameSet
-
getImageNamesRecursively
-
getImageNamesRecursively
-
getLocalImageNames
-
buildLocalizedDirectoryList
-
getAllLocalImageNamesForDirectory
-
getAllLocalImageNames
-
addExtension
DataArchives can extend other archives. The extensions will be searched for data if not found in the parent archive.- Parameters:
ext- the extension
-
getWriter
Return the writeable instance of DataArchive, either this or one of its extensions. (At most one archive should be edited at a time.)- Returns:
- writer
-
loadClass
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
getPermissions
- Overrides:
getPermissionsin classSecureClassLoader
-
findClass
- Overrides:
findClassin classClassLoader- Throws:
ClassNotFoundException
-
addImageSource
@Deprecated(since="2020-08-06", forRemoval=true) public boolean addImageSource(String name, org.apache.xmlgraphics.image.loader.ImageSource src)Deprecated, for removal: This API element is subject to removal in a future version.Add an ImageSource under the given name, but only if no source is yet registered under this name.- Parameters:
name- namesrc- source- Returns:
- true if the ImageSource was added, false if it existed already
-
removeImageSource
Deprecated, for removal: This API element is subject to removal in a future version. -
getImageSize
@Deprecated(since="2020-08-06", forRemoval=true) public Dimension getImageSize(String name) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.Get the size of an image without loading and decoding it.- Parameters:
name- filename of the image- Returns:
- the size of the image
- Throws:
IOException
-
getImage
@Deprecated(since="2020-08-06", forRemoval=true) public BufferedImage getImage(String name) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.Returns anImagefrom the archive.- Parameters:
name- the name of the image file- Returns:
- the
Imagecontained in the image file - Throws:
IOException- if there is a problem reading the image file
-
isNameCacheStale
Deprecated, for removal: This API element is subject to removal in a future version. -
setOfImageNames
Deprecated, for removal: This API element is subject to removal in a future version.UsegetImageNameSet()instead.- Returns:
- the names of the image files stored in this DataArchive and its extensions
-
unCacheImage
Deprecated, for removal: This API element is subject to removal in a future version. -
unCacheImage
Deprecated, for removal: This API element is subject to removal in a future version. -
clearTransformedImageCache
Deprecated, for removal: This API element is subject to removal in a future version. -
clearScaledImageCache
Deprecated, for removal: This API element is subject to removal in a future version. -
getCachedImage
Deprecated, for removal: This API element is subject to removal in a future version.UseImageOps instead.Find an image from the archive Once an image is found, cache it in our HashMap. -
getTransformedImage
@Deprecated(since="2020-08-06", forRemoval=true) public Image getTransformedImage(Image base, double scale, double theta)Deprecated, for removal: This API element is subject to removal in a future version.UseRotateScaleOpinstead.Return a transformed instance of the image. The image will be retrieved from the cache if available, and cached after retrieval if not.- Parameters:
base- the untransformed Imagescale- the scaling factortheta- the angle of rotation (in degrees) about the Image center
-
getTransformedImage
@Deprecated(since="2020-08-06", forRemoval=true) public Image getTransformedImage(Image base, double scale, double theta, boolean forceSmoothing)Deprecated, for removal: This API element is subject to removal in a future version.UseRotateScaleOpinstead.- Parameters:
base- basescale- scaletheta- thetaforceSmoothing- forceSmoothing- Returns:
- transformed image
-
getScaledImage
@Deprecated(since="2020-08-06", forRemoval=true) public Image getScaledImage(Image base, double scale, boolean reversed, boolean forceSmoothing)Deprecated, for removal: This API element is subject to removal in a future version.UseScaleOpinstead. The image will be retrieved from cache if available, cached otherwise- Parameters:
base- basescale- scalereversed- reversedforceSmoothing- If true, force smoothing. This usually yields better results, but can be slow for large images- Returns:
- Scaled image
-
getScaledImage
@Deprecated(since="2020-08-06", forRemoval=true) public Image getScaledImage(Image base, double scale)Deprecated, for removal: This API element is subject to removal in a future version.UseScaleOpinstead.Return a scaled instance of the image. The image will be retrieved from cache if available, cached otherwise- Parameters:
base- basescale- scale- Returns:
- Scaled image
-
findImage
@Deprecated(since="2020-08-06", forRemoval=true) public static Image findImage(File zip, String file) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.UsegetImage(java.lang.String)instead.- Throws:
IOException
-
findImage
@Deprecated(since="2020-08-06", forRemoval=true) public static Image findImage(File dir, String zip, String file) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.UsegetImage(java.lang.String)instead.- Throws:
IOException
-
getFileStream
@Deprecated(since="2020-08-06", forRemoval=true) public static InputStream getFileStream(File zip, String file) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.UsegetFileStream(String)instead.- Throws:
IOException
-
getFileStream
@Deprecated(since="2020-08-06", forRemoval=true) public static InputStream getFileStream(File dir, String zipName, String file)Deprecated, for removal: This API element is subject to removal in a future version.UsegetFileStream(String)instead. -
getFileStream
@Deprecated(since="2020-08-06", forRemoval=true) public InputStream getFileStream(String fileName) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.UsegetInputStream(String)instead.Get anInputStreamfor the given filename in the archive.- Throws:
IOException
-
getImage
@Deprecated(since="2020-08-06", forRemoval=true) public static Image getImage(InputStream in) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.UseImageUtils.getImage(String, InputStream)instead.- Throws:
IOException
-
getArchiveURL
Deprecated, for removal: This API element is subject to removal in a future version.UsegetURL()instead. -
getBytes
@Deprecated(since="2020-08-06", forRemoval=true) public static byte[] getBytes(InputStream in) throws IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.UseInputStream.readAllBytes()instead.Read all available bytes from the given InputStream.- Throws:
IOException
-
listImageNames
Deprecated, for removal: This API element is subject to removal in a future version.UsegetImageNameSet())} instead.Place the names of the image files stored in this DataArchive into the argument Collection- Parameters:
l- l
-
getImageBounds
Deprecated, for removal: This API element is subject to removal in a future version.UseImageUtils.getBounds(BufferedImage)instead.- Parameters:
im- image- Returns:
- the boundaries of this image, where (0,0) is the center of the image
-
improvedScaling
@Deprecated(since="2020-08-06", forRemoval=true) public Image improvedScaling(Image img, int width, int height)Deprecated, for removal: This API element is subject to removal in a future version.Don't use this. We've switched to Lanczos scaling.
-
getImage(java.lang.String)instead.