Alma2 API
Actor
Actor(String[] figureName);
Actor(String[] figureName, HashMap state);
Actor(String[] figureName, String label, HashMap state);
Actor(String[] figureName, int x, int y, int angle, String label, HashMap state);
Actor(String[] figureName, String label);
Actor(String[] figureName, int x, int y, int angle, String label);
Actor(String[] figureName, int x, int y, int angle);
Actor(Actor aThis);
- figureName: List with the name of the images, relative to the Images directory;
- state: HashMap with pairs key (name of the variable) and value (initial value of the variable);
- x: X-axe position;
- y: Y-axe position;
- angle: Angle to where the Actor will be rotated: 0 to 360 initially;
- label: The text that will appear on the screen below the actor;
- aThis: A reference to an actor to be copied
Actor(String[] figureName, HashMap
Actor(String[] figureName, String label, HashMap
Actor(String[] figureName, int x, int y, int angle, String label, HashMap
Actor(String[] figureName, String label);
Actor(String[] figureName, int x, int y, int angle, String label);
Actor(String[] figureName, int x, int y, int angle);
Actor(Actor aThis);
- figureName: List with the name of the images, relative to the Images directory;
- state: HashMap with pairs key (name of the variable) and value (initial value of the variable);
- x: X-axe position;
- y: Y-axe position;
- angle: Angle to where the Actor will be rotated: 0 to 360 initially;
- label: The text that will appear on the screen below the actor;
- aThis: A reference to an actor to be copied
Base Semantic Patterns (Alma Nodes)
CAssignNode
Description: Used to create assignment expressions like: a = b+1;CAssignNode(CAlmaNode var, CAlmaNode aStmt2);
CAssignNode(CToken tokvar, CAlmaNode aStmt2);
- var: A Semantic Pattern representing a Variable;
- Tokvar: A Token representing a Variable;
- aStmt2: A Semantic Pattern representing the continuation of the tree.
CCallNode
Description: Used to make a call to a function like, for example: fun(1,x);CCallNode(CToken tokvar, CAlmaNode args);
CCallNode(String var, CAlmaNode args);
- var: A Semantic Pattern representing a Variable;
- Tokvar: A Token representing a Variable;
- args: A Semantic Pattern representing the arguments of the functions (can be null).
CConstNode
Description: Used to define constants like: 5;CConstNode(CToken constant, String type)
CConstNode(Object value)
CConstNode(CToken constant)
- constant: A Token representing a constant;
- type: The type of the constant;
- value: An Object representing a constant value.
CDeclNode
Description: Used to make a declaration of a variable, for instance: int a;CDeclNode(CToken var, String typeVar, CAlmaNode structTree, CAlmaNode assign);
- var: A Token representing a variable;
- type: The type of the constant;
- assign: An Alma node representing an assignment;
- structTree: An Alma node representing a structure (it can be null if the type is simple);
CFuncNode
Description: Used to define a function like: sum(int a, int b) {return a+b};CFuncNode(CToken var, String returnT, CAlmaNode args, CAlmaNode stats);
- var: A Token representing a variable;
- returnT: The type of the returned value (can be null if function is void);
- args: An Alma node representing the arguments of the function;
- stats: An Alma node representing the body of the function;
CIfElseNode
Description: Used to define an if ... then... else... structure: if(a≥0) {a=a-1} {print a=a+1};CIfElseNode(CAlmaNode aStmt1,CAlmaNode aStmt2,CAlmaNode aStmt3);
- aStmt1: An Alma node representing the if condition;
- aStmt2: An Alma node representing the 'then' body of the if;
- aStmt3: An Alma node representing the 'else' body of the if ;
CIfNode
Description: Used to define an if ... then... structure: if(a≤0) {a=a-1}CIfNode(CAlmaNode aStmt1,CAlmaNode aStmt2)
- aStmt1: An Alma node representing the if condition;
- aStmt2: An Alma node representing the 'then' body of the if;
CLstNode
Description: Used to define an list of elements, for example: {a, b, c};CLstNode(CAlmaNode aStmt1, CAlmaNode aStmt2)
- aStmt1: An Alma node representing the head of the list;
- aStmt2: An Alma node representing the tail of the list;
COperNode
Description: Used to define an arithmetic operation, for instance: a+3;COperNode(CAlmaNode aStmt1, CAlmaNode aStmt2, String aName)
COperNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CToken op)
- aStmt1: An Alma node representing the left part of the arithmetic expression;
- aStmt2: An Alma node representing the right part of the arithmetic expression;
- aName: A string representing the operator;
- op: A Token representing the operator;
- The allowed operators are: sum (+), subtraction (-), division (/) and multiplication (*).
COperRelNode
Description: Used to define a boolean operation, for instance: a ≤ 3;COperRelNode(CAlmaNode aStmt1, CAlmaNode aStmt2, String aName);
COperRelNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CToken op);
COperRelNode(CAlmaNode aStmt1, String aName);
COperRelNode(CAlmaNode aStmt1, CToken op);
- aStmt1: An Alma node representing a part of the arithmetic expression;
- aStmt2: An Alma node representing the second part of the arithmetic expression;
- aName: A string representing the operator;
- op: A Token representing the operator;
- The allowed operators are: or (||), and (&&), not (!), less (<), greater (>), less or equal (≤) and great or equal (≥).
CReadNode
Description: Used to read a value from the standard input and store it in a variable: read(x);CReadNode(CAlmaNode aStmt1);
CReadNode(CToken var);
- aStmt1: An Alma node representing a variable to read a value into;
- var: A Token representing the a variable to read a value into.
CReturnNode
Description: Used to define a return expression: return x;CReturnNode(CAlmaNode expr);
CReturnNode();
- expr: An Alma node representing a variable an expression to return;
CStmtsNode
Description: Used to define a single statement or a list of statements: a=2; a = a+3;...CStmtsNode(CAlmaNode aStmt1, CAlmaNode aStmt2);
CStmtsNode(CAlmaNode aStmt1);
- aStmt1: An Alma node representing a statement (the head of a list of statements);
- aStmt2: An Alma node representing a statement (the tail of a list of statements).
CVarNode
Description: Used to access to a variable value;CVarNode(CToken var);
CVarNode(CToken var, String type)
CVarNode(CToken var, CAlmaNode IndexOrField)
- var: A Token representing a variable;
- type: The type of the variable;
- IndexOrField: An Alma node representing the index if the variable is an array.
CWhileNode
Description: Used to define a loop structure, for example: while(i>1) {i=i+1};CWhileNode(CAlmaNode aStmt1,CAlmaNode aStmt2);
- aStmt1: An Alma node representing the conditional expression of the loop;
- aStmt2: An Alma node representing the body of the loop structure;
CWriteNode
Description: Used to print into the standard output the value of an expression: print(a+b);CWriteNode(CAlmaNode aStmt1);
- aStmt1: An Alma node representing the statement to write;
CToken
Description: It's an utility to create a token;CToken();
CToken(boolean aIsEOF, int aRow, int aColumn, String aFileName);
CToken(String avalue, int aRow, int aColumn);
CToken(String aValue, int aType, int aColumn, int aRow, boolean aIsEmpty, boolean aIsEOF, String aName, int aState, String aFileName);
CToken(String aValue, int aType, int aColumn, int aRow, boolean aIsEmpty, boolean aIsEOF, String aName, int aState, String aFileName, Vector aTypes);
CToken(CToken aToken, String aValue);
CToken(String aValue, int aType, int aColumn, int aRow, boolean aIsEmpty, boolean aIsEOF, String aName, String aFileName)
- aIsEOF: boolean that specifies whether or not the token is at the end of the file;
- aRow: the line where the token appears;
- aColumn: the column where the token appears;
- aValue: the value of the token;
- aFileName: the name of the file (you can use the name of the token also);
- aIsEmpty: specifies whether or not the token is empty;
- aName: the identifier of the token;
- aState: the state machine in witch the token is identified
- aTypes: a Vector with the types of the token;
- aType: the type of a token;
- aToken: a reference to an existing token;
Extended Semantic Patterns
The following patterns are extensions to the patterns presented above.
But these are used to set animations and to provide synchronization of the problem and the program domains visualizations.
All the patterns have a common argument in their construction, aps, which is a list of animation patterns (discussed below).
The remainder arguments are the same used in the patterns shown above.
AnimAssignNode(CToken var, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimAssignNode(CAlmaNode var, CAlmaNode aStmt2, AnimationPattern[] aps)
AnimCallNode(String var, CAlmaNode args, AnimationPattern[] aps);
AnimCallNode(CToken var, CAlmaNode args, AnimationPattern[] aps);
AnimConstNode(CToken constant, AnimationPattern[] aps);
AnimConstNode(Object value, AnimationPattern[] aps);
AnimConstNode(CToken constant, String type, AnimationPattern[] aps);
AnimDeclNode(CToken var, String typeVar, CAlmaNode structTree, CAlmaNode assign, AnimationPattern[] aps);
AnimFuncNode(CToken var, String returnT, CAlmaNode args, CAlmaNode stats, AnimationPattern[] aps);
AnimIfElseNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CAlmaNode aStmt3, AnimationPattern[] aps);
AnimIfNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimLstNode(CAlmaNode aStmt1, AnimationPattern[] aps);
AnimLstNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimOperNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CToken op, AnimationPattern[] aps);
AnimOperNode(CAlmaNode aStmt1, CAlmaNode aStmt2, String aName, AnimationPattern[] aps);
AnimOperRelNode(CAlmaNode aStmt1, CToken op, AnimationPattern[] aps);
AnimOperRelNode(CAlmaNode aStmt1, String aName, AnimationPattern[] aps);
AnimOperRelNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CToken op, AnimationPattern[] aps);
AnimOperRelNode(CAlmaNode aStmt1, CAlmaNode aStmt2, String aName, AnimationPattern[] aps);
AnimReadNode(CToken var, AnimationPattern[] aps);
AnimReadNode(CAlmaNode aStmt1, AnimationPattern[] aps);
AnimReturnNode(AnimationPattern[] aps);
AnimReturnNode(CAlmaNode expr, AnimationPattern[] aps);
AnimStmtsNode(CAlmaNode aStmt1, AnimationPattern[] aps);
AnimStmtsNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimVarNode(CToken var, CAlmaNode IndexOrField, AnimationPattern[] aps);
AnimVarNode(CToken var, String type, AnimationPattern[] aps);
AnimVarNode(CToken var, AnimationPattern[] aps);
AnimWhileNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimWriteNode(CAlmaNode aStmt1, AnimationPattern[] aps);
All the patterns have a common argument in their construction, aps, which is a list of animation patterns (discussed below).
The remainder arguments are the same used in the patterns shown above.
AnimAssignNode
Description: See CAssignNode description;AnimAssignNode(CToken var, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimAssignNode(CAlmaNode var, CAlmaNode aStmt2, AnimationPattern[] aps)
AnimCallNode
Description: See CCallNode description;AnimCallNode(String var, CAlmaNode args, AnimationPattern[] aps);
AnimCallNode(CToken var, CAlmaNode args, AnimationPattern[] aps);
AnimConstNode
Description: See CConstNode description;AnimConstNode(CToken constant, AnimationPattern[] aps);
AnimConstNode(Object value, AnimationPattern[] aps);
AnimConstNode(CToken constant, String type, AnimationPattern[] aps);
AnimDeclNode
Description: See CDeclNode description;AnimDeclNode(CToken var, String typeVar, CAlmaNode structTree, CAlmaNode assign, AnimationPattern[] aps);
AnimFuncNode
Description: See CFuncNode description;AnimFuncNode(CToken var, String returnT, CAlmaNode args, CAlmaNode stats, AnimationPattern[] aps);
AnimIfElseNode
Description: See CIfElseNode description;AnimIfElseNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CAlmaNode aStmt3, AnimationPattern[] aps);
AnimIfNode
Description: See CIfNode description;AnimIfNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimLstNode
Description: See CLstNode description;AnimLstNode(CAlmaNode aStmt1, AnimationPattern[] aps);
AnimLstNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimOperNode
Description: See COperNode description;AnimOperNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CToken op, AnimationPattern[] aps);
AnimOperNode(CAlmaNode aStmt1, CAlmaNode aStmt2, String aName, AnimationPattern[] aps);
AnimOperRelNode
Description: See COperRelNode description;AnimOperRelNode(CAlmaNode aStmt1, CToken op, AnimationPattern[] aps);
AnimOperRelNode(CAlmaNode aStmt1, String aName, AnimationPattern[] aps);
AnimOperRelNode(CAlmaNode aStmt1, CAlmaNode aStmt2, CToken op, AnimationPattern[] aps);
AnimOperRelNode(CAlmaNode aStmt1, CAlmaNode aStmt2, String aName, AnimationPattern[] aps);
AnimReadNode
Description: See CReadNode description;AnimReadNode(CToken var, AnimationPattern[] aps);
AnimReadNode(CAlmaNode aStmt1, AnimationPattern[] aps);
AnimReturnNode
Description: See CReturnNode description;AnimReturnNode(AnimationPattern[] aps);
AnimReturnNode(CAlmaNode expr, AnimationPattern[] aps);
AnimStmtsNode
Description: See CStmtsNode description;AnimStmtsNode(CAlmaNode aStmt1, AnimationPattern[] aps);
AnimStmtsNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimVarNode
Description: See CVarNode description;AnimVarNode(CToken var, CAlmaNode IndexOrField, AnimationPattern[] aps);
AnimVarNode(CToken var, String type, AnimationPattern[] aps);
AnimVarNode(CToken var, AnimationPattern[] aps);
AnimWhileNode
Description: See CWhileNode description;AnimWhileNode(CAlmaNode aStmt1, CAlmaNode aStmt2, AnimationPattern[] aps);
AnimWrieNode
Description: See CWriteNode description;AnimWriteNode(CAlmaNode aStmt1, AnimationPattern[] aps);
Animation Patterns
APMove
Description:Is the pattern used to move the actor to any position in the 2D plan.APMove(Actor obj, int[] poses, int x, int y);
APMove(Actor obj, int[] poses, String Xvar, String Yvar);
- obj: Reference to an Actor Object;
- poses: List of numbers (starting in zero) to the refer to the several poses of the Actor;
- x: X-axe position;
- y: Y-axe position;
- Xvar: the name of the key variable to access the X-axe position of the Actor;
- Yvar: the name of the key variable to access the Y-axe position of the Actor.
APRotate
Description:Is the pattern used to rotate the actor. It is not limited to 360o. The use of a superior value is processed natively by the Java Virtual Machine (JVM), so the effects may not be the desired ones.APRotate(Actor obj, int[] poses, int rotAngle);
APRotate(Actor obj, int[] poses, String angleVar);
- obj: Reference to an Actor Object;
- poses: List of numbers (starting in zero) to the refer to the several poses of the Actor;
- rotAngle: Angle to where the Actor will be rotated: 0 to 360;
- angleVar: the name of the key variable to access the rotate angle of the Actor.
APIdentity
DescriptionIs used to keep the actor as it is. This pattern is used to allow the redrawing of an actor in the same position in a sequent scene.APIdentity(Actor actor, int[] poses);
- obj: Reference to an Actor Object;
- poses: List of numbers (starting in zero) to the refer to the several poses of the Actor.
APLabel
DescriptionIs the pattern to set or change the text recited by the actor.APLabel(Actor obj, int[] poses, String labelText);
APLabel(Actor obj, int[] poses, String labelText, String labelVar);
- obj: Reference to an Actor Object;
- poses: List of numbers (starting in zero) to the refer to the several poses of the Actor;
- labelText: The text that will appear on the screen;
- labelVar: The key variable to any attribute of the Actor, to append to the label text.
APAggregator
Description This pattern differs from the others because it does not actuates over a single actor, but over a list of them. It is also used to aggregate poses of a same actor through out the scenes, otherwise only one pose would remain per scene. It can be used to show the trace of the entire animation of a program. The APAggregator is a higher-order animation pattern, because besides the aggregation utility, it embodies both the APMove and the APLabel patterns.APAggregator(ArrayList
APAggregator(ArrayList
APAggregator(ArrayList
- objs: Reference to an ArrayList of Actor Objects;
- poses: List of numbers (starting in zero) to the refer to the several poses of the Actor;
- x: X-axe position;
- y: Y-axe position;
- label: The text that will appear;
- variable: The name of a key variable to any attribute of the Actor. The variable value will figure in the label's text.
APCleanAggregator
Description: This pattern cleans the list of aggregated actors.APCleanAggregator(ArrayList
- listReference: Reference to an ArrayList of Actor Objects to be cleaned;