Package edu.wisc.game.sql
Class ImageObject
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,String>
-
- edu.wisc.game.sql.ImageObject
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,String>
- Direct Known Subclasses:
Composite
public class ImageObject extends HashMap<String,String>
Describes an image-and-properties-based object. For details, see Image-and-property-based description of objects- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImageObject.Generator
An image generator is an object that can be used to obtain a random IPB object.static class
ImageObject.PickFromList
A Generator interface to a stored list of ImageObjects, from which they can be retrieved at random.-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ImageObject()
Used by Composite
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clearTable()
void
enlist()
Enters this ImageObject into the master tableString
getKey()
String
getSvg()
The SVG code for the image, if available.String
listProperties()
String
listProperties(String sep)
Produces a "key1:val1, key2:val2, ..." list, with a desired separator.static ImageObject
obtainImageObjectPlain(File f)
static ImageObject
obtainImageObjectPlain(File f, boolean allowMissing)
static ImageObject
obtainImageObjectPlain(File dir, String plainPath, boolean allowMissing)
Retrieves the ImageObject for a specified path (no wildcards!) from the master table.static Vector<ImageObject>
obtainImageObjects(String wildCardPath)
Loads an image object (or a group of them, if a wildcard is given).String
symbol()
For use in ASCII graphics-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Method Detail
-
getKey
public String getKey()
-
getSvg
public String getSvg()
The SVG code for the image, if available. It is mandatory for dynamically generated ImageObjects (/composite). For static ones, it may or may not be null.
-
clearTable
public static void clearTable()
-
enlist
public void enlist()
Enters this ImageObject into the master table
-
obtainImageObjectPlain
public static ImageObject obtainImageObjectPlain(File dir, String plainPath, boolean allowMissing)
Retrieves the ImageObject for a specified path (no wildcards!) from the master table. If necessary, tries to add that object (and all other objects listed in the properties file in that directory) to the master table.- Parameters:
dir
- If provided, plainPath is understood as being relative to it.plainPath
- The image path (relative to dir, or absolute if dir==null). Must not contain wildcards. May contain an extension (e.g. ".png" or ".svg"); if it does not, ".svg" will be added.
-
obtainImageObjectPlain
public static ImageObject obtainImageObjectPlain(File f)
-
obtainImageObjectPlain
public static ImageObject obtainImageObjectPlain(File f, boolean allowMissing)
- Parameters:
allowMissing
- If true, simply return null, rather than throw exception, when the file is not listed in the prop file
-
obtainImageObjects
public static Vector<ImageObject> obtainImageObjects(String wildCardPath)
Loads an image object (or a group of them, if a wildcard is given).- Parameters:
path
- One of the values from the "images" column of ParaSet. It is either a path (maybe with wildcards) relative to game-data/shapes, or a /composite/... string refering to a dynamically generated Composite ImageObject (or a group of them).- Returns:
- a Vector of "regular" ImageObjects (associated with the file(s) given by the wildCardPath), or a Composite ImageObject (maybe a "family" one) is the path is of that kind.
-
listProperties
public String listProperties()
-
listProperties
public String listProperties(String sep)
Produces a "key1:val1, key2:val2, ..." list, with a desired separator.
-
symbol
public String symbol()
For use in ASCII graphics
-
-