|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpslib.PSTools
public class PSTools
PSTools Class
The PSTools class provides a range of static utility functions.
This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.
Constructor Summary | |
---|---|
PSTools()
|
Method Summary | |
---|---|
static java.lang.String[] |
cleanStrings(java.lang.String[] s)
Remove any empty entries from the specified string array |
static java.lang.String |
combineStrings(java.lang.String[] s)
Combine all the strings within the specified array and return the result |
static java.lang.String |
combineStrings(java.lang.String[] sa,
java.lang.String ss)
Combine all the strings within the specified array with the specified spacer string and return the result |
static float |
constrainFloat(float value,
float min,
float max)
Constrain a float value between the specified minimum and maximum |
static int |
constrainInt(int value,
int min,
int max)
Constrain an integer value between the specified minimum and maximum |
static java.lang.String[] |
copyStrings(java.lang.String[] str)
Copy an array of strings and return the result |
static PSColour |
randomColour()
Return a Colour object with random component values |
static PSColour |
randomColour(boolean alpha)
Return a Colour object with random component values |
static PSVector |
randomVector()
Return a normalised PSVector object with random component values |
static PSVector |
randomVector(float r)
Return a PSVector object with random component values within the specified radius about the point (0, 0, 0) |
static PSVector |
randomVector(float rmi,
float rma)
Return a PSVector object with random component values within the specified radii about the point (0, 0, 0) |
static PSVector |
randomVector(PSVector r)
Return a PSVector object with random component values within +/- the specified range about the point (0, 0, 0) |
static java.lang.String[] |
readStrings(java.io.File f)
Converts an input text file to an array of strings |
static java.lang.String[] |
readStrings(java.lang.String f)
Converts an input text file to an array of strings |
static java.lang.String |
removeFileExtension(java.lang.String s)
Removes a file extension from a string assuming the file.extension format |
static java.lang.String |
removeFileName(java.lang.String s)
Remove the file name from the specified string assuming the string adopts the File.separatorChar path character |
static java.lang.String |
removeTokens(java.lang.String s,
java.lang.String t)
Remove the specified characters from a string |
static java.lang.String |
removeWhiteSpace(java.lang.String str)
Removes all spaces within a string |
static java.lang.String[] |
splitTokens(java.lang.String s,
java.lang.String t)
Split a string using the specified tokens |
static java.lang.String |
stringNumberFormat(java.lang.String s,
char c,
int n)
Replaces instances of a specified character within a string with a formatted number |
static java.lang.String |
stringNumberFormat(java.lang.String s,
int n)
Replaces instances of the character # within a string with a formatted number |
static java.lang.String |
stripQuotes(java.lang.String str)
Removes quotations from a string by removing the first and last characters |
static boolean |
writeStrings(java.lang.String[] sa,
java.io.File f)
Write an array of strings to the specified file |
static boolean |
writeStrings(java.lang.String[] sa,
java.lang.String f)
Write an array of strings to the specified file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PSTools()
Method Detail |
---|
public static java.lang.String[] readStrings(java.lang.String f)
If the input file cannot be parsed a null value will be returned.
f
- file
public static java.lang.String[] readStrings(java.io.File f)
If the input file cannot be parsed a null value will be returned.
f
- file
public static boolean writeStrings(java.lang.String[] sa, java.lang.String f)
sa
- string arrayf
- output file
public static boolean writeStrings(java.lang.String[] sa, java.io.File f)
sa
- string arrayf
- output file
public static java.lang.String combineStrings(java.lang.String[] s)
s
- array of strings
public static java.lang.String combineStrings(java.lang.String[] sa, java.lang.String ss)
sa
- array of stringsss
- spacer string
public static java.lang.String stringNumberFormat(java.lang.String s, int n)
s
- a stringn
- an integer
public static java.lang.String stringNumberFormat(java.lang.String s, char c, int n)
s
- a stringc
- the character to be replacedn
- an integer
public static java.lang.String[] splitTokens(java.lang.String s, java.lang.String t)
s
- stringt
- tokens
public static java.lang.String[] cleanStrings(java.lang.String[] s)
s
- string array
public static java.lang.String removeTokens(java.lang.String s, java.lang.String t)
s
- stringt
- tokens
public static java.lang.String removeFileExtension(java.lang.String s)
s
- a file name as a string
public static java.lang.String removeFileName(java.lang.String s)
s
- file
public static java.lang.String stripQuotes(java.lang.String str)
str
- the string to be formatted
public static java.lang.String removeWhiteSpace(java.lang.String str)
str
- the string to be formatted
public static java.lang.String[] copyStrings(java.lang.String[] str)
str
- string array
public static int constrainInt(int value, int min, int max)
value
- input valuemin
- lower limitmax
- upper limit
public static float constrainFloat(float value, float min, float max)
value
- input valuemin
- lower limitmax
- upper limit
public static PSColour randomColour()
public static PSColour randomColour(boolean alpha)
alpha
- alpha component toggle (true = random alpha)
public static PSVector randomVector()
public static PSVector randomVector(float r)
r
- radius
public static PSVector randomVector(float rmi, float rma)
rmi
- minimum radiusrma
- maximum radius
public static PSVector randomVector(PSVector r)
r
- range
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |