1 package fr.ove.openmath.jome.model.processor;
2
3 import fr.ove.openmath.jome.model.Formula;
4
5 /***
6 * An implementation of a @see Processor.<BR>
7 * The method <CODE>doProcess</CODE> does nothing. Subclasses have to,
8 * at least, override it to provide the desired processing.
9 *
10 * @author © 2000 DIRAT Laurent
11 * @version 1.0 17/08/2000
12 */
13 public class ProcessorImpl implements Processor {
14 /***
15 * The formula to process.
16 */
17 private Formula formula;
18
19 /***
20 * To check if we have to update the display of the formula.<BR>
21 * The default is false.
22 */
23 private boolean updateDisplay = false;
24
25 /***
26 * The processing to execute.<BR>
27 * The default corresponds to <CODE>ProcessorImpl.COMPUTE_AND_ICONIFY</CODE>.
28 */
29 private int processingId = COMPUTE_AND_ICONIFY;
30
31 /***
32 * The level form which the processing starts.
33 */
34 private int level = 0;
35
36 /***
37 * The constructor.
38 * @param formula the formula to process.
39 */
40 public ProcessorImpl(Formula formula) {
41 this.formula = formula;
42 }
43
44 /***
45 * Does processing.<BR>
46 * !! Method to override by subclasses !!
47 */
48 public void doProcess() {}
49
50 /***
51 * Sets the formula to processs.
52 */
53 public void setFormula(Formula formula) {
54 this.formula = formula;
55 }
56
57 /***
58 * Returns the formula to process.
59 */
60 public Formula getFormula() {
61 return formula;
62 }
63
64 /***
65 * Specifies if, after processing the formula, the display has to be
66 * updated.
67 * @param updateDisplay <CODE>true</CODE> if the display needs update.
68 * <CODE>false</CODE> otherwise.
69 */
70 public void setUpdateDisplay(boolean updateDisplay) {
71 this.updateDisplay = updateDisplay;
72 }
73
74 /***
75 * Checks if, after processing the formula, the display has to be
76 * updated.
77 * @returns <CODE>true</CODE> if the display needs update.
78 * <CODE>false</CODE> otherwise.
79 */
80 public boolean getUpdateDisplay() {
81 return updateDisplay;
82 }
83
84 /***
85 * Initialisation of the processor.
86 * !! Method to override by subclasses !!
87 * The default is just setting the processing Id to be COMPUTE_AND_ICONIFY;
88 */
89 public void init() {
90 setProcessingId(COMPUTE_AND_ICONIFY);
91 }
92
93 /***
94 * Sets the processing to execute.
95 * @param processingId the processing Id.
96 */
97 public void setProcessingId(int processingId) {
98 this.processingId = processingId;
99 }
100
101 /***
102 * Returns the current processing to execute.
103 */
104 public int getProcessingId() {
105 return processingId;
106 }
107
108 /***
109 * Sets the level from which the processing starts.
110 * @param level the level.
111 */
112 public void setLevel(int level) {
113 this.level = level;
114 }
115
116 /***
117 * Returns the level from which the processing starts.
118 */
119 public int getLevel() {
120 return level;
121 }
122
123
124
125 /***
126 * The different processing to apply to the formula
127 */
128
129 /***
130 * Compute the the necessaru stuff for the iconifcation of the formula.
131 */
132 public static final int COMPUTE = 1;
133
134 /***
135 * Iconify the formula according to the iconification level fixed.<BR>
136 * We assume the necessary computation for the iconification of the formula was previously done.<BR>
137 * This is a simple iconification process. Subtrees of iconfied ones are not iconified.
138 */
139 public static final int SIMPLE_ICONIFICATION = 2;
140
141 /***
142 * Iconify the formula according to the iconification level fixed.<BR>
143 * We assume the necessary computation for the iconification of the formula was previously done.<BR>
144 * This is a recursive iconification process. Subtrees of iconfied ones are also iconified.
145 */
146 public static final int RECURSIVE_ICONIFICATION = 3;
147
148 /***
149 * Compute and iconify (recursivly) the formula according to the iconification level fixed.<BR>
150 * This is the default behaviour.
151 */
152 public static final int COMPUTE_AND_ICONIFY = 4;
153 }