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 the specified image to the specified file, attempting to overwrite any pre-existing file.static voidWrite the specified Savable to the specified J3O file.
-
Method Details
-
areAssertionsEnabled
public static boolean areAssertionsEnabled()Test whether assertions are enabled.- Returns:
trueif enabled, otherwisefalse
-
browseWeb
Open the specified web page in a new browser or browser tab.- Parameters:
startUriString- URI of the web page (notnull)- Returns:
trueif successful, otherwisefalse
-
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- (notnull)whichClass- (notnull)
-
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 (notnull)- Returns:
- the pre-existing member, or
nullif none
-
fixedPath
Canonicalize a file's path and convert backslashes to slashes.- Parameters:
inputFile- the input file (notnull, 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 (notnull, 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 (notnull)assetManager- (notnull)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 (notnull, unaffected)- Returns:
- the pre-existing instance
-
hasStoredSettings
Test whether the named application has stored settings.- Parameters:
applicationName- the name of the application- Returns:
trueif it has stored settings, otherwisefalse
-
homePath
Generate a canonical filesystem path to the named file in the user's home directory.- Parameters:
fileName- file name to use (notnull, 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 (notnull, not empty)namePrefix- (notnull)- 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 (notnull)- 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 (notnull)arguments- array of command-line arguments (notnull)
-
setGrayPixel
Set the specified pixel to the specified brightness and opacity.- Parameters:
graphics- rendering context of the pixel (notnull)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 (notnull)- 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 the specified image to the specified file, attempting to overwrite any pre-existing file.- Parameters:
filePath- the path to the output file (notnull, not empty)image- the image to be written (notnull)- Throws:
IOException- if the file cannot be written
-
writeJ3O
Write the specified Savable to the specified J3O file.- Parameters:
filePath- (notnull, not empty, should end in ".j3o")savable- (notnull, unaffected)
-