1 package fr.ove.openmath.jome.model;
2
3 import java.util.*;
4 import fr.ove.openmath.jome.model.*;
5 import fr.ove.openmath.jome.model.events.ModelEvent;
6
7 /***
8 * The lambda expression object.<BR>
9 * The first child corresponds to the function. The next child(ren) to the bound variable(s).
10 *
11 * @author © 1999 DIRAT Laurent
12 * @version 2.0 11/10/1999
13 */
14 public class LambdaExpression extends Function
15 private boolean gotoVariable = true;
16
17 /***
18 * Indicator for the rendrering.<BR>
19 * Is only function displayed ?<BR>
20 * In other words, if we got the lambda expression coresponding to lambda(sin(x)+cos(y), x, y), if
21 * its values equals <CODE>true</CODE>, the rendering will be something like (x, y) -> sin(x)+cos(y).
22 * Otherwise, the rendering will simply be sin(x)+cos(y). (we just function is rendered).<BR>
23 */
24 private boolean justFunction = false;
25
26 /***
27 * Returns <CODE>true</CODE> if only the is displayed.
28 * <CODE>false</CODE> otherwise.
29 */
30 public boolean isJustFunction() {
31 return justFunction;
32 }
33
34 /***
35 * Sets if just the function is rendered or not.
36 * @param justFunction <CODE>true</CODE> if we only want the function to be displayed. <CODE>false</CODE> otherwise.
37 */
38 public void setJustFunction(boolean justFunction) {
39 this.justFunction = justFunction;
40 }
41
42 /***
43 * Inserts the instance in the formula tree structure.<BR>
44 * @param current the position in the formula tree where the operator is to be insert.
45 * @return the new current position int hte formula tree.
46 */
47 public FormulaTreeStructure insert(FormulaTreeStructure current) {
48 current = super.insert(current);
49 super.addElement();
50 return current;
51 }
52
53 /***
54 * Adds a new element (template) to the end of the list.
55 * Returns the new element.
56 */
57 public FormulaTreeStructure addElement() {
58 if (gotoVariable) {
59 gotoVariable = false;
60 return (FormulaTreeStructure) getChild(1).getChild(0);
61 }
62 else
63 return super.addElement();
64 }
65 }