Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
fr.ove.openmath.jome.model.processor.DepthProcessor Class Reference

A processor for the depth of the formula. More...

Inheritance diagram for fr.ove.openmath.jome.model.processor.DepthProcessor:
Inheritance graph
[legend]
Collaboration diagram for fr.ove.openmath.jome.model.processor.DepthProcessor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DepthProcessor (Formula formula)
 The constructor.
void setDepthLevel (int depthLevel)
 Sets the depth level form which the processing will be considering.
int getDepthLevel ()
 Returns the depth level form which the processing will be considering.
int getMaxDepthValue ()
 Returns the max depth value of the formula.
void doProcess ()
 Does processing.
void setFormula (Formula formula)
 Sets the formula to processs.
Formula getFormula ()
 Returns the formula to process.
void setUpdateDisplay (boolean updateDisplay)
 Specifies if, after processing the formula, the display has to be updated.
boolean getUpdateDisplay ()
 Checks if, after processing the formula, the display has to be updated.
void init ()
 Initialisation of the processor.
void setProcessingId (int processingId)
 Sets the processing to execute.
int getProcessingId ()
 Returns the current processing to execute.
void setLevel (int level)
 Sets the level from which the processing starts.
int getLevel ()
 Returns the level from which the processing starts.

Static Public Member Functions

static void main (String args[])

Static Public Attributes

static final int COMPUTE = 1
 The different processing to apply to the formula.
static final int SIMPLE_ICONIFICATION = 2
 Iconify the formula according to the iconification level fixed.
static final int RECURSIVE_ICONIFICATION = 3
 Iconify the formula according to the iconification level fixed.
static final int COMPUTE_AND_ICONIFY = 4
 Compute and iconify (recursivly) the formula according to the iconification level fixed.

Private Member Functions

void iconifyTheFTS (FormulaTreeStructure fts, int depth)
 Iconifies the descendance of the instance which has a depth greater than the specified.
void iconifyAllTheFTS (FormulaTreeStructure fts, int depth)
 Iconifies all the descendance of the instance which has a Strahler number lower than the specified.
void iconify (FormulaTreeStructure fts, int depth)
 Iconifie the instance if it has a Strahler number lower than the specified.
void computeMaxDepthValue (FormulaTreeStructure fts)
 Computes the max depth value of the formula.

Private Attributes

int maxDepthValue = 0
 The maximal depth of the formula.

Detailed Description

A processor for the depth of the formula.

Author:
© 2000 DIRAT Laurent
Version:
1.0 21/08/2000

Definition at line 42 of file DepthProcessor.java.


Constructor & Destructor Documentation

The constructor.

Parameters:
formulathe formula to process.

Definition at line 52 of file DepthProcessor.java.

                                           {
        super(formula);
    }

Here is the caller graph for this function:


Member Function Documentation

Computes the max depth value of the formula.

Definition at line 226 of file DepthProcessor.java.

                                                                {
        if (fts.getNbChildren() > 0) {
            for (Enumeration e = fts.getChildren().elements(); e.hasMoreElements(); ) 
                computeMaxDepthValue((FormulaTreeStructure) e.nextElement());
        }
        
        maxDepthValue = (int) Math.max(fts.getDepth(), maxDepthValue);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Does processing.

Reimplemented from fr.ove.openmath.jome.model.processor.ProcessorImpl.

Definition at line 85 of file DepthProcessor.java.

                            {
        Formula formula = getFormula();
        
        if (formula != null) {
            switch (getProcessingId()) {
                case COMPUTE :
                    // En fait le calcul de la profondeur est fait à la construction de la formule.
                    // donc rien de particulier à faire ici, si ce n'est affecter la valeur de la 
                    // profondeur max de l'arbre de la formule.
                    maxDepthValue = 0; // initialisation
                    computeMaxDepthValue(formula); // calcul.
                    break;
                case SIMPLE_ICONIFICATION :
                    // Iconifie les parties de la formule qui ont une profondeur supérieure
                    // à celle spécifiée.
                    setUpdateDisplay(true);
                    iconifyTheFTS(formula, getLevel());
                    setUpdateDisplay(false);
                    break;
                case RECURSIVE_ICONIFICATION :
                    // Iconifie les parties de la formule qui ont une profondeur supérieure
                    // à celle spécifiée. Iconification récursive.
                    setUpdateDisplay(true);
                    iconifyAllTheFTS(formula, getLevel());
                    setUpdateDisplay(false);
                    break;
                case COMPUTE_AND_ICONIFY :
                    // En fait le calcul de la profondeur est fait à la construction de la formule.
                    // donc rien de particulier à faire ici, si ce n'est affecter la valeur de la 
                    // profondeur max de l'arbre de la formule.
                    maxDepthValue = 0; // initialisation
                    computeMaxDepthValue(formula); // calcul.
                    // Iconifie les parties de la formule qui ont une profondeur supérieure
                    // à celle spécifié. Iconification récursive.
                    // Le defaut est que l'on icionifie à une valeur correspondant à peu près à la
                    // moitié de la profondeur de l'arbre.
                    setLevel(maxDepthValue / 2);
                    iconifyAllTheFTS(formula, getLevel());
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the depth level form which the processing will be considering.


For convenience only, in most cases this method is equivalent to the

See also:
getLevel of the
Processor interface.

Implements fr.ove.openmath.jome.model.processor.DepthProcessorInterface.

Definition at line 71 of file DepthProcessor.java.

                               {
        return getLevel();
    }

Here is the call graph for this function:

Returns the formula to process.

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 88 of file ProcessorImpl.java.

                                {
        return formula;
    }

Here is the caller graph for this function:

Returns the level from which the processing starts.

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 147 of file ProcessorImpl.java.

                          {
        return level;
    }

Here is the caller graph for this function:

Returns the max depth value of the formula.

Implements fr.ove.openmath.jome.model.processor.DepthProcessorInterface.

Definition at line 78 of file DepthProcessor.java.

                                  {
        return maxDepthValue;
    }

Here is the caller graph for this function:

Returns the current processing to execute.

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 132 of file ProcessorImpl.java.

                                 {
        return processingId;
    }

Here is the caller graph for this function:

Checks if, after processing the formula, the display has to be updated.

Returns:
true if the display needs update. false otherwise.

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 108 of file ProcessorImpl.java.

                                      {
        return updateDisplay;
    }

Here is the caller graph for this function:

Iconifie the instance if it has a Strahler number lower than the specified.

Parameters:
depththe specified Strahler number

Definition at line 201 of file DepthProcessor.java.

                                                              {
        if (fts.getFather() != null) {
            Icon icon = new Icon(fts);
            // On ajoute notre instance à iconifier dans Icon (<=> on iconfie l'instance)
            icon.addIconified(fts);
            // On insère maintenant notre icon à la place de fts.
            // On prend le père de l'instance.
            FormulaTreeStructure father = (FormulaTreeStructure) fts.getFather();
            // On insère notre icone à la place de l'instance
            father.addChild(icon, fts.getRank());
            // On enlève l'instance de la liste des enfants de father.
            father.removeChild(fts);
            
            if (getUpdateDisplay()) {
                // On ajoute un display pour notre icon.
                ModelEvent modelEvent = new ModelEvent(father);
                modelEvent.setAction(ModelEvent.ADD, icon);
                father.fireModelEvent(modelEvent);
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Iconifies all the descendance of the instance which has a Strahler number lower than the specified.

Parameters:
depththe specified Strahler number.

Definition at line 183 of file DepthProcessor.java.

                                                                       {
        // On parcourt tous les enfants de l'instance et on descend dans toute l'arboresnce
        // jusqu'au feuilles. (DFS) Arrivée à la feuille, on teste la valeur du strahler et si
        // elle est inférieure à celle spécifiée, on iconifie.
        // On réitère le process sur tous les enfants.
        if (fts.getNbChildren() > 0) {
            for (Enumeration e = fts.getChildren().elements(); e.hasMoreElements(); ) 
                iconifyAllTheFTS((FormulaTreeStructure) e.nextElement(), depth);

            if (fts.getDepth() >= depth)
                iconify(fts, depth);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Iconifies the descendance of the instance which has a depth greater than the specified.

Parameters:
depththe specified depth value.

Definition at line 132 of file DepthProcessor.java.

                                                                    {
        // On parcourt tous les enfants de l'instance et on descend dans toute l'arboresnce
        // jusqu'au feuilles. (DFS) Arrivée à la feuille, on teste la valeur de la profondeur et si
        // elle est spérieure à celle spécifiée, on iconifie.
        // On réitère le process sur tous les enfants.
        FormulaTreeStructure child = null;
        
        /*
        if (fts.getNbChildren() > 0) {
            for (Enumeration e = fts.getChildren().elements(); e.hasMoreElements(); ) {
                child = (FormulaTreeStructure) e.nextElement();
                if (child.getDepth() < depth)
                    iconifyTheFTS(child, depth);
                else
                    if (child.getNbChildren() > 0) // Si child n'est pas une feuille (i.e. constante), on iconifie
                        iconify(child, depth);
            }
        }
        */
        
        if (fts.isIcon()) {
            FormulaTreeStructure father = (FormulaTreeStructure) fts.getFather();
            fts.uniconify();
            
            // On envoie maintenant un événement comme quoi il faut reconstruire
            // l'affichage.
            ModelEvent modelEvent = new ModelEvent(father);
            modelEvent.setAction(ModelEvent.REBUILD, null);
            father.fireModelEvent(modelEvent);
            
            iconifyTheFTS(father, depth);
        }
        
        if (fts.getDepth() < depth) {
            if (fts.getNbChildren() > 0) {
                for (Enumeration e = fts.getChildren().elements(); e.hasMoreElements(); )
                        iconifyTheFTS((FormulaTreeStructure) e.nextElement(), depth);
            }
        }
        else {
            if (fts.getNbChildren() > 0)
                iconify(fts, depth);
        }
        
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Initialisation of the processor.

!! Method to override by subclasses !! The default is just setting the processing Id to be COMPUTE_AND_ICONIFY;

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 117 of file ProcessorImpl.java.

Here is the call graph for this function:

static void fr.ove.openmath.jome.model.processor.DepthProcessor.main ( String  args[]) [inline, static]

Definition at line 235 of file DepthProcessor.java.

                                           {
        String exp = "1+2/3*(4+3/5)^2+2/((3+5^9)*(1+2+3))";
        Formula formula = new Formula();
        formula.setDoProcessing(true);
        
        DepthProcessor p = new DepthProcessor(formula);
        //p.setLevel(3);
        formula.setProcessor(p);
        
        fr.ove.openmath.jome.ctrlview.bidim.FormulaDisplay display = new fr.ove.openmath.jome.ctrlview.bidim.FormulaDisplay();
        formula.addModelListener(display);
        display.addControlListener(formula);
        
        java.awt.Frame f = new java.awt.Frame();
        f.setLayout(new java.awt.BorderLayout());
        f.setBounds(50, 50, 250, 80);
        f.add("Center", display);
        f.setVisible(true);
        
        fr.ove.openmath.jome.ctrl.linear.LinearParser linearParser = new fr.ove.openmath.jome.ctrl.linear.LinearParser();
        linearParser.addLinearParserListener(formula);
        linearParser.parse(exp);
        System.out.println("la formule saisie est : \t\t" + exp);
        System.out.println("la formule construite est : \t\t" + formula.getLinear());
    }    

Here is the call graph for this function:

Sets the depth level form which the processing will be considering.


For convenience only, in most cases this method is equivalent to the

See also:
setLevel of the
Processor interface.
Parameters:
depthLevelthe depth level.

Implements fr.ove.openmath.jome.model.processor.DepthProcessorInterface.

Definition at line 62 of file DepthProcessor.java.

                                              {
        setLevel(depthLevel);
    }

Here is the call graph for this function:

Sets the formula to processs.

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 81 of file ProcessorImpl.java.

                                            {
        this.formula = formula;
    }
void fr.ove.openmath.jome.model.processor.ProcessorImpl.setLevel ( int  level) [inline, inherited]

Sets the level from which the processing starts.

Parameters:
levelthe level.

Implements fr.ove.openmath.jome.model.processor.Processor.

Reimplemented in fr.ove.openmath.jome.model.processor.WidthDepthProcessor.

Definition at line 140 of file ProcessorImpl.java.

                                    {
        this.level = level;
    }

Here is the caller graph for this function:

void fr.ove.openmath.jome.model.processor.ProcessorImpl.setProcessingId ( int  processingId) [inline, inherited]

Sets the processing to execute.

Parameters:
processingIdthe processing Id.

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 125 of file ProcessorImpl.java.

Here is the caller graph for this function:

Specifies if, after processing the formula, the display has to be updated.

Parameters:
updateDisplaytrue if the display needs update. false otherwise.

Implements fr.ove.openmath.jome.model.processor.Processor.

Definition at line 98 of file ProcessorImpl.java.

Here is the caller graph for this function:


Member Data Documentation

The different processing to apply to the formula.

Compute the the necessaru stuff for the iconifcation of the formula.

Definition at line 160 of file ProcessorImpl.java.

Compute and iconify (recursivly) the formula according to the iconification level fixed.


This is the default behaviour.

Definition at line 180 of file ProcessorImpl.java.

The maximal depth of the formula.

Definition at line 46 of file DepthProcessor.java.

Iconify the formula according to the iconification level fixed.


We assume the necessary computation for the iconification of the formula was previously done.
This is a recursive iconification process. Subtrees of iconfied ones are also iconified.

Definition at line 174 of file ProcessorImpl.java.

Iconify the formula according to the iconification level fixed.


We assume the necessary computation for the iconification of the formula was previously done.
This is a simple iconification process. Subtrees of iconfied ones are not iconified.

Definition at line 167 of file ProcessorImpl.java.


The documentation for this class was generated from the following file: