View Javadoc

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   *
9   * @author © 1999 DIRAT Laurent
10  * @version 2.0 28/06/1999
11  */
12  public class Integral extends KaryOperator {
13      /*
14      * Pour savoir si on est dans le cas o? il faut positionner current sur la variable d'intÈgration
15      * o? si on doit effectivement ajouter un nouvel Èlement (la borne inf au moins).
16      * A la crÈation de l'instance, on ajoute un template pour l'intÈgrande, mais aussi un pour la
17      * variable d'intÈgration (on aura [?]d[?]). Donc, quand on va tomber sur un sÈparateur et donc
18      * que l'on va faire un addElement(), il faudra savoir si on va sur la variable d'intÈgration o?
19      * s'il faut effectivement ajouter la borne inf. Donc par dÈfaut, la valeur est true.
20      */
21      private boolean gotoVariable = true;
22      
23      /*** 
24      * Inserts the instance in the formula tree structure.<BR>
25      * @param current the position in the formula tree where the operator is to be insert.
26      * @return the new current position int hte formula tree.
27      */
28      public FormulaTreeStructure insert(FormulaTreeStructure current) {
29          current = super.insert(current);
30          super.addElement();
31          // On rÈcupËre l'ÈlÈment du second slot (le dx), pour rajouter le d justement.
32          VariableOrNumber dx = (VariableOrNumber) getChild(1).getChild(0);
33          dx.setValue("d" + dx.getValue());
34          return current;
35      }
36      
37      /***
38      * Adds a new element (template) to the end of the list.
39      * Returns the new element.
40      */
41      public FormulaTreeStructure addElement() {
42          if (gotoVariable) {
43              gotoVariable = false;
44              return (FormulaTreeStructure) getChild(1).getChild(0);
45          }
46          else
47              return super.addElement();
48      }
49  }