rita
Class RiTa

java.lang.Object
  extended by rita.RiTa
All Implemented Interfaces:
processing.core.PConstants, RiConstants

public abstract class RiTa
extends java.lang.Object
implements RiConstants

A range of constants and (static) utility functions for the rita package


Field Summary
static java.lang.String BN
           
static java.lang.String[] CLOSED_CLASS_WORDS
           
static java.lang.String COMMA
           
static int DEFAULT_SERVER_PORT
           
static java.lang.String DOT
           
static java.lang.String LINE_BREAK
           
static java.lang.String LINUX
           
static java.lang.String MAC
           
static java.lang.String OS_SLASH
           
static java.lang.String OS_UNDEFINED
           
static int port
           
static java.lang.String PUNCTUATION
           
static java.lang.String QQ
           
static java.lang.String SPC
           
static java.lang.String[] STOP_WORDS
           
static java.lang.String textEncoding
           
static java.lang.String VERSION
          The current version number for the RiTa package.
static java.lang.String WINDOWS
           
 
Fields inherited from interface rita.support.RiConstants
BEHAVIOR_COMPLETED, BOUNDING_BOX_ALPHA, BRILL_POS_TAGGER, EASE_IN, EASE_IN_CUBIC, EASE_IN_EXPO, EASE_IN_OUT, EASE_IN_OUT_CUBIC, EASE_IN_OUT_EXPO, EASE_IN_OUT_QUARTIC, EASE_IN_OUT_SINE, EASE_IN_QUARTIC, EASE_IN_SINE, EASE_OUT, EASE_OUT_CUBIC, EASE_OUT_EXPO, EASE_OUT_QUARTIC, EASE_OUT_SINE, ESS, FADE_COLOR, FADE_IN, FADE_OUT, FADE_TO_TEXT, FIRST_PERSON, FUTURE_TENSE, ID, LERP, LINEAR, MAXENT_POS_TAGGER, MINIM, MOVE, MUTABLE, PAST_TENSE, PHONEME_BOUNDARY, PHONEMES, PLING_STEMMER, PLURAL, PORTER_STEMMER, POS, PRESENT_TENSE, SCALE_TO, SECOND_PERSON, SENTENCE_BOUNDARY, SINGULAR, SONIA, SPEECH_COMPLETED, STRESSES, SYLLABLE_BOUNDARY, SYLLABLES, TEXT, TEXT_ENTERED, THIRD_PERSON, TIMER, TIMER_COMPLETED, TIMER_TICK, TOKENS, UNKNOWN, WORD_BOUNDARY
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, X, Y, Z
 
Constructor Summary
RiTa()
           
 
Method Summary
static boolean allCaps(java.lang.String word)
          Verifies all chars are are capital letters
static boolean allLetters(java.lang.String[] words)
          Verifies all characters in all words are lowercase letters
static boolean allLowerCase(java.lang.String word)
          Verifies all characters are lowercase & letters
static boolean allLowerCase(java.lang.String[] words)
          Verifies all characters in all (non-null) words are lowercase letters
static java.util.List asList(char[] chars)
           
static java.util.List asList(float[] floats)
           
static java.util.List asList(int[] ints)
           
static java.util.List asList(long[] longs)
           
static java.util.List asList(java.lang.Object[] o)
           
static java.util.List asList(java.util.Set s)
           
static java.awt.image.BufferedImage captureScreen(java.lang.String outFileName)
          Takes a screenshot of the specified width and height (starting in the upper left-hand corner)
static java.awt.image.BufferedImage captureScreen(java.lang.String outFileName, int width, int height)
          Takes a screenshot of the specified width and height (starting in the upper left-hand corner)
static java.awt.image.BufferedImage captureScreen(java.lang.String outFileName, int x, int y, int width, int height)
          Takes a screenshot of the specified width and height (starting at x,y), writes it to a JPG file, and returns the generated BufferedImage.
static java.lang.String chomp(java.lang.String s)
          Removes white-space and line breaks from start and end of String
static float constrain(float amt, float min, float max)
           
static int constrain(int amt, int min, int max)
           
static boolean contains(java.lang.CharSequence word, java.lang.CharSequence[] searches, boolean ignoreCase)
          Return true if any of the words in 'searches' are a substring of 'full'
static boolean contains(java.lang.CharSequence word, java.lang.CharSequence search, boolean ignoreCase)
          Return true if 'search' is a substring of 'full'
static boolean contains(java.lang.Object[] array, java.lang.Object item)
          Returns true if array contains the item, else false
static boolean contains(java.lang.String full, char search)
           
static boolean contains(java.lang.String full, char search, boolean ignoreCase)
          Returns true if 'search' is found in the String, else false.
static boolean contains(java.lang.String full, java.lang.String search)
           
static int count(java.lang.String input, char toMatch)
          counts the # of times char c appears in input
static int count(java.lang.String input, java.lang.String toMatch)
          counts the # of times 'toMatch' appears in input
static Xmlable create(processing.core.PApplet p, java.lang.String xml)
          Creates and returns an Xmlable from the contents of String xml after calling the no-argument constructor.
static Xmlable createFromFile(processing.core.PApplet p, java.lang.String fileName)
          Creates and returns an Xmlable from the XML contents of fileName after calling the no-argument constructor.
static java.lang.String cwd()
          Returns a String holding the current working directory
static java.lang.String decimalFormat(double d)
          Returns a decimal formatted to one place, (eg.
static void die(processing.core.PApplet papplet, java.lang.String errStr)
           
static void disableServer()
          Disables server processing for RiTa.
static java.lang.Object dynamicCast(java.lang.Object toCast, java.lang.Class iface)
          Returns the passed in Object after dynamically casting it to the specified interface.
static java.lang.Object dynamicCast(java.lang.Object toCast, java.lang.Class[] ifaces)
          Returns the passed in Object after dynamically casting it to the specified interfaces.
Note: 'toCast' must be a an instance of a public class.
static float elapsed()
          Returns time since start of program as float (in seconds)
static float elapsed(long start)
          Returns time since start as float (in seconds)
static java.lang.String elapsedStr()
          Returns time since start of program as string, e.g., '4.33s'
static java.lang.String elapsedStr(long start)
          Returns time since start as string, e.g., '4.33s'
static boolean endsWith(java.lang.String full, char[] search)
           
static boolean endsWithPunctuation(java.lang.String input)
          Returns true if 'input' ends with a punctuation character
static boolean equals(java.util.List l1, java.util.List l2)
          Returns true if all elements of the 2 lists are equal, and have the same ordering, testing the elements in each with Object.equals(Object)
static java.lang.String escapeXml(java.lang.String string)
           
static java.lang.String exceptionToString(java.lang.Throwable e)
          Returns a String representation of Exception and stacktrace (only elements with line numbers)
static java.lang.reflect.Method findMethod(java.lang.Object callee, java.lang.String methodName, java.lang.Class[] argTypes, java.lang.Object[] args, boolean isPublic)
           
static boolean fireEvent(java.lang.Object pApplet, RiTaEvent rte)
          Fires a RiTaEvent as a callback to the parent which is generally (but now always) a PApplet
static java.lang.String[] getDataDirectoryGuesses()
           
static java.lang.String getModelDir()
          Returns the directory from which statistical models are loaded
static java.lang.String[] getOpenClassWords(java.lang.String[] words)
          Returns an array without the closed-class words
static java.lang.String getOS()
          Returns a String representing the current OS ["mac", "windows", "linux" ]
static void hideCursor(processing.core.PApplet p)
          Hides the cursor for the duration of the program (requires an application or signed applet).
static java.lang.Object invoke(java.lang.Object callee, java.lang.String methodName)
          Calls 'methodName' on 'callee' Object via reflection
static java.lang.Object invoke(java.lang.Object callee, java.lang.String methodName, java.lang.Class[] argTypes, java.lang.Object[] args)
          Calls 'methodName' on 'callee' Object with args via reflection
static java.lang.Object invoke(java.lang.Object callee, java.lang.String methodName, java.lang.Object[] args)
          Calls 'method' on 'object' via reflection, passing 'args' and inferring the Class[] of argument types by calls to Object.getClass() for each arg.
static java.lang.Object invokeHidden(java.lang.Object callee, java.lang.String methodName, java.lang.Class[] argTypes, java.lang.Object[] args)
          Calls inaccessible (default, private, or protected) 'methodName' on 'callee' Object with 'args' via reflection.
static boolean is3D(processing.core.PGraphics graphics)
           
static boolean isAbbreviation(java.lang.String input)
          Returns true if 'input' is an abbreviation
static boolean isAbsolutePath(java.lang.String fileName)
           
static boolean isAllCaps(java.lang.String word)
          Verifies only the absence of lowercase letters
static boolean isClosedClass(java.lang.String word)
          Returns true if word is a close-class word.
static boolean isLowerCase(java.lang.String word)
          Verifies that every character in word is lowerCase
static boolean isQuestion(java.lang.String[] sentence)
          Returns true if sentence starts with a question sword.
static boolean isSentenceEnd(java.lang.String currentWord, java.lang.String nextWord)
          Returns true if 'currentWord' is the final word of a sentence.
static boolean isServerEnabled()
          Returns whether RiTa will attempt to use the server for processing.
static boolean isStopWord(java.lang.String keyword)
          Returns true if the word is a so-called 'stop-word'
static boolean isTitleCase(java.lang.String word)
          Verifies the first char is upperCase and the rest are lowerCase
static boolean isUpperCase(java.lang.String word)
          Returns true if all characters are uppercase letters
static boolean isVowel(char c)
          Returns true if c is a vowel
static boolean isW_Question(java.lang.String[] sentence)
          Returns true if sentence starts with a w-question word, eg (who,what,why,where,when,etc.)
static java.lang.String join(java.util.List tokenList)
          Joins a list using space as a delimiter.
static java.lang.String join(java.util.List input, java.lang.String delim)
          Concatenates the list 'input' into a single String, spearated by 'delim'
static java.lang.String join(java.lang.Object[] full)
          Joins Array of String into space-delimited String.
static java.lang.String join(java.lang.Object[] full, java.lang.String delim)
          Joins Array of String into delimited String.
static java.lang.String join(java.lang.String[] input, char delim)
          Concatenates the array 'input' into a single String, spearated by 'delim'
static boolean lastCharIs(java.lang.String string, char c)
           
static boolean lastCharMatches(java.lang.String string, char[] chars)
           
static java.lang.String libPath(processing.core.PApplet p)
          Returns the path to the 'libaries' directory in the Processing sketchbook
static byte[] loadBytes(processing.core.PApplet p, java.io.InputStream is)
           
static java.util.Map loadPropertyFile(processing.core.PApplet p, java.lang.String fName)
          Loads a properties-format (key=value) File from the 'data' directory (if the path is relative) and parses it into a Map
static RiSample loadSample(processing.core.PApplet p, java.lang.String sampleFileName)
           
static RiSample loadSample(processing.core.PApplet p, java.lang.String sampleFileName, int playerType)
           
static RiSample loadSample(processing.core.PApplet p, java.lang.String sampleFileName, int playerType, boolean setLooping)
          Convenience method that loads a RiSample object and (if 'setLooping' is true) starts it looping.
static java.lang.String loadString(processing.core.PApplet pApplet, java.lang.String fileName)
          Loads a File by name and reads the contents into a single String
static java.lang.String[] loadStrings(processing.core.PApplet pApplet, java.lang.String fileName)
          Same as pApplet.loadStrings but correctly handles UTF-8 characters.
static java.lang.String[] loadStrings(java.net.URL url)
          Opens a URL (line-by-line) and reads the contents into a String[], one line per array element
static RiSample loopSample(processing.core.PApplet p, java.lang.String sampleFileName)
           
static RiSample loopSample(processing.core.PApplet p, java.lang.String sampleFileName, int playerType)
          Convenience method that loads a RiSample object and starts it looping.
static java.lang.String ls()
           
static void main(java.lang.String[] args)
           
static void mainc(java.lang.String[] args)
           
static java.lang.String mapToString(java.util.Map m)
           
static int millis()
          Returns time since 'start' of program in ms
static int millis(long start)
          Returns time since start as an int (milliseconds)
static boolean noCaps(java.lang.String word)
          Verifies the absence of uppercase letters
static java.io.InputStream openStream(java.lang.Class resourceDir, java.lang.String fileName)
          Opens an InputStream to the specified filename
static java.io.InputStream openStream(processing.core.PApplet p, java.lang.String fileName)
          Opens an InputStream for the specified file
static int pack(int a, int r, int g, int b)
           
 int pack(processing.core.PApplet pApplet, float[] c)
          Packs an array of floats (1,2,3, or 4 elements) into a single integer.
static void pauseCallbackTimer(java.lang.Object pApplet, java.lang.String timerName, boolean paused)
          Pauses (or unpauses) the callback timer with the specified name
static void pauseCallbackTimer(java.lang.Object pApplet, java.lang.String timerName, float pauseTime)
          Pauses the callback timer with the specified name for 'pauseTime' seconds
static void pcwd()
           
static void pElapsed(long timestamp)
           
static void persist(Xmlable persistent, java.lang.String fileName)
          Creates a file with fileName and writes the contents of persistent to it in XML format
static RiSample playSample(processing.core.PApplet p, java.lang.String sampleFileName)
           
static RiSample playSample(processing.core.PApplet p, java.lang.String sampleFileName, int playerType)
          Convenience method that loads a RiSample object and starts it playing.
static void pls()
           
static java.lang.String[] posTag(FeaturedIF[] tokens)
          Uses the default PosTagger to tag (and add features for) each element of words.
static java.lang.String[] posTag(java.lang.String[] tokens)
          Uses the default PosTagger to tag the input with the PENN tag set
static RiProbable probabalisticSelect(java.util.Collection c)
           
static java.util.Map propertiesFromXml(java.lang.String xml)
          Returns a map of key-value pairs in an XML string with format: <...
static java.lang.Object random(java.util.Collection c)
          Returns a random element from a Collection
static java.lang.Object random(java.util.List list)
          Returns a random element from a List
static java.lang.Object random(java.lang.Object[] list)
          Returns a random element from a List
static int[] randomOrdering(int numElements)
          Returns a randomly ordered array of unique integers from 0 to numElements -1.
static void refreshServer()
          Clears all objects from the RiTaServer so that they can be reloaded
static java.lang.Object removeRandom(java.util.Collection c)
          Removes a random element from a Collection, maintaining the ordering
static java.lang.Object removeRandom(java.util.List list)
          Removes a random element from a List, maintaining the ordering
static java.lang.String replaceEntities(java.lang.String input)
          Returns input String with XML/HTML entities replaced
static RiTextBehavior resetCallbackTimer(java.lang.Object pApplet, java.lang.String timerName, float startOffset, float duration, boolean repeat)
          Resets the callback timer with the specified name
static RiTextBehavior resetCallbackTimer(processing.core.PApplet pApplet, java.lang.String timerName, float startOffset, float duration)
          Resets the callback timer with the specified name
static RiProbable select(java.util.Collection c, boolean probabalisticSelect)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, float duration)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, float duration, boolean repeat)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, float startOffset, float duration)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, float startOffset, float duration, boolean repeat)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, java.lang.String timerName, float duration)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, java.lang.String timerName, float duration, boolean repeat)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, java.lang.String timerName, float startOffset, float duration)
           
static RiTextBehavior setCallbackTimer(java.lang.Object pApplet, java.lang.String timerName, float startOffset, float duration, boolean repeat)
          Creates and returns a new callback timer which will generate callbacks to pApplet.onRiTaEvent(RiTaEvent) according to the parameters specified.
static void setModelDir(java.lang.String modelDirectory)
          Set the directory from which statistical models should be loaded
static java.lang.String shortName(java.lang.Class c)
           
static java.lang.String shortName(java.lang.Object c)
           
static void shuffle(java.lang.Object[] items)
           
static java.util.List shuffleKeys(java.util.Map m)
          Returns a shuffled view of the key list for a map
static java.lang.String[] split(java.lang.String toSplit, java.util.regex.Pattern regexPattern, boolean returnDelims)
          An alternative to String.split(String) that optionally returns the delimiters.
static java.lang.String[] splitSentences(java.lang.String text)
          Delegates to the default sentencer parser to split text into sentences
static void stopCallbackTimer(java.lang.String timerName)
          Stops the callback timer with the specified name
static void stopCallbackTimers()
          Stops all callback timers currently running
static java.lang.String[] strArr(java.util.List l)
          Converts the List to a String array
static java.util.Map stringToMap(java.lang.String parameters)
           
static java.lang.String stripMarkup(java.lang.String input)
          Returns input String stripped of HTML markup
static void stripPunctuation(RiText phrase)
           
static java.lang.String stripPunctuation(java.lang.String phrase)
           
static java.lang.String stripPunctuation(java.lang.String phrase, char[] charsToIgnore)
          Strips any punctuation characters from the String
static java.lang.String[] tokenize(java.lang.String line)
          Uses the default WordTokenizer to split the line into words
static void tokenize(java.lang.String line, java.util.List result)
          Uses the default WordTokenizer to split the line into words and places, then the results in result
static java.lang.String toString(char[] c)
           
static java.lang.String toString(float[] floats)
          Returns a formatted String from a float[]
static java.lang.Object[] trim(java.lang.Object[] input)
          Trims null entries off the end of an array.
static java.lang.String trimEnds(java.lang.String token)
          Trims whitespace from both ends of token
static java.lang.String trimPunctuation(java.lang.String token)
          Trims punctuation from each side of the token (does not trim whitespace or internal punctuation).
static java.lang.String trimRegex(java.lang.String input, java.lang.String regex)
          Removes the regex pattern from either side of the string.
static int unbinary(java.lang.String what)
          Unpack a binary String into an int.
static java.lang.String unescapeXml(java.lang.String xmlStr)
           
static float[] unhex(int hexColor)
           
static int[] unpack(int pix)
          Unpacks a integer into an array of floats (size 4) representing (a,r,g,b) color values
static java.lang.String upperCaseFirst(java.lang.String value)
           
static void useServer()
          Enables the RiTaServer on localhost using the default port
static void useServer(int port)
          Enables the RiTaServer on port (default=4444)
static void useServer(java.lang.String host, int port)
          Enables the RiTaServer on host (default=localhost) using port (default=4444).
static void writeFile(java.lang.String fileName, java.lang.String text)
          Creates a File with fname and writes the String 'text' to it
static void writeFile(java.lang.String fileName, java.lang.String[] lines)
          Creates a File with fname and writes the String[] 'lines' to it
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
The current version number for the RiTa package.

This is the # output to the console when the first RiTa class is loaded.

See Also:
Constant Field Values

DEFAULT_SERVER_PORT

public static final int DEFAULT_SERVER_PORT
See Also:
Constant Field Values
Invisible:

port

public static int port
Invisible:

textEncoding

public static java.lang.String textEncoding

QQ

public static final java.lang.String QQ
See Also:
Constant Field Values
Invisible:

BN

public static final java.lang.String BN
See Also:
Constant Field Values
Invisible:

DOT

public static final java.lang.String DOT
See Also:
Constant Field Values
Invisible:

COMMA

public static final java.lang.String COMMA
See Also:
Constant Field Values
Invisible:

SPC

public static final java.lang.String SPC
See Also:
Constant Field Values
Invisible:

OS_SLASH

public static java.lang.String OS_SLASH
Invisible:

LINE_BREAK

public static java.lang.String LINE_BREAK
Invisible:

MAC

public static final java.lang.String MAC
See Also:
Constant Field Values
Invisible:

LINUX

public static final java.lang.String LINUX
See Also:
Constant Field Values
Invisible:

WINDOWS

public static final java.lang.String WINDOWS
See Also:
Constant Field Values
Invisible:

OS_UNDEFINED

public static final java.lang.String OS_UNDEFINED
See Also:
Constant Field Values
Invisible:

PUNCTUATION

public static final java.lang.String PUNCTUATION
See Also:
Constant Field Values
Invisible:

CLOSED_CLASS_WORDS

public static final java.lang.String[] CLOSED_CLASS_WORDS
Invisible:

STOP_WORDS

public static java.lang.String[] STOP_WORDS
Invisible:
Constructor Detail

RiTa

public RiTa()
Method Detail

refreshServer

public static void refreshServer()
Clears all objects from the RiTaServer so that they can be reloaded


useServer

public static void useServer(java.lang.String host,
                             int port)
Enables the RiTaServer on host (default=localhost) using port (default=4444). Note: one must still start the server process (via the scripts provided).


useServer

public static void useServer(int port)
Enables the RiTaServer on port (default=4444)


useServer

public static void useServer()
Enables the RiTaServer on localhost using the default port


disableServer

public static void disableServer()
Disables server processing for RiTa. Note: This does not kill the server process itself if one is running.


isServerEnabled

public static boolean isServerEnabled()
Returns whether RiTa will attempt to use the server for processing. Note: this does say mean that a server process is actually running (or not).


captureScreen

public static java.awt.image.BufferedImage captureScreen(java.lang.String outFileName,
                                                         int x,
                                                         int y,
                                                         int width,
                                                         int height)
Takes a screenshot of the specified width and height (starting at x,y), writes it to a JPG file, and returns the generated BufferedImage. Note: pass a null 'outfile' to skip writing the output image to a file.

Invisible:

captureScreen

public static java.awt.image.BufferedImage captureScreen(java.lang.String outFileName,
                                                         int width,
                                                         int height)
Takes a screenshot of the specified width and height (starting in the upper left-hand corner)

Returns:
Invisible:

captureScreen

public static java.awt.image.BufferedImage captureScreen(java.lang.String outFileName)
Takes a screenshot of the specified width and height (starting in the upper left-hand corner)

Invisible:

pack

public int pack(processing.core.PApplet pApplet,
                float[] c)
Packs an array of floats (1,2,3, or 4 elements) into a single integer.

Invisible:

pack

public static int pack(int a,
                       int r,
                       int g,
                       int b)
Invisible:

unpack

public static int[] unpack(int pix)
Unpacks a integer into an array of floats (size 4) representing (a,r,g,b) color values

Invisible:

escapeXml

public static java.lang.String escapeXml(java.lang.String string)
Invisible:

unescapeXml

public static java.lang.String unescapeXml(java.lang.String xmlStr)
Invisible:

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              java.lang.String timerName,
                                              float startOffset,
                                              float duration)

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              java.lang.String timerName,
                                              float duration)

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              float duration,
                                              boolean repeat)

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              float startOffset,
                                              float duration)

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              float startOffset,
                                              float duration,
                                              boolean repeat)

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              float duration)

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              java.lang.String timerName,
                                              float duration,
                                              boolean repeat)

setCallbackTimer

public static RiTextBehavior setCallbackTimer(java.lang.Object pApplet,
                                              java.lang.String timerName,
                                              float startOffset,
                                              float duration,
                                              boolean repeat)
Creates and returns a new callback timer which will generate callbacks to pApplet.onRiTaEvent(RiTaEvent) according to the parameters specified.

Parameters:
pApplet - The parent applet to call back to
timerName - The name associated with this timer (optional)
startOffset - Time before the timer starts (in seconds)
duration - The timer's period (in seconds)
repeat - Whether the timer fires just once, or repeats indefinitely (default=true)

resetCallbackTimer

public static RiTextBehavior resetCallbackTimer(processing.core.PApplet pApplet,
                                                java.lang.String timerName,
                                                float startOffset,
                                                float duration)
Resets the callback timer with the specified name


resetCallbackTimer

public static RiTextBehavior resetCallbackTimer(java.lang.Object pApplet,
                                                java.lang.String timerName,
                                                float startOffset,
                                                float duration,
                                                boolean repeat)
Resets the callback timer with the specified name


pauseCallbackTimer

public static void pauseCallbackTimer(java.lang.Object pApplet,
                                      java.lang.String timerName,
                                      float pauseTime)
Pauses the callback timer with the specified name for 'pauseTime' seconds

Invisible:

pauseCallbackTimer

public static void pauseCallbackTimer(java.lang.Object pApplet,
                                      java.lang.String timerName,
                                      boolean paused)
Pauses (or unpauses) the callback timer with the specified name

Invisible:

stopCallbackTimers

public static void stopCallbackTimers()
Stops all callback timers currently running


stopCallbackTimer

public static void stopCallbackTimer(java.lang.String timerName)
Stops the callback timer with the specified name


loadSample

public static RiSample loadSample(processing.core.PApplet p,
                                  java.lang.String sampleFileName)

loadSample

public static RiSample loadSample(processing.core.PApplet p,
                                  java.lang.String sampleFileName,
                                  int playerType)

loadSample

public static RiSample loadSample(processing.core.PApplet p,
                                  java.lang.String sampleFileName,
                                  int playerType,
                                  boolean setLooping)
Convenience method that loads a RiSample object and (if 'setLooping' is true) starts it looping.

See Also:
RiConstants.MINIM, RiConstants.ESS, RiConstants.SONIA, loadSample(PApplet, String, int), loadSample(PApplet, String)

loopSample

public static RiSample loopSample(processing.core.PApplet p,
                                  java.lang.String sampleFileName)

loopSample

public static RiSample loopSample(processing.core.PApplet p,
                                  java.lang.String sampleFileName,
                                  int playerType)
Convenience method that loads a RiSample object and starts it looping.

See Also:
RiConstants.MINIM, RiConstants.ESS, RiConstants.SONIA, playSample(PApplet, String, int)

playSample

public static RiSample playSample(processing.core.PApplet p,
                                  java.lang.String sampleFileName)

playSample

public static RiSample playSample(processing.core.PApplet p,
                                  java.lang.String sampleFileName,
                                  int playerType)
Convenience method that loads a RiSample object and starts it playing.

See Also:
RiConstants.MINIM, RiConstants.ESS, RiConstants.SONIA, playSample(PApplet, String, int)

stringToMap

public static java.util.Map stringToMap(java.lang.String parameters)
Invisible:

mapToString

public static java.lang.String mapToString(java.util.Map m)
Invisible:

split

public static java.lang.String[] split(java.lang.String toSplit,
                                       java.util.regex.Pattern regexPattern,
                                       boolean returnDelims)
An alternative to String.split(String) that optionally returns the delimiters.


trim

public static java.lang.Object[] trim(java.lang.Object[] input)
Trims null entries off the end of an array. Returns a new array consisting of the elements from 0 to the last non-null element.


trimEnds

public static java.lang.String trimEnds(java.lang.String token)
Trims whitespace from both ends of token


trimPunctuation

public static java.lang.String trimPunctuation(java.lang.String token)
Trims punctuation from each side of the token (does not trim whitespace or internal punctuation).


getOS

public static java.lang.String getOS()
Returns a String representing the current OS ["mac", "windows", "linux" ]


exceptionToString

public static java.lang.String exceptionToString(java.lang.Throwable e)
Returns a String representation of Exception and stacktrace (only elements with line numbers)


invoke

public static java.lang.Object invoke(java.lang.Object callee,
                                      java.lang.String methodName,
                                      java.lang.Class[] argTypes,
                                      java.lang.Object[] args)
Calls 'methodName' on 'callee' Object with args via reflection

Returns:
return value of method or null on error.
Invisible:

invoke

public static java.lang.Object invoke(java.lang.Object callee,
                                      java.lang.String methodName,
                                      java.lang.Object[] args)
Calls 'method' on 'object' via reflection, passing 'args' and inferring the Class[] of argument types by calls to Object.getClass() for each arg.

Returns:
return value of method or null on error.
Invisible:

invoke

public static java.lang.Object invoke(java.lang.Object callee,
                                      java.lang.String methodName)
Calls 'methodName' on 'callee' Object via reflection

Returns:
return value of method or null on error.
Invisible:

fireEvent

public static boolean fireEvent(java.lang.Object pApplet,
                                RiTaEvent rte)
Fires a RiTaEvent as a callback to the parent which is generally (but now always) a PApplet

Invisible:

findMethod

public static java.lang.reflect.Method findMethod(java.lang.Object callee,
                                                  java.lang.String methodName,
                                                  java.lang.Class[] argTypes,
                                                  java.lang.Object[] args,
                                                  boolean isPublic)
Invisible:

invokeHidden

public static java.lang.Object invokeHidden(java.lang.Object callee,
                                            java.lang.String methodName,
                                            java.lang.Class[] argTypes,
                                            java.lang.Object[] args)
Calls inaccessible (default, private, or protected) 'methodName' on 'callee' Object with 'args' via reflection.

Returns:
return value of method or null on error.
Invisible:

removeRandom

public static java.lang.Object removeRandom(java.util.List list)
Removes a random element from a List, maintaining the ordering

Returns:
null if List is null or empty, else removed item
Invisible:

removeRandom

public static java.lang.Object removeRandom(java.util.Collection c)
Removes a random element from a Collection, maintaining the ordering

Returns:
null if List is null or empty, else removed item

random

public static java.lang.Object random(java.util.Collection c)
Returns a random element from a Collection

Returns:
null if List is null or empty, else random item

random

public static java.lang.Object random(java.util.List list)
Returns a random element from a List

Returns:
null if List is null or empty, else random item

random

public static java.lang.Object random(java.lang.Object[] list)
Returns a random element from a List

Returns:
null if List is null or empty, else random item

shuffle

public static void shuffle(java.lang.Object[] items)
Invisible:

randomOrdering

public static int[] randomOrdering(int numElements)
Returns a randomly ordered array of unique integers from 0 to numElements -1. The size of the array will be numElements.


toString

public static java.lang.String toString(float[] floats)
Returns a formatted String from a float[]


shuffleKeys

public static java.util.List shuffleKeys(java.util.Map m)
Returns a shuffled view of the key list for a map


join

public static java.lang.String join(java.util.List tokenList)
Joins a list using space as a delimiter.


equals

public static boolean equals(java.util.List l1,
                             java.util.List l2)
Returns true if all elements of the 2 lists are equal, and have the same ordering, testing the elements in each with Object.equals(Object)


constrain

public static float constrain(float amt,
                              float min,
                              float max)
Invisible:

constrain

public static int constrain(int amt,
                            int min,
                            int max)
Invisible:

isLowerCase

public static boolean isLowerCase(java.lang.String word)
Verifies that every character in word is lowerCase


isUpperCase

public static boolean isUpperCase(java.lang.String word)
Returns true if all characters are uppercase letters


replaceEntities

public static java.lang.String replaceEntities(java.lang.String input)
Returns input String with XML/HTML entities replaced


shortName

public static java.lang.String shortName(java.lang.Class c)
Invisible:

shortName

public static java.lang.String shortName(java.lang.Object c)
Invisible:

pcwd

public static void pcwd()
Invisible:

cwd

public static java.lang.String cwd()
Returns a String holding the current working directory


pls

public static void pls()
Invisible:

ls

public static java.lang.String ls()
Invisible:

stripMarkup

public static java.lang.String stripMarkup(java.lang.String input)
Returns input String stripped of HTML markup

Parameters:
input - String containing HTML markup
Returns:
input stripped of HTML markup

isClosedClass

public static boolean isClosedClass(java.lang.String word)
Returns true if word is a close-class word.


isSentenceEnd

public static boolean isSentenceEnd(java.lang.String currentWord,
                                    java.lang.String nextWord)
Returns true if 'currentWord' is the final word of a sentence.

This is a simplified version of the OAK/JET sentence splitter method.


isQuestion

public static boolean isQuestion(java.lang.String[] sentence)
Returns true if sentence starts with a question sword.


isW_Question

public static boolean isW_Question(java.lang.String[] sentence)
Returns true if sentence starts with a w-question word, eg (who,what,why,where,when,etc.)


isVowel

public static boolean isVowel(char c)
Returns true if c is a vowel


getOpenClassWords

public static java.lang.String[] getOpenClassWords(java.lang.String[] words)
Returns an array without the closed-class words


toString

public static java.lang.String toString(char[] c)

isAbbreviation

public static boolean isAbbreviation(java.lang.String input)
Returns true if 'input' is an abbreviation


isTitleCase

public static boolean isTitleCase(java.lang.String word)
Verifies the first char is upperCase and the rest are lowerCase


isAllCaps

public static boolean isAllCaps(java.lang.String word)
Verifies only the absence of lowercase letters


allCaps

public static boolean allCaps(java.lang.String word)
Verifies all chars are are capital letters


noCaps

public static boolean noCaps(java.lang.String word)
Verifies the absence of uppercase letters


allLowerCase

public static boolean allLowerCase(java.lang.String word)
Verifies all characters are lowercase & letters


allLowerCase

public static boolean allLowerCase(java.lang.String[] words)
Verifies all characters in all (non-null) words are lowercase letters


allLetters

public static boolean allLetters(java.lang.String[] words)
Verifies all characters in all words are lowercase letters


join

public static java.lang.String join(java.lang.String[] input,
                                    char delim)
Concatenates the array 'input' into a single String, spearated by 'delim'


join

public static java.lang.String join(java.util.List input,
                                    java.lang.String delim)
Concatenates the list 'input' into a single String, spearated by 'delim'


contains

public static boolean contains(java.lang.String full,
                               java.lang.String search)
Invisible:

count

public static int count(java.lang.String input,
                        java.lang.String toMatch)
counts the # of times 'toMatch' appears in input


count

public static int count(java.lang.String input,
                        char toMatch)
counts the # of times char c appears in input


join

public static java.lang.String join(java.lang.Object[] full)
Joins Array of String into space-delimited String.

Parameters:
full - - Array of Strings to be joined
Returns:
String containing elements of String[] or ""

join

public static java.lang.String join(java.lang.Object[] full,
                                    java.lang.String delim)
Joins Array of String into delimited String.

Parameters:
full - - Array of Strings to be joined
delim - - Delimiter to parse elements in resulting String
Returns:
String containing elements of String[] or "" if null

loadPropertyFile

public static java.util.Map loadPropertyFile(processing.core.PApplet p,
                                             java.lang.String fName)
Loads a properties-format (key=value) File from the 'data' directory (if the path is relative) and parses it into a Map


getDataDirectoryGuesses

public static java.lang.String[] getDataDirectoryGuesses()
Invisible:

libPath

public static java.lang.String libPath(processing.core.PApplet p)
Returns the path to the 'libaries' directory in the Processing sketchbook

Invisible:

loadStrings

public static java.lang.String[] loadStrings(java.net.URL url)
Opens a URL (line-by-line) and reads the contents into a String[], one line per array element

Returns:
Contents of the URL stream as a String

loadString

public static java.lang.String loadString(processing.core.PApplet pApplet,
                                          java.lang.String fileName)
Loads a File by name and reads the contents into a single String

Returns:
Contents of the file as String

loadStrings

public static java.lang.String[] loadStrings(processing.core.PApplet pApplet,
                                             java.lang.String fileName)
Same as pApplet.loadStrings but correctly handles UTF-8 characters.


propertiesFromXml

public static java.util.Map propertiesFromXml(java.lang.String xml)
Returns a map of key-value pairs in an XML string with format: <... key1='value1' key2='value2' ... />

Invisible:

openStream

public static java.io.InputStream openStream(java.lang.Class resourceDir,
                                             java.lang.String fileName)
Opens an InputStream to the specified filename

Invisible:

openStream

public static java.io.InputStream openStream(processing.core.PApplet p,
                                             java.lang.String fileName)
Opens an InputStream for the specified file


contains

public static boolean contains(java.lang.String full,
                               char search,
                               boolean ignoreCase)
Returns true if 'search' is found in the String, else false.

Invisible:

contains

public static boolean contains(java.lang.String full,
                               char search)
Invisible:

endsWith

public static boolean endsWith(java.lang.String full,
                               char[] search)
Invisible:

endsWithPunctuation

public static boolean endsWithPunctuation(java.lang.String input)
Returns true if 'input' ends with a punctuation character

See Also:
PUNCTUATION

stripPunctuation

public static java.lang.String stripPunctuation(java.lang.String phrase)

stripPunctuation

public static void stripPunctuation(RiText phrase)

stripPunctuation

public static java.lang.String stripPunctuation(java.lang.String phrase,
                                                char[] charsToIgnore)
Strips any punctuation characters from the String

See Also:
PUNCTUATION

isStopWord

public static boolean isStopWord(java.lang.String keyword)
Returns true if the word is a so-called 'stop-word'

See Also:
STOP_WORDS

asList

public static java.util.List asList(java.util.Set s)
Invisible:

asList

public static java.util.List asList(int[] ints)
Invisible:

asList

public static java.util.List asList(char[] chars)
Invisible:

asList

public static java.util.List asList(long[] longs)
Invisible:

asList

public static java.util.List asList(float[] floats)
Invisible:

asList

public static java.util.List asList(java.lang.Object[] o)
Invisible:

unhex

public static final float[] unhex(int hexColor)
Invisible:

upperCaseFirst

public static final java.lang.String upperCaseFirst(java.lang.String value)
Invisible:

unbinary

public static final int unbinary(java.lang.String what)
Unpack a binary String into an int. i.e. unbinary("00001000") would return 8.

Invisible:

die

public static void die(processing.core.PApplet papplet,
                       java.lang.String errStr)
Invisible:

loadBytes

public static byte[] loadBytes(processing.core.PApplet p,
                               java.io.InputStream is)
Invisible:

pElapsed

public static void pElapsed(long timestamp)
Invisible:

dynamicCast

public static java.lang.Object dynamicCast(java.lang.Object toCast,
                                           java.lang.Class iface)
Returns the passed in Object after dynamically casting it to the specified interface. An example:
      Object o = new Object() {
        public void run() {
          System.out.println("running...");
      }};
      Runnable r = (Runnable)RiTa.dynamicCast(o, Runnable.class);
      r.run();
Note: 'toCast' must be a an instance of a public class.


dynamicCast

public static java.lang.Object dynamicCast(java.lang.Object toCast,
                                           java.lang.Class[] ifaces)
Returns the passed in Object after dynamically casting it to the specified interfaces.
Note: 'toCast' must be a an instance of a public class.

See Also:
dynamicCast(Object, Class)

elapsedStr

public static java.lang.String elapsedStr(long start)
Returns time since start as string, e.g., '4.33s'

Invisible:

elapsedStr

public static java.lang.String elapsedStr()
Returns time since start of program as string, e.g., '4.33s'

Invisible:

elapsed

public static float elapsed()
Returns time since start of program as float (in seconds)

Invisible:

elapsed

public static float elapsed(long start)
Returns time since start as float (in seconds)


millis

public static int millis()
Returns time since 'start' of program in ms

Invisible:

millis

public static int millis(long start)
Returns time since start as an int (milliseconds)

Invisible:

splitSentences

public static java.lang.String[] splitSentences(java.lang.String text)
Delegates to the default sentencer parser to split text into sentences


tokenize

public static void tokenize(java.lang.String line,
                            java.util.List result)
Uses the default WordTokenizer to split the line into words and places, then the results in result

See Also:
RiTokenizer

tokenize

public static java.lang.String[] tokenize(java.lang.String line)
Uses the default WordTokenizer to split the line into words

See Also:
RiTokenizer

posTag

public static java.lang.String[] posTag(java.lang.String[] tokens)
Uses the default PosTagger to tag the input with the PENN tag set

See Also:
RiPosTagger

posTag

public static java.lang.String[] posTag(FeaturedIF[] tokens)
Uses the default PosTagger to tag (and add features for) each element of words.

Invisible:

writeFile

public static void writeFile(java.lang.String fileName,
                             java.lang.String text)
Creates a File with fname and writes the String 'text' to it

Parameters:
fileName - by which to create the File
text - contents to be written to the file as a String

writeFile

public static void writeFile(java.lang.String fileName,
                             java.lang.String[] lines)
Creates a File with fname and writes the String[] 'lines' to it

Parameters:
fileName - by which to create the File
lines - contents to be written to the file

persist

public static void persist(Xmlable persistent,
                           java.lang.String fileName)
Creates a file with fileName and writes the contents of persistent to it in XML format

Invisible:

create

public static Xmlable create(processing.core.PApplet p,
                             java.lang.String xml)
Creates and returns an Xmlable from the contents of String xml after calling the no-argument constructor.

Invisible:

createFromFile

public static Xmlable createFromFile(processing.core.PApplet p,
                                     java.lang.String fileName)
Creates and returns an Xmlable from the XML contents of fileName after calling the no-argument constructor.

Invisible:

strArr

public static java.lang.String[] strArr(java.util.List l)
Converts the List to a String array


chomp

public static java.lang.String chomp(java.lang.String s)
Removes white-space and line breaks from start and end of String

Parameters:
s - String to be chomped
Returns:
string without starting or ending white-space or line-breaks

select

public static RiProbable select(java.util.Collection c,
                                boolean probabalisticSelect)
Invisible:

probabalisticSelect

public static RiProbable probabalisticSelect(java.util.Collection c)
Invisible:

lastCharIs

public static boolean lastCharIs(java.lang.String string,
                                 char c)
Invisible:

lastCharMatches

public static boolean lastCharMatches(java.lang.String string,
                                      char[] chars)
Invisible:

contains

public static boolean contains(java.lang.Object[] array,
                               java.lang.Object item)
Returns true if array contains the item, else false


setModelDir

public static void setModelDir(java.lang.String modelDirectory)
Set the directory from which statistical models should be loaded

Note: expects an absolute path: e.g., '/Users/jill/models'

Invisible:

getModelDir

public static java.lang.String getModelDir()
Returns the directory from which statistical models are loaded

Invisible:

isAbsolutePath

public static boolean isAbsolutePath(java.lang.String fileName)
Invisible:

decimalFormat

public static java.lang.String decimalFormat(double d)
Returns a decimal formatted to one place, (eg. #.#)

Invisible:

contains

public static boolean contains(java.lang.CharSequence word,
                               java.lang.CharSequence search,
                               boolean ignoreCase)
Return true if 'search' is a substring of 'full'


hideCursor

public static void hideCursor(processing.core.PApplet p)
Hides the cursor for the duration of the program (requires an application or signed applet).


contains

public static boolean contains(java.lang.CharSequence word,
                               java.lang.CharSequence[] searches,
                               boolean ignoreCase)
Return true if any of the words in 'searches' are a substring of 'full'


is3D

public static boolean is3D(processing.core.PGraphics graphics)

mainc

public static void mainc(java.lang.String[] args)
                  throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

trimRegex

public static java.lang.String trimRegex(java.lang.String input,
                                         java.lang.String regex)
Removes the regex pattern from either side of the string.


main

public static void main(java.lang.String[] args)