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.WidthProcessor Class Reference

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

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

List of all members.

Public Member Functions

 WidthProcessor (Formula formula)
 The constructor.
void setWidthLevel (int widthLevel)
 Sets the width level form which the processing will be considering.
int getWidthLevel ()
 Returns the width level form which the processing will be considering.
void setView (int view)
 Sets the number of children viewed.
int getView ()
 Returns the number of children viewed.
Vector getWidthList ()
 Returns the list of widths of the formula.
int getBiggestWidth ()
 Returns the biggest width 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 width)
 Iconifies the descendance of the instance which has a widht number greater than the specified.
void iconifyAllTheFTS (FormulaTreeStructure fts, int width)
 Iconifies all the descendance of the instance which has a width greater than the specified.
void iconify (FormulaTreeStructure fts, int width)
 Iconifie the instance if it has a width greater than the specified.
void buildWidthList (FormulaTreeStructure fts)
 Builds the list of widths of the formula.
void addNewWidth (int width)
 Adds the specified width value in the list if necessary.

Private Attributes

Vector widthList = new Vector()
 The list of widths numbers in the formula.
boolean isListValid = false
 Check if the current list of Strahler numbers in the formula is valid or not.
int view = -1
 The number of children viewed.

Detailed Description

A processor for the width of the formula.


What is called width corresponds to the number of operand of an operator. (i.e. the number of children of a node in the formula tree stucture.
The processor only displays a specified amount of operand of an operator whose number of operands is greater than a specified value. The other operands are iconified.

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

Definition at line 46 of file WidthProcessor.java.


Constructor & Destructor Documentation

The constructor.

Definition at line 67 of file WidthProcessor.java.

                                           {
        super(formula);
    }

Here is the caller graph for this function:


Member Function Documentation

Adds the specified width value in the list if necessary.

Parameters:
widththe width value to add

Definition at line 269 of file WidthProcessor.java.

                                        {
        int currentWidth;
        
        if (widthList.size() == 0)
            widthList.addElement(new Integer(width));
        else {
            for (int i = 0; i < widthList.size(); i++) {
                currentWidth = ((Integer) widthList.elementAt(i)).intValue();
                if (width == currentWidth)
                    return;
                else if (width < currentWidth) {
                    widthList.insertElementAt(new Integer(width), i);
                    return;
                }
            }
            widthList.addElement(new Integer(width));
        }
    }

Here is the caller graph for this function:

Builds the list of widths of the formula.

Definition at line 255 of file WidthProcessor.java.

                                                          {
        int width = fts.getNbChildren();
        
        if (width > 1)
            addNewWidth(width);
            
        for (int i = 0; i < width; i++)
            buildWidthList((FormulaTreeStructure) fts.getChild(i));
    }

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 127 of file WidthProcessor.java.

                            {
        Formula formula = getFormula();
        
        if (formula != null) {
            switch (getProcessingId()) {
                case COMPUTE :
                    // La liste des Strahler n'est (a priori) plus à jour.
                    buildWidthList(formula);
                    break;
                case SIMPLE_ICONIFICATION :
                    // Iconifie les parties de la formule qui ont un nombre de Strahler inférieur
                    // à celui spécifié.
                    setUpdateDisplay(true);
                    iconifyTheFTS(formula, getLevel());
                    setUpdateDisplay(false);
                    break;
                case RECURSIVE_ICONIFICATION :
                    // Iconifie les parties de la formule qui ont un nombre de Strahler inférieur
                    // à celui spécifié. Iconification récursive.
                    setUpdateDisplay(true);
                    iconifyAllTheFTS(formula, getLevel());
                    setUpdateDisplay(false);
                    break;
                case COMPUTE_AND_ICONIFY :
                    // La liste des Strahler n'est (a priori) plus à jour.
                    buildWidthList(formula);
                    // Iconifie les parties de la formule qui ont un nombre de Strahler inférieur
                    // à celui spécifié. Iconification récursive.
                    // Le defaut est que l'on icionifie à une valeur correspondant à peu près à la
                    // valeur moyenne du Strahler max calculé.
                    int width = getBiggestWidth() / 2;
                    // Maintenant on regarde dans la liste des width, le width valide immédiatement
                    // supérieur à la valeur correpsondant à la moitié du plus grand.
                    int count = widthList.size();
                    int tmp;
                    for (int i = 0; i < count; i++ ) {
                        tmp = ((Integer) widthList.elementAt(i)).intValue();
                        if (tmp > width) {
                            width = tmp;
                            break;
                        }
                        
                    }
                    setLevel(width);
                    view = width / 2; // On ne visualise que la moitié de fils de l'opérateur
                    iconifyAllTheFTS(formula, width);
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the biggest width of the formula.

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

Definition at line 120 of file WidthProcessor.java.

                                 {
        return ((Integer) widthList.lastElement()).intValue();
    }

Here is the caller 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 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:

Returns the number of children viewed.

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

Definition at line 101 of file WidthProcessor.java.

                         {
        return view;
    }

Here is the caller graph for this function:

Returns the width 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.WidthProcessorInterface.

Definition at line 86 of file WidthProcessor.java.

                               {
        return getLevel();
    }

Here is the call graph for this function:

Returns the list of widths of the formula.

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

Definition at line 109 of file WidthProcessor.java.

                                 {
        if (!isListValid) {
            buildWidthList(getFormula());
            isListValid = true;
        }
        return widthList;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Iconifie the instance if it has a width greater than the specified.

Parameters:
widththe specified width.
    for (int i = view; i < count; ) {
        child = (FormulaTreeStructure) fts.getChild(i);
        icon.addIconified(child);

fts.removeChild(child); count--; }

Definition at line 221 of file WidthProcessor.java.

                                                              {
        int count = fts.getNbChildren();
        Icon icon = new Icon(fts);
        // On ajoute notre instance à iconifier dans Icon (<=> on iconfie l'instance)
        FormulaTreeStructure child;
        // On ajout notre icone
        fts.addChild(icon);
        for (int i = view; i < count; i++)
            icon.addIconified((FormulaTreeStructure) fts.getChild(i));
            
        for (int i = view; i < count; ) {
            fts.removeChild((FormulaTreeStructure) fts.getChild(i));
            count--;
        }
        
        if (getUpdateDisplay()) {
            // On ajoute un display pour notre icon.
            ModelEvent modelEvent = new ModelEvent(fts);
            modelEvent.setAction(ModelEvent.ADD, icon);
            fts.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 width greater than the specified.

Parameters:
widththe specified width.

Definition at line 202 of file WidthProcessor.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.
        int ftsWidth = fts.getNbChildren();
        if (ftsWidth > 0) {
            for (Enumeration e = fts.getChildren().elements(); e.hasMoreElements(); ) 
                iconifyAllTheFTS((FormulaTreeStructure) e.nextElement(), width);
                
            if (ftsWidth >= width)
                iconify(fts, width);
        }
    }

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 widht number greater than the specified.

Parameters:
widththe specified width.

Definition at line 182 of file WidthProcessor.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.
        FormulaTreeStructure child = null;
        int ftsWidth = fts.getNbChildren();
        if ((ftsWidth > 0) && (ftsWidth >= width))
            iconify(fts, width);
                        
        int count = fts.getNbChildren();
        for (int i = 0; i < count; i++) 
            iconifyTheFTS((FormulaTreeStructure) fts.getChild(i), width);
    }

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.WidthProcessor.main ( String  args[]) [inline, static]

Definition at line 288 of file WidthProcessor.java.

                                           {
        String exp = "a*z*e*r*r*t*(t+2+2+2+2+2+2+2+6+6+6+6+6+6)*1*6*6*6*6*6*6+2+3+4+5+6+7+8+9+10+11+12+13+14";
        Formula formula = new Formula();
        formula.setDoProcessing(true);
        
        WidthProcessor p = new WidthProcessor(formula);
        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 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:

Sets the number of children viewed.

Parameters:
thenumber of children viewed.

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

Definition at line 94 of file WidthProcessor.java.

                                  {
        this.view = view;
    }

Here is the caller graph for this function:

Sets the width 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:
widthLevelthe width level.

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

Definition at line 77 of file WidthProcessor.java.

                                              {
        setLevel(widthLevel);
    }

Here is the call 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.

Check if the current list of Strahler numbers in the formula is valid or not.

Definition at line 55 of file WidthProcessor.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 number of children viewed.


Should be a positive value. If equals to -1, then all children have to be displayed. This is the default value.

Definition at line 62 of file WidthProcessor.java.

The list of widths numbers in the formula.

Definition at line 50 of file WidthProcessor.java.


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