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
Modifier and TypeFieldDescriptionprotected FileArchive
protected List<DataArchive>
static String
static String
protected String
protected String[]
Deprecated, for removal: This API element is subject to removal in a future version.static String
protected String
static String
Deprecated, for removal: This API element is subject to removal in a future version.protected String
Deprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ModifierConstructorDescriptionprotected
DataArchive(String zipName)
DataArchive(String zipName, String imageDir)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtension(DataArchive ext)
DataArchives can extend other archives.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.protected void
buildLocalizedDirectoryList(List<String> list)
void
Deprecated, for removal: This API element is subject to removal in a future version.void
Deprecated, for removal: This API element is subject to removal in a future version.void
close()
boolean
protected Class<?>
static Image
Deprecated, for removal: This API element is subject to removal in a future version.static Image
Deprecated, for removal: This API element is subject to removal in a future version.UsegetImage(java.lang.String)
instead.getAllLocalImageNames(boolean localized, boolean fullPath)
protected void
getAllLocalImageNamesForDirectory(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.UseImageOp
s instead.static InputStream
getFileStream(File zip, String file)
Deprecated, for removal: This API element is subject to removal in a future version.UsegetFileStream(String)
instead.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(String fileName)
Deprecated, for removal: This API element is subject to removal in a future version.UsegetInputStream(String)
instead.static Image
getImage(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 Rectangle
getImageBounds(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 void
protected void
getImageNamesRecursively(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 anInputStream
for the given file in the archive.getName()
protected PermissionCollection
getPermissions(CodeSource codesource)
getScaledImage(Image base, double scale)
Deprecated, for removal: This API element is subject to removal in a future version.UseScaleOp
instead.getScaledImage(Image base, double scale, boolean reversed, boolean forceSmoothing)
Deprecated, for removal: This API element is subject to removal in a future version.UseScaleOp
instead.getTransformedImage(Image base, double scale, double theta)
Deprecated, for removal: This API element is subject to removal in a future version.UseRotateScaleOp
instead.getTransformedImage(Image base, double scale, double theta, boolean forceSmoothing)
Deprecated, for removal: This API element is subject to removal in a future version.UseRotateScaleOp
instead.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 boolean
Deprecated, for removal: This API element is subject to removal in a future version.protected void
Deprecated, for removal: This API element is subject to removal in a future version.UsegetImageNameSet()
)} instead.Class<?>
void
removeImageSource(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.void
unCacheImage(Image im)
Deprecated, for removal: This API element is subject to removal in a future version.void
unCacheImage(String file)
Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
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
-
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:
getName
in 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 anInputStream
for the given image file in the archive.- Parameters:
fileName
- the name of the image file- Returns:
- an
InputStream
which contains the image file - Throws:
IOException
- if there is a problem reading the image fileFileNotFoundException
- if the image file doesn't exist
-
getInputStream
Get anInputStream
for the given file in the archive.- Parameters:
fileName
- the name of the file- Returns:
- an
InputStream
which 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
getPermissions
- Overrides:
getPermissions
in classSecureClassLoader
-
findClass
- Overrides:
findClass
in 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 anImage
from the archive.- Parameters:
name
- the name of the image file- Returns:
- the
Image
contained 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.UseImageOp
s 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.UseRotateScaleOp
instead.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.UseRotateScaleOp
instead.- 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.UseScaleOp
instead. 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.UseScaleOp
instead.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 anInputStream
for 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.