codesimian
Class ThisComputersScreen

java.lang.Object
  extended by codesimian.CS<CSGeneric>
      extended by codesimian.DefaultCS
          extended by codesimian.ThisComputersScreen
All Implemented Interfaces:
CodeSimian

public class ThisComputersScreen
extends DefaultCS

Get my value as a java.awt.Image to create a new Image whose pixels are the same as whats displayed on your computer monitor right now. The image does not change as your screen changes. TODO: write more about this... Execute this object in certain ways to get the next Image.

WARNING: Getting the screen as an image is SLOW and takes MEGABYTES OF MEMORY and may be prevented by your computer's security software or (when more code is finished) prevented by CodeSimian's options.

There can be 0 or 1 params. If at least 1 param, P(0) will be set to the Image when this object is executed, even if this object is not executed as an Image. If 0 params and you execute this object as an Image, it returns that Image. If 0 params and you execute this object as a number, it returns the Image's width in pixels. If 0 params and you execute as anything else, I dont know what it will return.

The Image is often used to set the value of an ImagePixels object, which represents each pixel as a number between 0 and (2^24)-1. Some ImagePixels objects may instead use numbers between 0.0 and 1.0 and/or only represent red, green, or blue, or any other division (instead of all colors). Its a 1-dimensional array. To get its width as an int, execute the ImagePixels object. By combining ThisComputerScreen and ImagePixels, CodeSimian can view your screen the same way you do.

Later, use the system clock to prevent getting a new image capture if its sooner than 1/50 second or a bigger fraction if the system is running too slow. Create some system to monitor Codesimian's speed (if its too busy to respond right now) and to adjust numbers like that fraction when CodeSimian's speed gets too low. See MemoryHog.java. Make a similar class for CPU speed, or design more of codesimian's FUEL system.

Currently ThisComputerScreen does not allow you to SET its value as an Image, but I'd like to be able to write an Image to the screen through this class.

Params 1-4 are XPIXEL YPIXEL XSIZE and YSIZE of the part of the screen the Image should be. They can either be literal pixel numbers (example: x from 1.0001 to 1024, y from 1.0001 to 768) or a fraction of the screen width or height (0.0 to 1.0).


Field Summary
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS
 
Constructor Summary
ThisComputersScreen()
           
 
Method Summary
 double DForProxy()
          Execute this CS and cast to double.
 java.lang.String keyword()
          For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
 java.lang.Object L(java.lang.Class type)
          Optionally execute this CS, and definitely try to CAST it to the specified Java type.
 int maxP()
          Maximum quantity of Params
 int minP()
          For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.
 int pixelInt(double pixelDouble, int pixelsWide)
          pixelDouble is a fraction, range 0 to 1, or if bigger than 1 then its wrapped around pixelsWide.
 java.awt.Rectangle subRectangle(java.awt.Rectangle biggerRectangle)
           
 void updateImage()
           
 
Methods inherited from class codesimian.DefaultCS
B, C, countP, decrementMyFuel, deleteP, description, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertP, insertS, insertZ, J, javaCode, LForProxy, LForProxy, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, P, prevD, prevL, PType, S, setB, setC, setCountP, setD, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL, setL1, setMyFuel, setName, setObject, setP, setPrevExec, setPType, setS, setZ, start, toString, V, Z
 
Methods inherited from class codesimian.CS
addB, addC, addD, addF, addI, addJ, addL, addP, addP, addP, addP, addP, addS, addZ, BForProxy, CForProxy, clone, cost, D, deleteP, FForProxy, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, GETS, GETZ, IForProxy, isIllusion, JForProxy, L, L, L, L, maxD, minD, overwrites, parent, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, reflect6, setB, SETB, setC, SETC, setCost, SETD, setDescription, setF, SETF, setHeap, setI, SETI, setJ, SETJ, SETL, setL, setL, setParent, setParsePriority, setProxyOf, setS, SETS, setTester, setZ, SETZ, SForProxy, tester, toJavaCode, VForProxy, voidReflect, ZForProxy
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThisComputersScreen

public ThisComputersScreen()
Method Detail

DForProxy

public double DForProxy()
Description copied from class: CS
Execute this CS and cast to double.

D() and DForProxy() are the 2 most important functions in CS. They execute this CS. All other execute functions, by default, return DForProxy cast to their own type.

For example, J() calls the proxy which calls JForProxy() which calls DForProxy(). D() calls the proxy which calls DForProxy().

By default, all other primitive EXECUTE functions defer to D.
Functions that EXECUTE this CS: L(Class) L(int,Class,int) Z() B() C() S() I() J() F() D() V()

Specified by:
DForProxy in class DefaultCS

L

public java.lang.Object L(java.lang.Class type)
Description copied from class: CS
Optionally execute this CS, and definitely try to CAST it to the specified Java type. If fail, throw a ClassCastException.

It is preferred not to return CSs from this function. If you have a CS to return, the standard is to put it in param0... setP(0,returnValue), where the function caller should get the output from... P(0).

The functions: V Z B C S I J F D and L , usually EXECUTE this CS and CAST its value to the specified type.
L does not have to execute this CS, but all the others do. The other difference is L can throw a CSCastException (extends ClassCastException).

No pattern of L()'s behavior is guaranteed except for primitive wrappers and 1D arrays.
The L's of some some CSs are more predictable than others, often written about in javadoc of a class.
If it casts correctly, it could fail later. If it fails many times, and you try again, it could still succeed.

These 10 function names are also used by a core part of Java (but not as function names): java.lang.Class.name() . Example: new int[7][6][5].getClass().getName() returns "[[[I".

EXAMPLES:
JButton b = (JButton) new ButtonCS().L(Component.class); //JButton inherits from Component
int fiveFiftyFive = new N(555).I();
double charValues[] = (double[]) new S("arraySize11").L(double[].class);

Overrides:
L in class CS
See Also:
CS.Z(), CS.B(), CS.C(), CS.S(), CS.I(), CS.J(), CS.F(), CS.D()

minP

public int minP()
Description copied from class: DefaultCS
For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.

Overrides:
minP in class DefaultCS

maxP

public int maxP()
Description copied from class: CS
Maximum quantity of Params

Overrides:
maxP in class CS

keyword

public java.lang.String keyword()
Description copied from class: DefaultCS
For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
Default: Returns class name, minus package name (and its dots), and change the first letter to lowercase.

For example, CS.MaxParams does not override keyword(), which returns "maxP".

Overrides:
keyword in class DefaultCS
See Also:
CS.parent(), CS.newInstance(), CS.name()

updateImage

public void updateImage()

subRectangle

public java.awt.Rectangle subRectangle(java.awt.Rectangle biggerRectangle)

pixelInt

public int pixelInt(double pixelDouble,
                    int pixelsWide)
pixelDouble is a fraction, range 0 to 1, or if bigger than 1 then its wrapped around pixelsWide. PixelsWide is the width or height of something on the screen, or the screen itself.