View Javadoc

1   package fr.ove.openmath.jome.model.processor;
2   
3   import fr.ove.openmath.jome.model.*;
4   import fr.ove.openmath.jome.model.events.*;
5   import java.util.*;
6   
7   /***
8   * A Width-Depth processor.<BR>
9   * It is a mix bettween a Width processor (@see WidthProcessor) and a Depth processor
10  * (@see DepthProcessor).<BR>
11  * The iconification of the formula operates in 2 phases :
12  * <OL>
13  *   <LI>iconification of a certain amount of operands of the operators whose number
14  *   of operands is greater than a specified value</LI>
15  *   <LI>iconification of the subtree of the formula tree structure whose depth is greater than
16  *   than the specified value<LI>
17  * </OL>
18  *
19  * @author © 2000 DIRAT Laurent
20  * @version 1.0  22/08/2000
21  */
22  public class WidthDepthProcessor extends ProcessorImpl implements WidthProcessorInterface, DepthProcessorInterface {
23      /***
24      * The depth processor.
25      */
26      private DepthProcessor depth;
27      
28      /***
29      * The width processor.
30      */
31      private WidthProcessor width;
32      
33      
34      /***
35      * The constructor.
36      * @param formula the formula to process.
37      */
38      public WidthDepthProcessor(Formula formula) {
39          super(formula);
40          depth = new DepthProcessor(formula);
41          width = new WidthProcessor(formula);
42      }
43      
44      /***
45      * Does processing.
46      */
47      public void doProcess() {
48          Formula formula = getFormula();
49          
50          if (formula != null) {
51              width.setProcessingId(getProcessingId());
52              width.doProcess();
53              depth.setProcessingId(getProcessingId());
54              depth.doProcess();
55              
56              /*
57              switch (getProcessingId()) {
58                  case COMPUTE :
59                      width.setProcessingId(COMPUTE);
60                      width.doProcess();
61                      depth.setProcessingId(COMPUTE);
62                      depth.doProcess();
63                      break;
64                  case SIMPLE_ICONIFICATION :
65                      width.setProcessingId(SIMPLE_ICONIFICATION);
66                      width.doProcess();
67                      depth.setProcessingId(SIMPLE_ICONIFICATION);
68                      depth.doProcess();
69                      break;
70                  case RECURSIVE_ICONIFICATION :
71                      width.setProcessingId(RECURSIVE_ICONIFICATION);
72                      width.doProcess();
73                      depth.setProcessingId(RECURSIVE_ICONIFICATION);
74                      depth.doProcess();
75                      break;
76                  case COMPUTE_AND_ICONIFY :
77                      width.setProcessingId(COMPUTE_AND_ICONIFY);
78                      width.doProcess();
79                      depth.setProcessingId(COMPUTE_AND_ICONIFY);
80                      depth.doProcess();
81              }
82              */
83          }
84      }
85      
86      /***
87      * Sets the level from which the processing starts.<BR>
88      * The level correspond for both width and depth processor.
89      * @param level the level.
90      */
91      public void setLevel(int level) {
92          width.setLevel(level);
93          depth.setLevel(level);
94      }
95      
96      // #########################################
97      // ### Interface DepthProcessorInterface ###
98      // #########################################
99      
100     /***
101     * Sets the depth level form which the processing will be considering.<BR>
102     * For convenience only, in most cases this method is equivalent to the
103     * @see setLevel of the @see Processor interface.
104     * @param depthLevel the depth level.
105     */
106     public void setDepthLevel(int depthLevel) {
107         depth.setLevel(depthLevel);
108     }
109     
110     /***
111     * Returns the depth level form which the processing will be considering.<BR>
112     * For convenience only, in most cases this method is equivalent to the
113     * @see getLevel of the @see Processor interface.
114     */
115     public int getDepthLevel() {
116         return depth.getLevel();
117     }
118     
119     /***
120     * Returns the max depth value calculated.
121     */
122     public int getMaxDepthValue() {
123         return depth.getMaxDepthValue();
124     }
125     
126     // #########################################
127     // ### Interface WidthProcessorInterface ###
128     // #########################################
129     
130     /***
131     * Sets the width level form which the processing will be considering.<BR>
132     * For convenience only, in most cases this method is equivalent to the
133     * @see setLevel of the @see Processor interface.
134     * @param widthLevel the width level.
135     */
136     public void setWidthLevel(int widthLevel) {
137         width.setLevel(widthLevel);
138     }
139     
140     /***
141     * Returns the width level form which the processing will be considering.<BR>
142     * For convenience only, in most cases this method is equivalent to the
143     * @see getLevel of the @see Processor interface.
144     */
145     public int getWidthLevel() {
146         return width.getLevel();
147     }
148     
149     /***
150     * Sets the number of children viewed.
151     * @param the number of children viewed.
152     */
153     public void setView(int view) {
154         width.setView(view);
155     }
156     
157     /***
158     * Returns the number of children viewed.
159     */
160     public int getView() {
161         return width.getView();
162     }
163     
164     /***
165     * Returns the list of widths calculated.
166     */
167     public Vector getWidthList() {
168         return width.getWidthList();
169     }
170     
171     /***
172     * Returns the biggest width calculated.
173     */
174     public int getBiggestWidth() {
175         return width.getBiggestWidth();
176     }
177 }