Amadeus_AlgJava: TUTORIAL
|
Elementary statements (ending with a semicolon) are seen as
primitives of the AlgJava language.
All primitives are written in Java, except the following
simplifications:
instead of
System.out.println(…
and
System.out.print(…
one may write
println(…
and
print(…
instead of the loop head
for(int i = a; i <= b;
i++)
one may write
i = a .. b
(at least 2 sequential dots).
In order
to observe the
corresponding Java program one
should
Also, only a part of an
AlgJava program can be translated and observed:
enclose the part (Editor>Enclose or Ctrl+E) into a separate
group, thereafter
apply Tools>Textualize.
Simple statement |
Typical general form ([] - optional part) |
variable declaration | type variableName
[= initial
value expression]; |
method call statement | methodName([argum1,
argum2, ...]); |
assignment
statement |
variableName
[operation
sign]=
expression; |
expression statement | variableName++;
or variableName--; ++variableName; or --variableName; |
break statement | break;
in loops and switches |
continue statement | continue; in loops |
return statement | return;
in void method declarations (and also in the main part) return ...; in method declarations |
throw statement | throw new ...Exception(...); |
empty statement | ; |
Structure | Empty
sketch is created by |
Empty branch is added by |
if
statement |
F1 |
F5 |
for
statement while statement |
F2 |
|
method
declaration |
F3 |
|
switch
statement |
F4 |
F5 |
try-catch
statement |
Shift
+ F4 |
F5 |
An AlgJava program consists of one
or two parts:
A demo-program without the second
part (in the project AlgJavaDemo),
see:
Hello.algjava
The first part contains simple and
structural statements. Method declarations can occur only in the second
part, and cannot, in turn, contain any method declarations.
A demo-program having also a second part:
Methods.algjava
In the case of more
complex AlgJava programs some plug-ins can be roped in. Their names are
listed (green) in the comment to the (first) branch of the program. The
empty list of plug-ins is denoted by an underscore.
Graphics00.algjava
Jewels.algjava
GraphicsPalette.algjava
OrnamentRek.algjava
Break point (in method mtd) |
Sample results on console |
> A
inspect :k :y :i |
mtd>A:
k = -234 : y = 13.075 : i = 3 |
> B inspect :a[0] :a[i-1] | mtd>B:
a[0] = 20 : i-1 = 2 a[i-1] = 40 |
> area inspect :Math.PI * y * y | mtd>area:
Math.PI * y * y = 537.0729355898515 |
>
below_100? inspect :(a[0]+a[i-1]/8) |
mtd>below_100?:
(a[0] + a[i-1]/8) = 25 |
>
inspect :i :y |
mtd>: i = 3 : y
= 13.075 |
>
start_of_inner_loop |
mtd>start_of_inner_loop: |
Break point (in method mtd) | Sample results on console |
> before_loop
inspectArray :a |
mtd>before_loop:a[]:
30 320 -40 50 |
> after_loop inspectArray :a | mtd>after_loop:a[]:
-40 30 50 320 |
> i-th_row inspectArray :table[i] | mtd>i-th_row:table[i][]: 0 -310 0 725 -1 |
One can insert
import
and static variables declarations at the beginning of an AlgJava
program. For instance:
static boolean on
= true; // declaration of a
static variable (on)
A static variable
is accessible from any method, incl the main
method.
It is not allowed
to enclose import and static variables declarations into a group.
The label of a structural statement may be written as the sketch comment at the
beginning of the sketch . The label must be a unique (inside the
program scope) Java-identifier. It is
transferred to the
corresponding Java program and suffixed by a colon.
At any deeper level of a labeled
statement one can use
break label;
// breaks the
execution of this statement
or, in case of loop statement,
continue label; // breaks the execution
of the body of this loop statement
Property key |
Form |
Purpose |
Example |
AmadeusDirectory |
Full path |
Path to
Amadeus_AlgJava home folder |
AmadeusDirectory
= D:\\AlgJava |
defaultOpenDirectory |
Full path;
current (.) by default |
Otsimistee algus
failidialoogides |
defaultOpenDirectory =
D:\\AlgJava\\Portfolio |
myMacros |
( fName[.type] )+ |
List of macro
sets to be activated |
myMacros = AltGrMacro
AlgJavaMacro |
startProject | Project
description file name; type = html by default |
Project to be
initially opened |
startProject = AlgJavaWorks |
defaultFont |
Font style: 0-plain / 1-bold / 2-italic/ 3-bolditalic |
Default font for
screen |
defaultFont = Times
New Roman, 1, 14 |
iconImageFileName |
By default: AmadeusDirectory \\gif\\collapsed.gif |
Name of the file, containing the icon picture |
iconImageFileName =
D:\\Algjava\\gif\\collapsed2.gif |
autoSaveTimePeriod |
Unsigned
integer; 1 by default |
Period (in
minutes) for autosave |
autoSaveTimePeriod = 3 |
locale |
ENG
| EST | RUS |
User interface
language |
locale = EST |
selectionIntensity |
LIGHT | DARK By default: DARK |
Selection color
intensity |
selectionIntensity = LIGHT |
5. If
necessary, transfer also user's macro set(s):
AlgJavaA|macros|MyAlgJavaMacro.html ==> AlgJavaB|macros|MyAlgJavaMacro.html
6. If necessary, edit AlgJavaB|Amadeus.properties
following the example of AlgJavaA|Amadeus.properties.
These properties will be reckoned at the next start of the
system.
Method Summary |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Method Summary |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Method Summary |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Method Summary |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Method Summary |
|
abstract void |
clearRect(int x,
int y, int width, int height) |
abstract void |
clipRect(int x,
int y, int width, int height) |
abstract void |
copyArea(int x,
int y, int width, int height, int dx, int dy) |
abstract Graphics |
create()
|
create(int x,
int y, int width, int height) |
|
abstract void |
dispose()
|
void |
draw3DRect(int x,
int y, int width, int height, boolean raised) |
abstract void |
drawArc(int x,
int y, int width, int height, int startAngle,
int arcAngle) |
void |
drawBytes(byte[] data,
int offset, int length, int x, int y) |
void |
drawChars(char[] data,
int offset, int length, int x, int y) |
abstract boolean |
drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) |
abstract boolean |
drawImage(Image img, int x, int y, ImageObserver observer) |
abstract boolean |
drawImage(Image img, int x, int y,
int width, int height, Color bgcolor, ImageObserver observer) |
abstract boolean |
drawImage(Image img, int x, int y,
int width, int height, ImageObserver observer) |
abstract boolean |
drawImage(Image img, int dx1,
int dy1, int dx2, int dy2, int sx1, int sy1,
int sx2, int sy2, Color bgcolor, ImageObserver observer) |
abstract boolean |
drawImage(Image img, int dx1,
int dy1, int dx2, int dy2, int sx1, int sy1,
int sx2, int sy2, ImageObserver observer) |
abstract void |
drawLine(int x1,
int y1, int x2, int y2) |
abstract void |
drawOval(int x,
int y, int width, int height) |
abstract void |
drawPolygon(int[] xPoints,
int[] yPoints, int nPoints) |
void |
drawPolygon(Polygon p) |
abstract void |
drawPolyline(int[] xPoints,
int[] yPoints, int nPoints) |
void |
drawRect(int x,
int y, int width, int height) |
abstract void |
drawRoundRect(int x,
int y, int width, int height, int arcWidth,
int arcHeight) |
abstract void |
drawString(AttributedCharacterIterator iterator,
int x, int y) |
abstract void |
drawString(String str, int x,
int y) |
void |
fill3DRect(int x,
int y, int width, int height, boolean raised) |
abstract void |
fillArc(int x,
int y, int width, int height, int startAngle,
int arcAngle) |
abstract void |
fillOval(int x,
int y, int width, int height) |
abstract void |
fillPolygon(int[] xPoints,
int[] yPoints, int nPoints) |
void |
fillPolygon(Polygon p) |
abstract void |
fillRect(int x,
int y, int width, int height) |
abstract void |
fillRoundRect(int x,
int y, int width, int height, int arcWidth,
int arcHeight) |
void |
finalize()
|
abstract Shape |
getClip()
|
abstract Rectangle |
getClipBounds()
|
getClipBounds(Rectangle r) |
|
getClipRect()
|
|
abstract Color |
getColor()
|
abstract Font |
getFont()
|
getFontMetrics()
|
|
abstract FontMetrics |
getFontMetrics(Font f) |
boolean |
hitClip(int x,
int y, int width, int height) |
abstract void |
setClip(int x,
int y, int width, int height) |
abstract void |
setClip(Shape clip) |
abstract void |
setColor(Color c)Sets this graphics context's current color to the specified color. |
abstract void |
setFont(Font font) |
abstract void |
setPaintMode()
|
abstract void |
setXORMode(Color c1) |
toString()
|
|
abstract void |
translate(int x,
int y) |