codesimian
Class WindowCS

java.lang.Object
  extended by codesimian.CS<CSGeneric>
      extended by codesimian.DefaultCS
          extended by codesimian.WindowCS
All Implemented Interfaces:
CodeSimian, java.awt.event.MouseListener, java.util.EventListener

public class WindowCS
extends DefaultCS
implements java.awt.event.MouseListener

a root gui component that displays 1 other gui component in a java.awt.JFrame (but may later use any Window instead of JFrame). That other might contain many more gui objects.

If countP() is at least 4, each param (except the first) is a list about a specific subject related to windows.

P(0) = window contents. P(1) = list of window properties: x size, y size, x position, y position. All in units of pixels, or if less than 1, a fraction of screen width or height. P(2) = list of window events, like close, minimize, maximize, move, resize (x y or both) P(3) = list of mouse events. Instead, create mouseEventsOnComponent(aComponent listener1 listener2...)? P(4) = list of keyboard events P(5) = pixels of standard-sized icon. One way to get pixel width is to execute P(5) as int (I()).

OLD TEXT, BUT MUCH OF IT IS STILL VALID IF countP() < 4.

Param0 is a GUI CS object to display in the window. To disply multiple things, put them in a Layout and the Layout in this window. Param1 is window width in pixels. Param2 is window height in pixels.

Location of window is similar to size. Param3 is X pixel position, and param4 is Y pixel position. If param3 is the last param, only X position is specified.

These 4 default sizes are in static instance vars with type Number, and start as instances of NumberStack. Example in WindowCS: protected NumberWindowCS.defaultLocationX. NumberStack can contain CSs because Number is CS's superclass.


Field Summary
protected static java.lang.Number defaultHeight
           
protected static java.lang.Number defaultLocationX
           
protected static java.lang.Number defaultLocationY
           
protected static java.lang.Number defaultWidth
           
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS
 
Constructor Summary
WindowCS()
           
WindowCS(javax.swing.JFrame window)
          JFrame 'window' will contain 1 JFrame from its 1 (type GUI.componentType) param.
 
Method Summary
 boolean combineIfParamIsMyClassType()
           
 double cost()
          cost() should be changed to return a float, and should be renamed to costToExecute()

cost of EXECUTING this CS, not including any CSs it executes recursively.
 java.lang.String description()
          a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for.
 double DForProxy()
          tries to make the JFrame visible.
 boolean insertP(int index, CS insertMe)
          same as setP(int,CS) but inserts instead of overwriting.
 CS interpretAsGUI(CS graphRoot)
          some trees/graphs of CSs cant be converted to java.util.Component objects.
 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 LForProxy(java.lang.Class type)
          the default implementation can use many Class parameters.
 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.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 boolean needFuzzyType()
           
 int paramValueToPixelSize(double paramValue, int screenSizeInPixels)
          If paramValue is negative, use the absolute value.
 CS PType(int indexP)
          There is a TYPE for each Param.
A TYPE is a CS whose minP() is at least 1.
 boolean setL(java.lang.Object window)
          setL setD setF setJ setI setS setC setB setZ are functions that SET THE VALUE OF THIS CS to some object, primitive, or array.
 boolean setName(java.lang.String newName)
          sets the name of this CS
 boolean setP(int index, CS setTo)
          Every CS is a list of other CSs, between size minP() and maxP() inclusive.
 boolean unknownCost()
           
protected  boolean updateObjectInWindow()
           
 boolean updateWindowSize()
          returns true if window size changed to param1 x param2 pixels, false if it was already that size
 
Methods inherited from class codesimian.DefaultCS
B, C, countP, decrementMyFuel, deleteP, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertS, insertZ, J, javaCode, LForProxy, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, P, prevD, prevL, S, setB, setC, setCountP, setD, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL1, setMyFuel, setObject, 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, D, deleteP, FForProxy, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, GETS, GETZ, IForProxy, isIllusion, JForProxy, L, 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
 

Field Detail

defaultLocationX

protected static java.lang.Number defaultLocationX

defaultLocationY

protected static java.lang.Number defaultLocationY

defaultWidth

protected static java.lang.Number defaultWidth

defaultHeight

protected static java.lang.Number defaultHeight
Constructor Detail

WindowCS

public WindowCS(javax.swing.JFrame window)
JFrame 'window' will contain 1 JFrame from its 1 (type GUI.componentType) param. The window should not be visible yet. It should become visible when DForProxy() is called.


WindowCS

public WindowCS()
Method Detail

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()

DForProxy

public double DForProxy()
tries to make the JFrame visible. Updates window size to param1 x param2.

Specified by:
DForProxy in class DefaultCS

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

description

public java.lang.String description()
Description copied from class: CS
a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for. Example use: in automatically generated webpages for CodeSimian. Example: "returns sum of all params" for Add.

Overrides:
description in class DefaultCS

updateWindowSize

public boolean updateWindowSize()
returns true if window size changed to param1 x param2 pixels, false if it was already that size


paramValueToPixelSize

public int paramValueToPixelSize(double paramValue,
                                 int screenSizeInPixels)
If paramValue is negative, use the absolute value. If less than 1, its a fraction of screen size. Else its the pixel size (wrapped around the screen size if too big).


combineIfParamIsMyClassType

public boolean combineIfParamIsMyClassType()

cost

public double cost()
Description copied from class: CS
cost() should be changed to return a float, and should be renamed to costToExecute()

cost of EXECUTING this CS, not including any CSs it executes recursively. The INTERNAL cost.

One unit of myFuel() costs cost() units of fuel(). Beware of CSs that counterfeit fuel.

Returns 1 by default.

Overrides:
cost in class CS

unknownCost

public boolean unknownCost()

PType

public CS PType(int indexP)
Description copied from class: CS
There is a TYPE for each Param.
A TYPE is a CS whose minP() is at least 1. When a TYPE executes, it MEASURES THE TYPE OF its first param CS. It returns a positive number if it is that type, else 0 or negative. Some TYPEs use only 2 numbers, while others can return any number in a continuous range.

Types are optional. To not use types, return the default type: Static.defaultType(). The default type returns true for any CS. Most CSs do not need types therefore they use the default type.

Overrides:
PType in class DefaultCS

needFuzzyType

public boolean needFuzzyType()

setP

public boolean setP(int index,
                    CS setTo)
Description copied from class: CS
Every CS is a list of other CSs, between size minP() and maxP() inclusive. setP overwrites one of those CSs or adds a new one at the end, depending on the index. If index is between 0 and countP()-1, overwrites. If it equals countP(), adds at end.

Overrides:
setP in class DefaultCS

insertP

public boolean insertP(int index,
                       CS insertMe)
Description copied from class: CS
same as setP(int,CS) but inserts instead of overwriting. All higher params slide up 1 index.

Overrides:
insertP in class DefaultCS

updateObjectInWindow

protected boolean updateObjectInWindow()

LForProxy

public java.lang.Object LForProxy(java.lang.Class type)
Description copied from class: DefaultCS
the default implementation can use many Class parameters. If you override but do not know what to return, return super.LForProxy(Class). All EXEC objects must override L(Class) the same way they override D(), reversed.

TODO: add ability to return List, or should I make every CS be a list?

Overrides:
LForProxy in class DefaultCS
See Also:
execProxy(), setExecProxy(CS)

setL

public boolean setL(java.lang.Object window)
Description copied from class: CS
setL setD setF setJ setI setS setC setB setZ are functions that SET THE VALUE OF THIS CS to some object, primitive, or array.

Overrides:
setL in class DefaultCS

setName

public boolean setName(java.lang.String newName)
Description copied from class: CS
sets the name of this CS

Overrides:
setName in class DefaultCS

interpretAsGUI

public CS interpretAsGUI(CS graphRoot)
some trees/graphs of CSs cant be converted to java.util.Component objects. interpretAsGUI converts ANY tree/graph of CSs to GUI objects and returns the tree's root. Default implementation uses Layout and TreeOfCodeGUI objects.


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener