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
public class DataArchive extends SecureClassLoader implements Closeable
Wrapper around a Zip archive with methods to cache images
-
Field Summary
Fields Modifier and Type Field Description protected FileArchivearchiveprotected List<DataArchive>extensionsstatic StringICON_DIRstatic StringIMAGE_DIRprotected StringimageDirprotected String[]imageNamesDeprecated.protected SortedSet<String>localImagesstatic StringSOUND_DIRprotected StringsoundDirstatic StringSOUNDS_DIRDeprecated.protected StringsoundsDirDeprecated. -
Constructor Summary
Constructors Modifier Constructor Description protectedDataArchive()DataArchive(String zipName)DataArchive(String zipName, String imageDir) -
Method Summary
Modifier and Type Method Description voidaddExtension(DataArchive ext)DataArchives can extend other archives.voidclearScaledImageCache()Deprecated.voidclearTransformedImageCache()Deprecated.voidclose()booleancontains(String fileName)protected Class<?>findClass(String name)static ImagefindImage(File zip, String file)Deprecated.UsegetImage(java.lang.String)instead.static ImagefindImage(File dir, String zip, String file)Deprecated.UsegetImage(java.lang.String)instead.FileArchivegetArchive()StringgetArchiveURL()Deprecated.UsegetURL()instead.static byte[]getBytes(InputStream in)Deprecated.Use {@link IOUtils.toBytesArray(InputStream)} instead.AudioClipgetCachedAudioClip(String name)ImagegetCachedImage(String name)Deprecated.UseImageOps instead.static InputStreamgetFileStream(File zip, String file)Deprecated.UsegetFileStream(String)instead.static InputStreamgetFileStream(File dir, String zipName, String file)Deprecated.UsegetFileStream(String)instead.InputStreamgetFileStream(String fileName)Deprecated.UsegetInputStream(String)instead.static ImagegetImage(InputStream in)Deprecated.BufferedImagegetImage(String name)Deprecated.UseImageUtils.getImageorSVGImageUtils.getImageinstead.static RectanglegetImageBounds(Image im)Deprecated.Use {@link ImageUtils.getBounds(BufferedImage)} instead.InputStreamgetImageInputStream(String fileName)Deprecated.UsegetInputStream(String)instead.String[]getImageNames()SortedSet<String>getImageNameSet()protected voidgetImageNamesRecursively(SortedSet<String> s)StringgetImagePrefix()DimensiongetImageSize(String name)Deprecated.UseImageUtils.getImageSizeorSVGImageUtils.getImageSizeinstead.URLgetImageURL(String fileName)Deprecated.UsegetURL(String)instead.InputStreamgetInputStream(String fileName)Get anInputStreamfor the given file in the archive.protected SortedSet<String>getLocalImageNames()StringgetName()protected PermissionCollectiongetPermissions(CodeSource codesource)ImagegetScaledImage(Image base, double scale)Deprecated.UseScaleOpinstead.ImagegetScaledImage(Image base, double scale, boolean reversed, boolean forceSmoothing)Deprecated.UseScaleOpinstead.ImagegetTransformedImage(Image base, double scale, double theta)Deprecated.UseRotateScaleOpinstead.ImagegetTransformedImage(Image base, double scale, double theta, boolean forceSmoothing)Deprecated.UseRotateScaleOpinstead.URLgetURL()Returns a URL pointing to the archive.URLgetURL(String fileName)Returns a URL pointing to the named file.ArchiveWritergetWriter()Return the writeable instance of DataArchive, either this or one of its extensions.ImageimprovedScaling(Image img, int width, int height)Deprecated.Don't use this.protected booleanisNameCacheStale()Deprecated.protected voidlistImageNames(Collection l)Deprecated.Use#listImageNames()instead.Class<?>loadClass(String name, boolean resolve)protected SortedSet<String>setOfImageNames()Deprecated.UsegetImageNameSet()instead.voidunCacheImage(Image im)Deprecated.voidunCacheImage(String file)Deprecated.Methods 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
-
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.- See Also:
- Constant Field Values
-
soundsDir
Deprecated. -
imageNames
Deprecated.
-
-
Constructor Details
-
DataArchive
protected DataArchive() -
DataArchive
- Throws:
IOException
-
DataArchive
- Throws:
IOException
-
-
Method Details
-
getName
- Overrides:
getNamein classClassLoader
-
getArchive
-
getImagePrefix
-
getCachedAudioClip
- Throws:
IOException
-
getImageInputStream
@Deprecated public InputStream getImageInputStream(String fileName) throws IOException, FileNotFoundExceptionDeprecated.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.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
-
getImageNamesRecursively
-
getLocalImageNames
-
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:
-
loadClass
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
getPermissions
- Overrides:
getPermissionsin classSecureClassLoader
-
findClass
- Overrides:
findClassin classClassLoader- Throws:
ClassNotFoundException
-
getImageSize
Deprecated.UseImageUtils.getImageSizeorSVGImageUtils.getImageSizeinstead.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.UseImageUtils.getImageorSVGImageUtils.getImageinstead.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. -
setOfImageNames
Deprecated.UsegetImageNameSet()instead.- Returns:
- the names of the image files stored in this DataArchive and its extensions
-
unCacheImage
Deprecated. -
unCacheImage
Deprecated. -
clearTransformedImageCache
Deprecated. -
clearScaledImageCache
Deprecated. -
getCachedImage
Deprecated.UseImageOps instead.Find an image from the archive Once an image is found, cache it in our HashMap.- Throws:
IOException
-
getTransformedImage
Deprecated.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 public Image getTransformedImage(Image base, double scale, double theta, boolean forceSmoothing)Deprecated.UseRotateScaleOpinstead.- Parameters:
base-scale-theta-forceSmoothing-- Returns:
-
getScaledImage
@Deprecated public Image getScaledImage(Image base, double scale, boolean reversed, boolean forceSmoothing)Deprecated.UseScaleOpinstead. The image will be retrieved from cache if available, cached otherwise- Parameters:
base-scale-reversed-forceSmoothing- If true, force smoothing. This usually yields better results, but can be slow for large images- Returns:
-
getScaledImage
Deprecated.UseScaleOpinstead.Return a scaled instance of the image. The image will be retrieved from cache if available, cached otherwise- Parameters:
base-scale-- Returns:
-
findImage
Deprecated.UsegetImage(java.lang.String)instead.- Throws:
IOException
-
findImage
Deprecated.UsegetImage(java.lang.String)instead.- Throws:
IOException
-
getFileStream
Deprecated.UsegetFileStream(String)instead.- Throws:
IOException
-
getFileStream
Deprecated.UsegetFileStream(String)instead. -
getFileStream
Deprecated.UsegetInputStream(String)instead.Get anInputStreamfor the given filename in the archive.- Throws:
IOException
-
getImage
Deprecated.Use {@link ImageUtils.getImage(InputStream)} instead.- Throws:
IOException
-
getArchiveURL
Deprecated.UsegetURL()instead. -
getBytes
Deprecated.Use {@link IOUtils.toBytesArray(InputStream)} instead.Read all available bytes from the given InputStream.- Throws:
IOException
-
listImageNames
Deprecated.Use#listImageNames()instead.Place the names of the image files stored in this DataArchive into the argument Collection- Parameters:
l-
-
getImageBounds
Deprecated.Use {@link ImageUtils.getBounds(BufferedImage)} instead.- Parameters:
im-- Returns:
- the boundaries of this image, where (0,0) is the center of the image
-
improvedScaling
Deprecated.Don't use this. We've switched to Lanczos scaling.
-