AlMuist's API reference
IMPORTANT
All classes here have a temporary status, and likely to be completely
rewritten. (Also note that they are not ready for writing a complete
application :o)
Table Of Contents
@program
@javaClass
@javaClass.method
@javaApp
@guiBlock
@guiBlock.gadget
@swing
@swing.window
@swing.group( @axis &)
@swing.hgroup
@swing.vgroup
@swing.label
@swing.textField
@swing.button
@swing.check
@swing.slide
This class is empty and serves as a superclass for all programs (so that you can
add definitions and access classes using 'program
)
subclass of @program
Defines a java class.
Note that you need to call @super
when subclassing this.
Fields: |
@import | may contain the name of imported packages (without semi-colon (;)!). Example:
&+'javaClass.import java.io.IOException && |
@comment | may contain a description to be put before the class. For instance:
&=comment This is the main class of the program && |
@extends | may contain the name of a Java superclass. |
@implements | may contain the name of implemented interfaces. Put one definition per implemented
interface. For instance:
&+'javaClass.implements ActionListener && |
@variables | may contain attributes of the Java class. You currently need to write the whole
definition. I'll code a @variable class when I get the time.. :-) Example:
&+variables protected String name; && |
@methods | may contain methods for the class. All definitions should subclass
@javaClass.method |
Defines a Java method.
Note that you need to call @super
when subclassing this.
Fields: |
@protection | may contain a protection modifier for the method (public, protected, private). Default is
public. You can write &=protection && to set the 'package'
protection. |
@isStatic | may contain a boolean value stating if the method is static or not. Default is not static.
Example:
&=isStatic true && |
@return | may contain a return type for the method. Default is void. |
@name | must contain the name of the method. |
@arguments | may contain definitions for the arguments. There should be one definition of this symbol
per argument. Example:
&+arguments String source &&
&+arguments boolean reset && |
@code | may contain the actual code of the method, i.e. what comes between the curly brackets. |
subclass of @javaClass
Defines a Java Application (a class with a static main.)
Note that you need to call @super
when subclassing this.
Definitions: |
@methods | javaApp defines a static method main with argument
String[] arg , that just creates a new instance of the class and
calls the go method on it.
javaApp defines a (nonstatic) go method that takes the same argument as main, and
executes @startup and @init in it (see fields) |
Fields: |
@startup | may contain code to be executed at the beginning of the go method |
@init | may contain code to be executed at the end of the go method |
subclass of @javaClass
generic class for (currently only Java) gui-blocks.
Instances of that amool class define a gui as a Java class; calling the
attachTo() method on a new (Java) instance of this class will create a new
guiBlock.
the amool parental class hierarchy must exactely match the guiBlock you are whishing.
In particular , you must define your root guiBlock as a direct child of your main java class,
and a guiBlock A being conceptually a child of another B, A must have
its amool class direct child of B.
For instance, if you have an application that has three guiBlocks, one root and two children
for it, your class hierarchy should look like this (superclasses and names can of course
be different!):
&=myApplication &=super @javaClass &&
&=mainGui &=super @guiBlock && @super
&=subGui1 &=super @guiBlock && @super
(...)
&&
&=subGui2 &=super @guiBlock && @super
(...)
&&
(...)
&&
(...)
&&
Note that you need to call @super
when subclassing this.
Definitions: |
@import | this class imports java.util.* |
@methods | this class defines a couple of methods:
- A constructorTaking no arguments and doing nothing (at least currently)
- attachTo(parent) attaches the guiBlock to the given parent guiBlock; sets
the parent variable. Runs the
@startup and
@init codes.
- removeFrom(parent) removes the guiBlock from the given parent (which should
be the same as the one given to attachTo), executing the
@exit
and @finish codes.
|
@parent.methods | this class defines a couple of methods to its parent:
- add<className> adds an instance of that guiBlock to the reciever.
- remove<className> removes the given instance of that guiBlock from
the reciever.
|
@variables | this class defines a variable named 'parent', that contains the guiBlock this guiBlock
is attached to, or the application class, if this guiBlock is the root guiBlock. |
@parent.variables | this class adds to its parent a Vector named 'inner<className>', that will contain
all instances of that guiBlock attached to its parent. |
@parent.finish | this class will tell its parent to close all its child guiBlocks of that instance when
it is itself closing. |
@stepUp( @following &) | When you are making a reference from a gadget in a guiblock to a gadget
in a super-guiblock (i.e. one of which the source guiblock is a (direct or not) child,
You have to use this class. I'll explain that in the documentation when I get the time.
The only reference out of a guiBlock you are allowed to make is to a call to this class in
the parent guiBlock (@'guiBlock.parent)
giving as argument the target you want to reach, which itself can be either a component
of that guiBlock, or another transfer class (another @stepDown or another @stepUp).
Example:
&=mainGui
(...)
&=theWindow (...) &&
&=subGui (...)
(...)
&=someGadget
(...)
&=attachedTo @'mainGui.stepUp( @'mainGui.theWindow &) &&
&&
&&
&&
This function basically adds the tag "getParent()." to the functions you're calling on it
(connect, unconnect, copyFrom). See swing.group and swing.slider for
details about these functions. |
@stepDown( @following &) | this is about the same as the above one, except that it must be used when you're going
down the guiBlock hierarchy. A typical example is when you want to notify something
to some gadget in all instances of a sub-guiBlock. Note that you have to call this
function on the destination guiBlock!
Example:
&=mainGui
(...)
&=theWindow (...)
&=source
(...)
&+speakTo @'guiBlock.subGui.stepDown( @'guiBlock.subGui.win.group.target &) &&
&&
&&
&=subGui
(...)
&=target (...)
&&
&&
&&
This function will generate a for-loop to go through all existing instances of the destination
guiBlock. As usual, the argument can itself be a stepXX call...
Remember that arguments of any function are evaluated relative to the caller. In particular,
the class you give as argument to such a function is also relative to that speakTo, attachedTo
(or other) class... |
Fields: |
@startup | may contain code to be executed at the beginning of the attachTo method |
@init | may contain code to be executed at the end of the attachTo method |
@exit | may contain code to be executed at the beginning of the removeFrom method, as
symetric of @init |
@finish | may contain code to be executed at the end of the removeFrom method, as
symetric of @startup |
this is a superclass of anything you might want to add to a window,
ie everything that can be connected to a group, buttons, textfields, gadgets,
groups themselves, ...
Definitions: |
@'guiBlock.variable | each gadget adds a variable of name @name to the surrounding guiBlock,
to allow further referencing |
@'guiBlock.startup | at startup, the gadget calls the @connect amool function on the
object it is attached to (see @attachedTo field) |
@'guiBlock.finish | when disposing the guiBlock, the gadget is unconnected from its container.
This is important when the gadget is attached to another guiBlock. |
Fields: |
@name | you must supply a name for the variable this will be stored into.
It must comply to the language requirements for variable names. Note that
this name might be re-used with some extension for other variables related
to the same gadget (detailed in the appropriate subclasses...) |
@attachedTo | The default value for this field is @'gadget.parent, it says to
which object this gadget should be attached (group or window).
If you want to add this to a gadget in another guiBlock, you can use
the @guiBlock.stepUp function |
@clsid | this must contain the type of which pointers to such a gadget must be.
For instance Jbutton. This is specified by children of classes
like swing |
@alloc | This must contain some expression that returns a new value for the variable.
Typical would be something like new Jbutton( @parent.text ) (or
even new @parent.clsid @% ()). Note that there's no semi-colon
as it is an expression and not a command... |
subclass of @guiBlock
Subclass of guiBlock for swing-based guis. I'll write more details later; but you can have a look at the example codes available
from index page in the meantime...
You design your interface making an amool hierarchy made of subclasses of the
children of this class, that reflects the actual gui hierarchy you want to build: You will typically have a subclass of swing,
inside it one or more subclasses of swing.window, inside it one subclass of swing.group, inside it subclasses of whatever gadgets you
wish your gui to have (see the nTest and sTest examples).
Note that when you have more than one guiBlock, all of them should inherit of the same guisystem!
(In later versions, you will have to put a single child named guisyst at the root of your class hierarchy,
and all guiblocks will inherit of guiBlock, which will reference this child to know what guisystem it is supposed
to use...)
Note that you need to call @super
when subclassing this.
Definitions: |
@import | this class imports:
java.awt.*
java.awt.event.*
javax.swing.*
javax.swing.event.*
|
@implements | this class implements:
- ActionListener
- ChangeListener
I might make this a little more intelligent, making it implement+import
only the stuff it needs... |
@methods | two methods are specified:
- actionPerformed, that runs all definitions of @actions
- stateChanged, that runs all definitions of @changes
|
Fields: |
@actions | every definition of this field will be pasted into the actionPerformed method. |
@changes | every definition of this field will be pasted into the stateChanged method. |
@needSize | setting this to true will make the attachTo method put the Dimension of the screen into
a (local) variable named screenSize... (This is used by windows to open on the center
of the screen) |
attaches a standard window to the containing guiBlock. I will
probably add something that allows to customize the action upon a
close request, as well as something that allows to show/hide the
window..
Definitions: |
@'guiBlock.variables | a variable will be added to the surrounding guiBlock to hold a pointer
to that object |
@'guiBlock.startup | currently, the default behaviour when closing any window is to terminate the program.
I'll make something similar to pressing a button (an action) |
@access | this is used when access the rootpane, for instance to change
the layout or to add component. This is the name of the variable for panels,
and the name of the variable with .getRootPane() for windows.
[I am not sure this is required?] |
@init | the window opens on the center of the screen when the surrounding guiBlock
is attached. |
@connect( @src &, @tag &) | Generates the code that adds an object (src) to the content pane of the window.
If special code is required to access the guiBlock of which this is a window,
then give it as tag argument (example of value for @tag: getParent().)
This does currently not call .pack() on the window; I must find a way to have
it called only once and only when needed (when another guiBlock adds a gadget to
the window after the latter has been opened) |
@unconnect( @src &, @tag &) | The symetric of @connect
(Generates the code that removes the given (src) gadget from the window) |
Fields: |
@title | the title of the window |
subclass of @swing.gadget
a generic group object. A group is a gadget that itself has no visible
components, but that can contain other gadgets.
There exists two kinds of groups, which are horizontal groups (that arrange all
contained gadgets on the same line, in the order in which they have been defined)
and vertical groups (the same, vertically)
Note that, for portability reasons, you should not reference group directely. Instead,
use hgroup and vgroup.
Definitions: |
@clsid | In swing, the groups are implemented using the BoxLayout manager. |
@alloc | Allocates the group at variable declaration... |
@connect( @src &, @tag &) | This adds the given source to the group tagged with the given tag.
see swing.window.connect for details |
@unconnect( @src &, @tag &) | removes the given source from the group tagged with the given tag.
see swing.window.unconnect for details |
Fields: |
@axis | This must contain either X (for an horizontal group) or Y (for a vertical group) |
subclass of @swing.group( X &)
an horizontal gadget group. Use this gadget to group several other gadgets
horizontally...
subclass of @swing.group( Y &)
an vertical gadget group. Use this gadget to group several other gadgets
vertically...
subclass of @swing.gadget
a readonly label, with integer input port
Definitions: |
@clsid | labels are implemented using the swing JLabel class |
@copyFrom | generates the code that changes the contents of
the label to the argument (which must represent an integer, not a gadget). Example:
@myLabel.copyFrom( bla.getValue() &) will generate
something like lbl.setText(bla.getValue()+""); |
Fields: |
@text | can contain a default value for the label |
subclass of @swing.gadget
a text gadget. Has action output and integer input ports
Definitions: |
@'guiBlock.startup | if action is defined, sets the guiBlock as action listener |
@'guiBlock.actions | if you define the field @action
, it will be put in the actionPerformed method. See the button class
for an example. |
Fields: |
@action | may contain code to be executed when the field is acknowledged
(when enter is pressed) |
subclass of @swing.gadget
a button, having action output port
Definitions: |
@'guiBlock.startup | if action is defined, sets the guiBlock as action listener |
@'guiBlock.actions | if you define the field @action
, it will be put in the actionPerformed method. |
Fields: |
@action | may contain native code to be executed when the button is pressed. Example:
Put the following anywhere in a gui hierarchy:
&=myButton &=super @'guiBlock.button &&
&=name button &&
&=text "Click me!" &&
&=action System.out.println("button was clicked!"); &&
&& |
@text | may contain a text string to be displayed on the button |
subclass of @swing.gadget
a currently unconnectable checkbox (I'll implement somehow the boolean input
and output ports... someday... ;-)
Fields: |
@text | may contain some text to be displayed near the checkBox |
subclass of @swing.gadget
a slider, having integer input and output, see nTest demo. You
currently can't set the bounds (fixed to 0;100) or the orientation
(fixed to horizontal)
Definitions: |
@'guiBlock.variables |
a boolean variable that tells if there's a notification running
for the slider, to handle circular notification references. |
@'guiBlock.startup | if required, sets the guiBlock as change listener to the slider |
@'guiBlock.changes | if the speakTo field is set, the changelistener will do the job to forward
the value to the asked destination. |
@copyFrom( @src &, @tag &) | the slider features an integer input port. You can call this giving a number
as argument (typically something like gadget.getValue())
The (optional) tag argument can specify a way to access the guiBlock in which
the slider is (something like "getParent()." or some variable. the name of the
slider variable will be directely attached to the tag, so you need to put a dot
at the end of the tag if you give one. |
Fields: |
@speakTo | may contain a reference to an amool class
that defines its @copyFrom field. If you want to get out of the current
guiBlock, then you need to use the stepUp/stepDown classes.
If define this field, the slider will notify the given destination of any change.
You may put more than one definition to this symbol. Circular references
are correctely handled. This is an integer output port.
Example of two synchronized sliders:
(These slides are in the same group)
&=slide1 &=super @'guiBlock.slide &&
&=name s1 &&
&+speakTo @parent.slide2 &&
&&
&=slide2 &=super @'guiBlock.slide
&=name s2 &&
&+speakTo @parent.slide1 &&
&&
|
Maxime Gamboni Last modified on: Wed Jun 20 11:05:43 CEST 2001
This page has been generated with Amool