Package gaia.cu9.ari.gaiaorbit.util
Class GlobalResources
- java.lang.Object
-
- gaia.cu9.ari.gaiaorbit.util.GlobalResources
-
public class GlobalResources extends java.lang.ObjectHolds and initialises resources utilised globally.
-
-
Field Summary
Fields Modifier and Type Field Description static ExtSpriteBatchextSpriteBatchSprite batch using int indicesstatic ExtShaderProgramextSpriteShaderstatic float[]gBluestatic com.badlogic.gdx.graphics.ColorgBlueCstatic float[]gGreenGOOGLE COLORSstatic com.badlogic.gdx.graphics.ColorgGreenCstatic float[]gPinkstatic com.badlogic.gdx.graphics.ColorgPinkCstatic float[]gRedstatic com.badlogic.gdx.graphics.ColorgRedCstatic float[]gWhitestatic com.badlogic.gdx.graphics.ColorgWhiteCstatic float[]gYellowstatic com.badlogic.gdx.graphics.ColorgYellowCstatic com.badlogic.gdx.graphics.CursorlinkCursorCursorsstatic com.badlogic.gdx.graphics.CursorresizeXCursorCursorsstatic com.badlogic.gdx.graphics.CursorresizeYCursorCursorsstatic com.badlogic.gdx.scenes.scene2d.ui.SkinskinThe global skinstatic com.badlogic.gdx.graphics.g2d.SpriteBatchspriteBatchGlobal all-purpose sprite batchstatic com.badlogic.gdx.graphics.glutils.ShaderProgramspriteShader
-
Constructor Summary
Constructors Constructor Description GlobalResources()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static floatangle2d(com.badlogic.gdx.math.Vector3 v1, com.badlogic.gdx.math.Vector3 v2)Gets the angle in degrees between the two vectorsstatic Vector3dapplyRelativisticAberration(Vector3d pos, ICamera cam)static intcountOccurrences(java.lang.String haystack, char needle)static voiddoneLoading(com.badlogic.gdx.assets.AssetManager manager)static Pair<java.lang.Double,java.lang.String>doubleToDistanceString(double d)Converts this double to the string representation of a distancestatic Pair<java.lang.Double,java.lang.String>doubleToVelocityString(double d)Converts the double to the string representation of a velocity (always in seconds)static booleanendsWith(java.lang.String s, java.lang.String[] endings)Returns true if the string ends with any of the endingsstatic booleanequal(java.lang.String buf, char[] compareTo, boolean ignoreCase)Compares a given buffer with another buffer.static longfileCount(java.nio.file.Path dir)Recursively count files in a directorystatic longfileCount(java.nio.file.Path dir, java.lang.String[] extensions)Count files matching a certain ending in a directory, recursivelystatic Pair<java.lang.Float,java.lang.String>floatToDistanceString(float f)Converts this float to the string representation of a distancestatic java.lang.StringgetGLExtensions()static java.lang.StringhumanReadableByteCount(long bytes, boolean si)Converts bytes to a human readable formatstatic voidinitialize(com.badlogic.gdx.assets.AssetManager manager)static <T,U>
java.util.Map<U,java.util.List<T>>invertMap(java.util.Map<T,U> map)Inverts a mapstatic booleanisAnyInView(Vector3d[] points, float coneAngle, Vector3d dir)Computes whether any of the given points is visible by a camera with the given direction and the given cone angle.static booleanisInView(Vector3d point, double len, float coneAngle, Vector3d dir)Computes whether a body with the given position is visible by a camera with the given direction and angle.static booleanisInView(Vector3d point, float coneAngle, Vector3d dir)Computes whether a body with the given position is visible by a camera with the given direction and angle.static booleanisNumeric(java.lang.String str)static com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle>listRec(com.badlogic.gdx.files.FileHandle f, com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> l, java.io.FilenameFilter filter)static com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle>listRec(com.badlogic.gdx.files.FileHandle f, com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> l, java.lang.String... extensions)Gets all the files with the given extension in the given file handle f.static intnthIndexOf(java.lang.String text, char needle, int n)static java.lang.String[]parseWhitespaceSeparatedList(java.lang.String str)Parses the string and creates a string array.static longsize(java.nio.file.Path path)Attempts to calculate the size of a file or directory.static <K,V extends java.lang.Comparable<? super V>>
java.util.Map<K,V>sortByValue(java.util.Map<K,V> map)static com.badlogic.gdx.graphics.PixmaptextureToPixmap(com.badlogic.gdx.graphics.g2d.TextureRegion tex)Converts a texture to a pixmap by drawing it to a frame buffer and getting the datastatic float[]toFloatArray(double[] array)Transforms the given double array into a float array by casting each of its numbersstatic java.lang.StringtoString(java.lang.String[] l, java.lang.String quote, java.lang.String separator)Converts a string array into a string, optionally quoting each entry and with a given separator.static java.lang.StringtoWhitespaceSeparatedList(java.lang.String[] l)Converts the string array into a whitespace-separated string where each element is double quoted.static java.lang.StringunpackSkyboxSide(java.lang.String skyboxLoc, java.lang.String side)static java.lang.StringunpackTexName(java.lang.String tex)static voidupdateSkin()
-
-
-
Field Detail
-
spriteShader
public static com.badlogic.gdx.graphics.glutils.ShaderProgram spriteShader
-
spriteBatch
public static com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch
Global all-purpose sprite batch
-
extSpriteShader
public static ExtShaderProgram extSpriteShader
-
extSpriteBatch
public static ExtSpriteBatch extSpriteBatch
Sprite batch using int indices
-
linkCursor
public static com.badlogic.gdx.graphics.Cursor linkCursor
Cursors
-
resizeXCursor
public static com.badlogic.gdx.graphics.Cursor resizeXCursor
Cursors
-
resizeYCursor
public static com.badlogic.gdx.graphics.Cursor resizeYCursor
Cursors
-
skin
public static com.badlogic.gdx.scenes.scene2d.ui.Skin skin
The global skin
-
gGreen
public static float[] gGreen
GOOGLE COLORS
-
gGreenC
public static com.badlogic.gdx.graphics.Color gGreenC
-
gBlue
public static float[] gBlue
-
gBlueC
public static com.badlogic.gdx.graphics.Color gBlueC
-
gRed
public static float[] gRed
-
gRedC
public static com.badlogic.gdx.graphics.Color gRedC
-
gYellow
public static float[] gYellow
-
gYellowC
public static com.badlogic.gdx.graphics.Color gYellowC
-
gWhite
public static float[] gWhite
-
gWhiteC
public static com.badlogic.gdx.graphics.Color gWhiteC
-
gPink
public static float[] gPink
-
gPinkC
public static com.badlogic.gdx.graphics.Color gPinkC
-
-
Method Detail
-
initialize
public static void initialize(com.badlogic.gdx.assets.AssetManager manager)
-
updateSkin
public static void updateSkin()
-
doneLoading
public static void doneLoading(com.badlogic.gdx.assets.AssetManager manager)
-
doubleToDistanceString
public static Pair<java.lang.Double,java.lang.String> doubleToDistanceString(double d)
Converts this double to the string representation of a distance- Parameters:
d- In internal units- Returns:
- An array containing the float number and the string units
-
doubleToVelocityString
public static Pair<java.lang.Double,java.lang.String> doubleToVelocityString(double d)
Converts the double to the string representation of a velocity (always in seconds)- Parameters:
d- In internal units- Returns:
- Array containing the number and the units
-
floatToDistanceString
public static Pair<java.lang.Float,java.lang.String> floatToDistanceString(float f)
Converts this float to the string representation of a distance- Parameters:
f- In internal units- Returns:
- An array containing the float number and the string units
-
toFloatArray
public static float[] toFloatArray(double[] array)
Transforms the given double array into a float array by casting each of its numbers- Parameters:
array- The array of doubles- Returns:
- The array of floats
-
isInView
public static boolean isInView(Vector3d point, float coneAngle, Vector3d dir)
Computes whether a body with the given position is visible by a camera with the given direction and angle. Coordinates are assumed to be in the camera-origin system- Parameters:
point- The position of the body in the reference system of the camera (i.e. camera is at origin)coneAngle- The cone angle of the cameradir- The direction- Returns:
- True if the body is visible
-
isInView
public static boolean isInView(Vector3d point, double len, float coneAngle, Vector3d dir)
Computes whether a body with the given position is visible by a camera with the given direction and angle. Coordinates are assumed to be in the camera-origin system- Parameters:
point- The position of the body in the reference system of the camera (i.e. camera is at origin)len- The point lengthconeAngle- The cone angle of the cameradir- The direction- Returns:
- True if the body is visible
-
isAnyInView
public static boolean isAnyInView(Vector3d[] points, float coneAngle, Vector3d dir)
Computes whether any of the given points is visible by a camera with the given direction and the given cone angle. Coordinates are assumed to be in the camera-origin system- Parameters:
points- The array of points to checkconeAngle- The cone angle of the camera (field of view)dir- The direction- Returns:
- True if any of the points is in the camera view cone
-
equal
public static boolean equal(java.lang.String buf, char[] compareTo, boolean ignoreCase)Compares a given buffer with another buffer.- Parameters:
buf- Buffer to compare againstcompareTo- Buffer to compare to (content should be ASCII lowercase if possible)- Returns:
- True if the buffers compare favourably, false otherwise
-
countOccurrences
public static int countOccurrences(java.lang.String haystack, char needle)
-
nthIndexOf
public static int nthIndexOf(java.lang.String text, char needle, int n)
-
listRec
public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> listRec(com.badlogic.gdx.files.FileHandle f, com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> l, java.lang.String... extensions)Gets all the files with the given extension in the given file handle f.- Parameters:
f- The directory to get all the filesl- The list with re resultsextensions- The allowed extensions- Returns:
- The list l
-
listRec
public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> listRec(com.badlogic.gdx.files.FileHandle f, com.badlogic.gdx.utils.Array<com.badlogic.gdx.files.FileHandle> l, java.io.FilenameFilter filter)
-
fileCount
public static long fileCount(java.nio.file.Path dir) throws java.io.IOExceptionRecursively count files in a directory- Parameters:
dir- The directory- Returns:
- The number of files
- Throws:
java.io.IOException
-
fileCount
public static long fileCount(java.nio.file.Path dir, java.lang.String[] extensions) throws java.io.IOExceptionCount files matching a certain ending in a directory, recursively- Parameters:
dir- The directory- Returns:
- The number of files
- Throws:
java.io.IOException
-
endsWith
public static boolean endsWith(java.lang.String s, java.lang.String[] endings)Returns true if the string ends with any of the endings- Parameters:
s- The stringendings- The endings- Returns:
- True if the string ends with any of the endings
-
isNumeric
public static boolean isNumeric(java.lang.String str)
-
sortByValue
public static <K,V extends java.lang.Comparable<? super V>> java.util.Map<K,V> sortByValue(java.util.Map<K,V> map)
-
textureToPixmap
public static com.badlogic.gdx.graphics.Pixmap textureToPixmap(com.badlogic.gdx.graphics.g2d.TextureRegion tex)
Converts a texture to a pixmap by drawing it to a frame buffer and getting the data- Parameters:
tex- The texture to convert- Returns:
- The resulting pixmap
-
invertMap
public static final <T,U> java.util.Map<U,java.util.List<T>> invertMap(java.util.Map<T,U> map)
Inverts a map- Parameters:
map- The map to invert- Returns:
- The inverted map
-
angle2d
public static float angle2d(com.badlogic.gdx.math.Vector3 v1, com.badlogic.gdx.math.Vector3 v2)Gets the angle in degrees between the two vectors
-
applyRelativisticAberration
public static Vector3d applyRelativisticAberration(Vector3d pos, ICamera cam)
-
humanReadableByteCount
public static java.lang.String humanReadableByteCount(long bytes, boolean si)Converts bytes to a human readable format- Parameters:
bytes- The bytessi- Whether to use SI units or binary- Returns:
- The size in a human readable form
-
size
public static long size(java.nio.file.Path path) throws java.io.IOExceptionAttempts to calculate the size of a file or directory.Since the operation is non-atomic, the returned value may be inaccurate. However, this method is quick and does its best.
- Throws:
java.io.IOException
-
parseWhitespaceSeparatedList
public static java.lang.String[] parseWhitespaceSeparatedList(java.lang.String str)
Parses the string and creates a string array. The string is a list of whitespace-separated tokens, each surrounded by double qutotes '"': str = '"a" "bc" "d" "efghi"'- Parameters:
str- The string- Returns:
- The resulting array
-
toWhitespaceSeparatedList
public static java.lang.String toWhitespaceSeparatedList(java.lang.String[] l)
Converts the string array into a whitespace-separated string where each element is double quoted.- Parameters:
l- The string array- Returns:
- The resulting string
-
toString
public static java.lang.String toString(java.lang.String[] l, java.lang.String quote, java.lang.String separator)Converts a string array into a string, optionally quoting each entry and with a given separator.- Parameters:
l- The listquote- The quote string to useseparator- The separator- Returns:
- The resulting string
-
unpackTexName
public static java.lang.String unpackTexName(java.lang.String tex)
-
unpackSkyboxSide
public static java.lang.String unpackSkyboxSide(java.lang.String skyboxLoc, java.lang.String side) throws java.lang.RuntimeException- Throws:
java.lang.RuntimeException
-
getGLExtensions
public static java.lang.String getGLExtensions()
-
-