In order to denote the class de.grogra.rgg.Axiom
(or one of the other node classes of the previous examples)
by its simple name Axiom
, it is necessary in Java
to import the class or its declaring package by
one of the following import statements:
import de.grogra.rgg.Axiom; import de.grogra.turtle.*;
In XL, this is not necessary if you use the RGG dialect
of XL, which is indicated by the file name extension rgg
.
This dialect simplifies the usage of XL within GroIMP by the following
implicit declarations:
Automatic import statements:
import java.lang.*; import javax.vecmath.*; import de.grogra.xl.lang.*; import de.grogra.annotation.*; import de.grogra.rgg.*; import de.grogra.turtle.*; import de.grogra.imp3d.objects.*; import de.grogra.imp3d.shading.*; import de.grogra.math.*; import de.grogra.pf.data.*; import de.grogra.graph.impl.Node; import de.grogra.rgg.Attributes; import static de.grogra.xl.util.Operators.*; import static de.grogra.rgg.Library.*; import static de.grogra.vecmath.VecmathOperators.*; import static de.grogra.imp3d.shading.RGBAShader.*; import static de.grogra.pf.ui.ChartPanel.*; import static de.grogra.turtle.TurtleState.*; import static de.grogra.xl.impl.base.Graph.*;
If you encounter simple names like Axiom
or RED
in one of the examples and wonder where they
are declared, the possible locations are the imported packages and
classes. But the simplest way to find the location is to use the
index of the online documentation located at
https://javadoc.grogra.de/index-all.html
.
A class is declared implicitly, its name being the name of the
source file, its superclass being de.grogra.rgg.RGG
.
The source code starting at the first declaration
which is not a class or module declaration is considered as the body
of the class. For example, if the file BinaryTree.rgg
has the content
module X (float a); const float A = 2; public void derive () [ Axiom ==> X(A); X(len) ==> F(len) [RU(30) X(len*0.7)] [RU(-30) X(len*0.7)]; ]
then the actual class declaration is equivalent to
module X (float a); public class BinaryTree extends de.grogra.rgg.RGG { const float A = 2; public void derive () [ Axiom ==> X(A); X(len) ==> F(len) [RU(30) X(len*0.7)] [RU(-30) X(len*0.7)]; ] }
double
values can be used where
float
values are expected. E.g., the declaration
float x = 0.1;
is legal in the RGG dialect of XL, but
illegal in Java, because 0.1
is a
double
literal.
In Java, one would have to write
0.1f
instead of 0.1
.
The standard XL programming language does not define these
implicit declarations. For an example of the standard XL
language, have a look at the
BinaryTree
as a standard XL file and its
development.