Package jme3utilities
Class Heart
java.lang.Object
jme3utilities.Heart
Miscellaneous utility methods in the Heart Library. All methods should be
static.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTest whether assertions are enabled.static booleanOpen the specified web page in a new browser or browser tab.static <T> TdeepCopy(T object) Copy the specified object using deepClone() if it's cloneable.static voiddeleteStoredSettings(String applicationName) Delete the application's stored settings, if any.static <T extends com.jme3.app.state.AppState>
voidDetach all app states which are subclasses of a specified class.driveMap()Construct a map from drive paths (roots) to file objects.static <T> Tfirst(Collection<T> collection) Access the first member of a collection.static StringCanonicalize a file's path and convert backslashes to slashes.static StringCanonicalize a file path and convert backslashes to slashes.static FileHandlerAccess the pre-existing FileHandler for logging, or if none is found, create one and use that.static com.jme3.post.FilterPostProcessorgetFpp(com.jme3.renderer.ViewPort viewPort, com.jme3.asset.AssetManager assetManager, int numSamples) Access the pre-existing FilterPostProcessor of the specified view port, or if it has none, add a new FPP and use that.static com.jme3.input.KeyInputgetKeyInput(com.jme3.input.InputManager inputManager) Access the keyboard interface of the specified InputManager.static booleanhasStoredSettings(String applicationName) Test whether the named application has stored settings.static StringGenerate a canonical filesystem path to the named file in the user's home directory.listZipEntries(String zipPath, String namePrefix) Enumerate all entries (in the specified JAR or ZIP) whose names begin with the specified prefix.static StringloadResourceAsString(String resourceName) Load UTF-8 text from the named resource.static voidparseAppArgs(com.jme3.app.SimpleApplication application, String... arguments) Parse some conventional command-line arguments and apply them to the specified SimpleApplication.static voidsetGrayPixel(Graphics2D graphics, int x, int y, float brightness, float opacity) Set the specified pixel to the specified brightness and opacity.static voidsetLoggingLevels(Level newLevel) Alter the logging levels of all known loggers.static Stringversion()Read the verbose version string for this library.static StringReturn the terse version string for this library.static voidwriteImage(String filePath, RenderedImage image) Write an image to a file, attempting to overwrite any pre-existing file.static voidWrite a Savable to a J3O file.
-
Method Details
-
areAssertionsEnabled
public static boolean areAssertionsEnabled()Test whether assertions are enabled.- Returns:
- true if enabled, otherwise false
-
browseWeb
Open the specified web page in a new browser or browser tab.- Parameters:
startUriString- URI of the web page (not null)- Returns:
- true if successful, otherwise false
-
deepCopy
public static <T> T deepCopy(T object) Copy the specified object using deepClone() if it's cloneable. This works around JME issue #879, but still doesn't handle all classes.- Type Parameters:
T- the type of object to be copied- Parameters:
object- the input (unaffected)- Returns:
- an instance equivalent to the input
-
deleteStoredSettings
Delete the application's stored settings, if any.- Parameters:
applicationName- the name of the application
-
detachAll
public static <T extends com.jme3.app.state.AppState> void detachAll(com.jme3.app.state.AppStateManager stateManager, Class<T> whichClass) Detach all app states which are subclasses of a specified class.- Type Parameters:
T- class to scan for- Parameters:
stateManager- (not null)whichClass- (not null)
-
driveMap
Construct a map from drive paths (roots) to file objects.- Returns:
- a new map from canonical file-system paths to files
-
first
Access the first member of a collection.- Type Parameters:
T- the type of the member- Parameters:
collection- the collection to access (not null)- Returns:
- the pre-existing member, or null if none
-
fixedPath
Canonicalize a file's path and convert backslashes to slashes.- Parameters:
inputFile- the input file (not null, not empty)- Returns:
- the fixed file path (not null, not empty)
-
fixPath
Canonicalize a file path and convert backslashes to slashes.- Parameters:
inputPath- the file path to fix (not null, not empty)- Returns:
- the fixed file path (not null, not empty)
-
getFileHandler
Access the pre-existing FileHandler for logging, or if none is found, create one and use that.- Returns:
- not null
-
getFpp
public static com.jme3.post.FilterPostProcessor getFpp(com.jme3.renderer.ViewPort viewPort, com.jme3.asset.AssetManager assetManager, int numSamples) Access the pre-existing FilterPostProcessor of the specified view port, or if it has none, add a new FPP and use that.- Parameters:
viewPort- which view port (not null)assetManager- (not null)numSamples- number of samples for anti-aliasing (≥1, ≤16) or 0 for the FPP default- Returns:
- not null
-
getKeyInput
public static com.jme3.input.KeyInput getKeyInput(com.jme3.input.InputManager inputManager) Access the keyboard interface of the specified InputManager.- Parameters:
inputManager- the InputManager to access (not null, unaffected)- Returns:
- the pre-existing instance
-
hasStoredSettings
Test whether the named application has stored settings.- Parameters:
applicationName- the name of the application- Returns:
- true if it has stored settings, otherwise false
-
homePath
Generate a canonical filesystem path to the named file in the user's home directory.- Parameters:
fileName- file name to use (not null, not empty)- Returns:
- the file-system path (not null, not empty)
-
listZipEntries
Enumerate all entries (in the specified JAR or ZIP) whose names begin with the specified prefix.- Parameters:
zipPath- filesystem path to the JAR or ZIP (not null, not empty)namePrefix- (not null)- Returns:
- a new list of entry names
-
loadResourceAsString
Load UTF-8 text from the named resource.- Parameters:
resourceName- the name of the classpath resource to load (not null)- Returns:
- the text (possibly multiple lines)
-
parseAppArgs
Parse some conventional command-line arguments and apply them to the specified SimpleApplication.- Parameters:
application- the application to modify (not null)arguments- array of command-line arguments (not null)
-
setGrayPixel
Set the specified pixel to the specified brightness and opacity.- Parameters:
graphics- rendering context of the pixel (not null)x- pixel's first coordinate (<width, ≥0)y- pixel's 2nd coordinate (<height, ≥0)brightness- (≤1, ≥0, 0 → black, 1 → white)opacity- (≤1, ≥0, 0 → transparent, 1 → opaque)
-
setLoggingLevels
Alter the logging levels of all known loggers.- Parameters:
newLevel- the desired level (not null)- See Also:
-
version
Read the verbose version string for this library.- Returns:
- project name, library name, branch, and revision
-
versionShort
Return the terse version string for this library.- Returns:
- the branch name and revision string (not null, not empty)
-
writeImage
Write an image to a file, attempting to overwrite any pre-existing file.- Parameters:
filePath- the path to the output file (not null, not empty)image- the image to be written (not null)- Throws:
IOException- if the file cannot be written
-
writeJ3O
Write a Savable to a J3O file.- Parameters:
filePath- (not null, not empty, should end in ".j3o")savable- (not null, unaffected)
-