View Javadoc

1   package fr.ove.openmath.jome.model;
2   
3   import java.util.*;
4   import fr.ove.openmath.jome.model.FormulaTreeStructure;
5   import fr.ove.openmath.jome.model.events.ModelEvent;
6   
7   /***
8   * The operator "-", which is the unary minus.<BR>
9   *
10  * <CODE>UnaryMinus</CODE> represents a node in the formula tree.<BR>
11  * Its children are the operands of the operation.
12  *
13  * @author © 2000 DIRAT Laurent
14  * @version 2.1 10/01/2000
15  */
16  public class UnaryMinus extends UnaryOperator {
17      /***
18      * The Constructor.
19      */
20      public UnaryMinus() {
21          setResourceIdentifier("UNARYMINUS");
22          setValue("-");
23          setAsOperatorPriority(resourcesManager.getAsOperatorPriority("unaryMinusPriorities"));
24          setAsOperandPriority(resourcesManager.getAsOperandPriority("unaryMinusPriorities"));
25      }
26      
27      /***
28      * Inserts the operator instance in the formula tree, from the current insertion position.
29      * (checks the priorities and goes up in the tree if necessary).
30      *
31      * @param ope the current insertion position.
32      * @return the new insertion position.
33      */
34      public FormulaTreeStructure insert(FormulaTreeStructure current) {
35          // Le seul moment o? l'on fait appel ? cet opÈrateur, c'est pour la saisie d'une
36          // soustaction ou d'un moins unaire, et donc o? l'on a une instance de Addition qui est en fait notre
37          // point d'insertion courant, i.e. current.
38          // On peut ajouter l'instance courante telle qu'elle.
39          current.addChild(this);
40          
41          // On insËre notre template dans le FTS
42          VariableOrNumber template = new VariableOrNumber();
43          addChild(template);
44  
45          // On retourne la refÈrence de notre dernier point d'insertion.
46          return template;
47      }
48  }
49