Back to index

wims  3.65+svn20090927
Public Member Functions | Protected Attributes
fr.ove.openmath.jome.ctrlview.bidim.StringBetweenOperatorLayout Class Reference

Layout manager that lays the display of an operator whose symbol is located between its 2 operands. More...

Inheritance diagram for fr.ove.openmath.jome.ctrlview.bidim.StringBetweenOperatorLayout:
Inheritance graph
[legend]
Collaboration diagram for fr.ove.openmath.jome.ctrlview.bidim.StringBetweenOperatorLayout:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Display createOperatorDisplay ()
 Returns the display of the operator.
void initDisplay (Display displayToLay)
 According to the operator, the layout manager has to add some components (e.g.
void validateSelection ()
 Checks the validity of the selection.
void validateDeselection (Display display)
 Checks the validity of the deselection.
Dimension computeAttributes ()
 Computes the size of the display according to its children size (if any), and its different attributes.
void rebuildDisplay ()
 The display needs to be rebuilt.
void layoutContainer (Container parent)
boolean selectLeftDisplay ()
 Returns true if during the selection, the display which is located to the left of the display that the instance lays, must be selected too.
boolean selectRightDisplay ()
 Returns true if during the selection, the display which is located to the right of the display that the instance lays, must be selected too.
void selectDisplay ()
 Selects the display (and its children if any)
void deselectDisplay ()
 Deselects the display.
void updateLevel (int level)
 Updates the level of the display laid out.
void addLayoutComponent (String name, Component comp)
 Adds the specified component with the specified name to the layout.
void addLayoutComponent (Component comp, Object constraints)
 Adds the specified component to the layout, using the specified constraint object.
void removeLayoutComponent (Component comp)
 Removes the specified component from the layout.
Dimension minimumLayoutSize (Container parent)
 Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
Dimension preferredLayoutSize (Container parent)
 Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
Dimension maximumLayoutSize (Container target)
 Returns the maximum size of this component.
float getLayoutAlignmentX (Container target)
 Returns the alignment along the x axis.
float getLayoutAlignmentY (Container target)
 Returns the alignment along the y axis.
void invalidateLayout (Container target)
 Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Protected Attributes

Display displayToLay = null
 The display laid out by the instance.

Detailed Description

Layout manager that lays the display of an operator whose symbol is located between its 2 operands.


Rendering is done vertically, the first operand on top, the symbol in the middle and the second operand under the 2 previous.
The symbol is rendered with a simple string.

Author:
© 1999 DIRAT Laurent
Version:
2.0 15/12/1999

Definition at line 44 of file StringBetweenOperatorLayout.java.


Member Function Documentation

void fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.addLayoutComponent ( String  name,
Component  comp 
) [inline, inherited]

Adds the specified component with the specified name to the layout.

Parameters:
namethe component name
compthe component to be added

Definition at line 189 of file DisplayLayout.java.

                                                                {
    }
void fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.addLayoutComponent ( Component  comp,
Object  constraints 
) [inline, inherited]

Adds the specified component to the layout, using the specified constraint object.

Parameters:
compthe component to be added
constraintswhere/how the component is added to the layout.

Definition at line 236 of file DisplayLayout.java.

                                                                       {
           if (!(constraints instanceof Display))
              throw new IllegalArgumentException("The component to add must be a Display instance !!!");
    }

Computes the size of the display according to its children size (if any), and its different attributes.

Returns:
the size of the display.

Reimplemented from fr.ove.openmath.jome.ctrlview.bidim.VerticalCenteredLayout.

Reimplemented in fr.ove.openmath.jome.ctrlview.bidim.FractionLayout.

Definition at line 165 of file BetweenOperatorLayout.java.

                                         {
        Display displayOperator = (Display) displayToLay.getComponent(0);
        Display topOperand = (Display) displayToLay.getComponent(1);
        Display bottomOperand = (Display) displayToLay.getComponent(2);
        // Initialisation de ces paramètres pour annuler les (éventuelles) précédentes valeurs prises.
        displayOperator.setShiftY(0);
        topOperand.setShiftY(0);
        bottomOperand.setShiftY(0);

        // On calcule les attributs des display enfants comme si on avait affaire à un VerticalCenteredLayout.
        // La différece réside dans le fait qu'il faut faire en sorte que le display de l'opérateur soit affiché
        // entre les opérandes
        Dimension dim = super.computeAttributes(); 
        

        // Cette taille là correspond au décalage qu'il faut appliquer à la barre de fraction
        displayOperator.setShiftY(topOperand.getHeight());
        // Mais il faut l'enlever au display du numérateur
        topOperand.setShiftY(-displayOperator.getShiftY() - displayOperator.getHeight());
        bottomOperand.setShiftY(displayOperator.getHeight());
        
        // On met la baseline de la fraction sur celle de la barre de fraction + qque broutilles qui
        // correspondent à où se trouve la barre horizontale du +
        int ascent = displayToLay.getFontMetrics(displayToLay.getFont()).getAscent();
        ascent = (int) Math.round(((float) ascent)*0.388f);
        
        ascent += topOperand.getShiftY() + topOperand.getHeight() + 
                 displayOperator.getShiftY() + displayOperator.getAscent();
        
        displayToLay.setAscent(ascent);
        displayToLay.setDescent(dim.height - ascent);
        
        displayToLay.setComputeAttributes(false);
        
        return dim;
    }

Here is the call graph for this function:

Returns the display of the operator.

Implements fr.ove.openmath.jome.ctrlview.bidim.OperatorDisplayCreator.

Definition at line 48 of file StringBetweenOperatorLayout.java.

                                           {
        Operator fts = (Operator) displayToLay.getListener();
        // On créé un display pour l'opérateur.
        StringDisplay stringDisplay = new StringDisplay(displayToLay.getGraphicContext(), fts.getTheOperator(), true);
        
        return stringDisplay;
    }

Here is the call graph for this function:

Deselects the display.

Parameters:
thedisplay to deselect.

Reimplemented in fr.ove.openmath.jome.ctrlview.bidim.OneFormulaLayout.

Definition at line 107 of file DisplayLayout.java.

                                  {
        displayToLay.deselect();

        SelectionEvent selEvt = new SelectionEvent(displayToLay);
        selEvt.setAction(SelectionEvent.REMOVE, displayToLay);
        displayToLay.fireSelectionEvent(selEvt);
        
        if (displayToLay.getParent() instanceof Display) {
            Display display = (Display) displayToLay.getParent();
            ((DisplayLayout) display.getLayout()).validateDeselection(displayToLay);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

float fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.getLayoutAlignmentX ( Container  target) [inline, inherited]

Returns the alignment along the x axis.

This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Definition at line 258 of file DisplayLayout.java.

                                                       {
        return 0.0f;
    }
float fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.getLayoutAlignmentY ( Container  target) [inline, inherited]

Returns the alignment along the y axis.

This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Definition at line 269 of file DisplayLayout.java.

                                                       {
        return 0.0f;
    }

According to the operator, the layout manager has to add some components (e.g.

brackets, ...) or has to perform some "re-oganisation" before rendering.
As soon as the layout manager is set to the display, this mehtod MUST be called with the display laid out as parameter. This method serves as well as a registering method. So all sub-classes of the instance MUST call super.initDisplay(displayToLay).

Parameters:
displayToLaythe display laid by the instance

Reimplemented from fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.

Definition at line 53 of file BetweenOperatorLayout.java.

                                                  {
        super.initDisplay(displayToLay);
        Display operatorDisplay = createOperatorDisplay();

        // On met un listener au display de l'opérateur
        // En fait, il n'y en a pas besoin, dans le sens où il n'y a pas spécifiquement de fts qui
        // écoute le comportement de ce display. Néanmoins, il s'avère nécessaire qu'il en ait
        // un, par exemple lors de l'iconification, car c'est le display qui reçoit la demande
        // d'iconification qui envoie l'événement correspondant à la FTS. Or si ce display n'a pas
        // d'écouteur, alors pb. Par cohérence, l'écouteur du display d'opérateur, est le fts qui
        // représente cette opération. Par contre, la fts en question, n'écoute pas le display
        // d'opérateur.
        operatorDisplay.addControlListener((FormulaTreeStructure) displayToLay.getListener());
        this.displayToLay.add(operatorDisplay);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.invalidateLayout ( Container  target) [inline, inherited]

Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Definition at line 277 of file DisplayLayout.java.

                                                   {
    }

Definition at line 103 of file VerticalCenteredLayout.java.

                                                   {
        int x, y;
        Display display, previous;
        
        int count = parent.getComponentCount();
        for ( int i = 0; i < count; i++ ) {
            display = (Display) parent.getComponent(i);
            
            display.setSize(display.getPreferredSize());
            
            x = (((Display) parent).getWidth() / 2) -
                (display.getWidth() / 2) +
                display.getShiftX();
            
            if ( i == 0 )
                y = display.getShiftY();
            else {
                previous = (Display) parent.getComponent(i-1);
                y = previous.getY() + previous.getHeight() + display.getShiftY();
            }
            
            display.setLocation(x, y);
            
            // On place maintenant les éventuels display enfants du display courant
            display.doLayout();
        }
    }

Here is the call graph for this function:

Dimension fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.maximumLayoutSize ( Container  target) [inline, inherited]

Returns the maximum size of this component.

See also:
java.awt.Component::getMinimumSize()
java.awt.Component::getPreferredSize()
LayoutManager

Definition at line 247 of file DisplayLayout.java.

                                                         {
        return preferredLayoutSize(target);
    }

Here is the call graph for this function:

Dimension fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.minimumLayoutSize ( Container  parent) [inline, inherited]

Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.

Parameters:
parentthe component to be laid out
See also:
preferredLayoutSize

Definition at line 205 of file DisplayLayout.java.

                                                         {
        return preferredLayoutSize(parent);
    }

Here is the call graph for this function:

Dimension fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.preferredLayoutSize ( Container  parent) [inline, inherited]

Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.

Parameters:
parentthe component to be laid out
See also:
minimumLayoutSize

Definition at line 216 of file DisplayLayout.java.

                                                           {
        if (((Display) parent).getComputeAttributes())
            return computeAttributes();
        else
            return parent.getSize();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

The display needs to be rebuilt.

We do this.

Implements fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.

Definition at line 205 of file BetweenOperatorLayout.java.

                                 {
        Display tmp;
        Display listDisplay[] = new Display[2];
        
        for (int i = 1; i <= 2; i++) {
            tmp = (Display) displayToLay.getComponent(i);
            tmp.setLocation(0,0);
            listDisplay[((FormulaTreeStructure) tmp.getListener()).getRank()] = tmp;
        }
        
        // On garde un référence sur le display du symbole l'opérateur
        tmp = (Display) displayToLay.getComponent(0);
        // On fait en sorte que temporairement ce display ne soit pas considéré comme un
        // display d'opérateur, sinon il serait supprimé de la liste des listeners de la fts,
        // chose qu'on ne veut pas puisque qu'on va le remettre à sa place.
        tmp.setIsSymbolOperatorDisplay(false);
        
        // ATTENTION : ici, on enlève les displays fils de display, mais on ne les enlève pas de la liste
        // des listeners de la fts qu'il sont en train d'écouter.
        displayToLay.removeAllDisplays();
        
        // On remet tmp comme étant un display d'opérateur
        tmp.setIsSymbolOperatorDisplay(true);
        // On le rajoute dans displayToLay à sa position (la première)
        displayToLay.add(tmp);
                
        for (int i = 0; i < 2; i++)
            displayToLay.add(listDisplay[i]);
        
        // La taille des displays est probablement différente de ceux qui étaient
        // précédemment. On demande alors le recalcul des display ancêtres.
        displayToLay.computeAncestorsAttributes();
    }

Here is the call graph for this function:

Removes the specified component from the layout.

Parameters:
compthe component ot be removed

Definition at line 196 of file DisplayLayout.java.

                                                      {
    }

Selects the display (and its children if any)

Parameters:
thedisplay to select.

Reimplemented in fr.ove.openmath.jome.ctrlview.bidim.OneFormulaLayout.

Definition at line 85 of file DisplayLayout.java.

                                {
        displayToLay.select();
        
        SelectionEvent selEvt = new SelectionEvent(displayToLay);
        // On purge la liste des éléments sélectionnés.
        selEvt.setAction(SelectionEvent.PURGE, null);
        displayToLay.fireSelectionEvent(selEvt);
        selEvt.setAction(SelectionEvent.ADD, displayToLay);
        displayToLay.fireSelectionEvent(selEvt);
        
        Display display = displayToLay;
        if (displayToLay.getParent() instanceof Display) {
            display = (Display) displayToLay.getParent();
            ((DisplayLayout) display.getLayout()).validateSelection();
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Returns true if during the selection, the display which is located to the left of the display that the instance lays, must be selected too.

false otherwise.

Reimplemented in fr.ove.openmath.jome.ctrlview.bidim.LeftAssocPrefixedUnaryOperatorLayout, and fr.ove.openmath.jome.ctrlview.bidim.StringLayout.

Definition at line 68 of file DisplayLayout.java.

                                       {
        return false;
    }

Here is the caller graph for this function:

Returns true if during the selection, the display which is located to the right of the display that the instance lays, must be selected too.

false otherwise.

Reimplemented in fr.ove.openmath.jome.ctrlview.bidim.StringLayout.

Definition at line 77 of file DisplayLayout.java.

                                        {
        return false;
    }

Here is the caller graph for this function:

void fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.updateLevel ( int  level) [inline, inherited]

Updates the level of the display laid out.

Parameters:
displaythe display laid out
levelthe level put to the display.

Reimplemented in fr.ove.openmath.jome.ctrlview.bidim.LimitLayout, fr.ove.openmath.jome.ctrlview.bidim.RootLayout, fr.ove.openmath.jome.ctrlview.bidim.IntegralLayout, fr.ove.openmath.jome.ctrlview.bidim.MapsArrayLayout, fr.ove.openmath.jome.ctrlview.bidim.MapsToSigmaLayout, fr.ove.openmath.jome.ctrlview.bidim.ScriptLayout, and fr.ove.openmath.jome.ctrlview.bidim.AbstractStringLayout.

Definition at line 126 of file DisplayLayout.java.

                                       {
        Display tmp;
        
        if (displayToLay.getUpdateLevel()) {
            // On met le niveau adéquat
            displayToLay.setLevel(level);
            // On scale le display en fonction du niveau
            displayToLay.scaleDisplay();
            // On n'a plus besoin de mettre à jour le niveau de l'instance
            displayToLay.setUpdateLevel(false);
            // Le comportement par défaut est que les displays enfant de l'instance courante
            // ont le même niveau que leur père.
            int count = displayToLay.getComponentCount();
            for (int i = 0; i < count; i++) {
                tmp = (Display) displayToLay.getComponent(i);
                ((DisplayLayout) tmp.getLayout()).updateLevel(level);
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Checks the validity of the deselection.

Parameters:
displaythe display to deselect.

Implements fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.

Definition at line 111 of file BetweenOperatorLayout.java.

                                                     {
        Display father = displayToLay;
        SelectionEvent selEvt = new SelectionEvent(father);
        
        // Si la fraction est sélectionnée, alors il faut la déselectionner.
        if (father.isSelected()) {
            father.setNotSelected();
            // On enlève le display père de la liste des display sélectionnés.
            selEvt.setAction(SelectionEvent.REMOVE, father);
            father.fireSelectionEvent(selEvt);
            
            Display operatorDisplay = (Display) father.getComponent(0);
            Display operand1 = (Display) father.getComponent(1);
            Display operand2 = (Display) father.getComponent(2);
            
            if (display == operand1) {
                operatorDisplay.setNotSelected();
                selEvt.setAction(SelectionEvent.ADD, operand2);
                father.fireSelectionEvent(selEvt);
            }
            else if (display == operand2) {
                operatorDisplay.setNotSelected();
                selEvt.setAction(SelectionEvent.ADD, operand1);
                father.fireSelectionEvent(selEvt);
            }
            else {
                operand1.deselect();
                operatorDisplay.setNotSelected();
                operand2.deselect();
            }

            // Comme pour la sélection, on contrôle la validité de la désélection.
            if (father.getParent() instanceof Display) {
                father = (Display) father.getParent();
                FormulaTreeStructure fts = (FormulaTreeStructure) father.getListener();
                if (fts.getFather() != null)
                    ((DisplayLayout) father.getLayout()).validateDeselection(displayToLay);
            }
            
            // Hé oui, on contrôle la validité de la sélection... dans une désélection.
            // Toujours le même pb, est-ce que le nouvel état de la sélection (après
            // désélection donc) est syntaxiquement cohérent ?
            validateSelection();
            
            // On met à jour l'affichage.
            father.repaint();
        }        
    }

Here is the call graph for this function:

Checks the validity of the selection.

Implements fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.

Definition at line 72 of file BetweenOperatorLayout.java.

                                    {
        SelectionEvent selEvt = new SelectionEvent(displayToLay);

        // La validité de la sélection est triviale.
        // Si les 2 opérandes sont sélectionnés, ou si le symbole de l'opérateur est sélectionné,
        // alors on sélectionne tout.
        Display operatorDisplay = (Display) displayToLay.getComponent(0);
        Display operand1 = (Display) displayToLay.getComponent(1);
        Display operand2 = (Display) displayToLay.getComponent(2);
        if ((operand1.gotSelectedElements() && operand2.gotSelectedElements()) ||
            (operatorDisplay.isSelected())) {
            // Sélectionne le display.
            displayToLay.select();
            // On purge la liste des éléments sélectionnés.
            selEvt.setAction(SelectionEvent.PURGE, null);
            displayToLay.fireSelectionEvent(selEvt);
            // On y ajoute os parenthèses
            selEvt.setAction(SelectionEvent.ADD, displayToLay);
            displayToLay.fireSelectionEvent(selEvt);
        }

        // On a vérifié la validité de la sélection de la puissance. On doit maitenant
        // la contrôler au niveau supérieur, au niveau du père.
        Display display = displayToLay;
        if (display.getParent() instanceof Display) {
            display = (Display) display.getParent();
            FormulaTreeStructure fts = (FormulaTreeStructure) display.getListener();
            if (fts.getFather() != null)
                ((DisplayLayout) display.getLayout()).validateSelection();
        }

        // On met à jour l'affichage.
        display.repaint();
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

The display laid out by the instance.

Definition at line 47 of file DisplayLayout.java.


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