Back to index

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

A layout manager that lays components horyzontally, but the last one in the list, is treated as a superscript (there is an upward shitf). More...

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

List of all members.

Public Member Functions

Dimension computeAttributes ()
 Computes the size of the display according to its children size (if any), and its different attributes.
void updateLevel (int level)
 Updates the level of the display that is layed out.
void validateSelection ()
 Checks the validity of the selection.
void validateDeselection (Display display)
 Checks the validity of the deselection.
void rebuildDisplay ()
 The display needs to be rebuilt.
void layoutContainer (Container parent)
void initDisplay (Display displayToLay)
 According to the operator, the layout manager has to add some components (e.g.
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 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.

Private Member Functions

int computeExponentShift (Display base, Display script)
 Computes the shift of the script display.

Detailed Description

A layout manager that lays components horyzontally, but the last one in the list, is treated as a superscript (there is an upward shitf).

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

Definition at line 45 of file SuperscriptLayout.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.HorizontalLayout.

Definition at line 51 of file SuperscriptLayout.java.

                                         {
        int ascent = 0;
        int descent = 0;
        int width = 0;
        int height = 0;
        
        Display base, exponent;
        int decalage = 0;
        
        base = (Display) displayToLay.getComponent(0);
        base.setSize(base.getPreferredSize());
        width += base.getWidth() + base.getShiftX();
        
        exponent = (Display) displayToLay.getComponent(1);

        if (base.getLayout() instanceof SuperscriptLayout)
            ((DisplayLayout) exponent.getLayout()).updateLevel(((Display) base.getComponent(1)).getLevel()+ 1);
        else
            ((DisplayLayout) exponent.getLayout()).updateLevel(base.getLevel()+ 1);
        
        exponent.setSize(exponent.getPreferredSize());
        
        if (base.getLayout() instanceof SuperscriptLayout) {
            Display exp_base = (Display) base.getComponent(1);
            decalage = computeExponentShift(exp_base, exponent);
        }
        else
            decalage = computeExponentShift(base, exponent);
        
        /* ############################# */
        base.setShiftY(0); // ATTENTION : rajout !!!!!!
        /* ############################# */

        exponent.setShiftY(-decalage);
        width += exponent.getWidth() + exponent.getShiftX();
                
        displayToLay.setDescent(base.getDescent()); 
        displayToLay.setAscent(decalage + exponent.getAscent());
        height += displayToLay.getAscent() + displayToLay.getDescent();
        displayToLay.setSize(width , height);
        
        displayToLay.setComputeAttributes(false);
        return new Dimension(width, height);
    }

Here is the call graph for this function:

Computes the shift of the script display.

Parameters:
basethe base of the script.
scriptthe script of the script.

Definition at line 101 of file SuperscriptLayout.java.

                                                                     {
        if (base instanceof StringDisplay)
            return (int) (Math.round(base.getAscent()*0.3)) + script.getDescent() -
                                     base.getShiftY();
        else 
            return (int) (Math.round(base.getAscent()*0.7)) + script.getDescent() -
                                     base.getShiftY();
    }

Here is the call graph for this function:

Here is the caller 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;
    }
void fr.ove.openmath.jome.ctrlview.bidim.DisplayLayout.initDisplay ( Display  displayToLay) [inline, inherited]

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 in fr.ove.openmath.jome.ctrlview.bidim.EnclosingLayout, fr.ove.openmath.jome.ctrlview.bidim.SuperposedOperatorLayout, fr.ove.openmath.jome.ctrlview.bidim.VarDiffLayout, fr.ove.openmath.jome.ctrlview.bidim.MapsArrayLayout, fr.ove.openmath.jome.ctrlview.bidim.MapsToSigmaLayout, fr.ove.openmath.jome.ctrlview.bidim.IntegralLayout, fr.ove.openmath.jome.ctrlview.bidim.Mfd2SubstitutionLayout, fr.ove.openmath.jome.ctrlview.bidim.HorizontalListLayout, fr.ove.openmath.jome.ctrlview.bidim.DifferentiationLayout, fr.ove.openmath.jome.ctrlview.bidim.IntervalLayout, fr.ove.openmath.jome.ctrlview.bidim.LambdaExpLayout, fr.ove.openmath.jome.ctrlview.bidim.BetweenOperatorLayout, fr.ove.openmath.jome.ctrlview.bidim.EnumerationLayout, fr.ove.openmath.jome.ctrlview.bidim.FunctionLayout, fr.ove.openmath.jome.ctrlview.bidim.RootLayout, fr.ove.openmath.jome.ctrlview.bidim.LimitLayout, and fr.ove.openmath.jome.ctrlview.bidim.UnaryOperatorLayout.

Definition at line 58 of file DisplayLayout.java.

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.

                                                   {
    }
void fr.ove.openmath.jome.ctrlview.bidim.HorizontalLayout.layoutContainer ( Container  parent) [inline, inherited]

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

Definition at line 95 of file HorizontalLayout.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());

            if (i == 0)
                x = display.getShiftX();
            else {
                previous = (Display) parent.getComponent(i-1);
                x = previous.getX() + previous.getWidth() + display.getShiftX();
            }

            y = ((Display) parent).getAscent() - display.getAscent() + 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 165 of file ScriptLayout.java.

                                 {
        Display tmp;
        Display base = null;
        Display script = null;
        // On parcourre la liste des displays pour trouver qui est qui.
        for (int i = 0; i < 2; i++) {
            tmp = (Display) displayToLay.getComponent(i);
            // On fait les initialisations qui s'imposent pour le bon repositionnement de chacun.
            tmp.setLocation(0,0);
            if (((FormulaTreeStructure) tmp.getListener()).getRank() == 0)
                base = tmp;
            else 
                script = tmp;
        }
        // On a retrouvé qui est qui, on reconstruit le display pour tout mettre
        // à la bonne position.
        displayToLay.removeAllDisplays();
        displayToLay.add(base);
        displayToLay.add(script);
        // 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.ScriptLayout.updateLevel ( int  level) [inline, inherited]

Updates the level of the display that is layed out.


Parameters:
levelthe level put to the display

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

Definition at line 51 of file ScriptLayout.java.

                                       {
        Display tmp;
        
        // Pour éviter de refaire le calcul plusieurs fois....
        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 premier display fils possède le même niveau que son père.
            tmp = (Display) displayToLay.getComponent(0);
            ((DisplayLayout) tmp.getLayout()).updateLevel(level);
            
            // Le deuxième display fils possède le même niveau que la base + 1.
            // (on applique une réduction de taille)
            tmp = (Display) displayToLay.getComponent(1);
            ((DisplayLayout) tmp.getLayout()).updateLevel(level+1);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void fr.ove.openmath.jome.ctrlview.bidim.ScriptLayout.validateDeselection ( Display  display) [inline, virtual, inherited]

Checks the validity of the deselection.

Parameters:
displaythe display to deselect.

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

Definition at line 117 of file ScriptLayout.java.

                                                     {
        Display tmp;
        SelectionEvent selEvt = new SelectionEvent(displayToLay);
        
        if (displayToLay.isSelected()) {
            // On désélectionne la puissance
            displayToLay.setNotSelected();
            // On enlève le display père de la liste des display sélectionnés.
            selEvt.setAction(SelectionEvent.REMOVE, displayToLay);
            displayToLay.fireSelectionEvent(selEvt);
            
            // Si la puissance toute entière était sélectionnée, donc présente dans la liste
            // des éléments sélectionné. Ce n'est pas le cas de la base et de l'exposant.
            // Donc en fonction de cela, il faut y ajouter l'élément adéquat
            if (((Display) displayToLay.getComponent(0)).isSelected())
                // On a demandé la désélection en cliquant sur l'exposant, ce qui revient
                // à sélectionner uniquement la base.
                // On l'ajoute donc dans la liste des display sélectionnés.
                selEvt.setAction(SelectionEvent.ADD, (Display) displayToLay.getComponent(0));
            else
                // On a demandé la désélection en cliquant sur la base, ce qui revient
                // à sélectionner uniquement l'exposant.
                // On l'ajoute donc dans la liste des display sélectionnés.
                selEvt.setAction(SelectionEvent.ADD, (Display) displayToLay.getComponent(1));

            displayToLay.fireSelectionEvent(selEvt);

            // Comme pour la sélection, on contrôle la validité de la désélection.
            Display father = displayToLay;
            if (displayToLay.getParent() instanceof Display) {
                father = (Display) displayToLay.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 77 of file ScriptLayout.java.

                                    {
        SelectionEvent selEvt = new SelectionEvent(displayToLay);

        // La validité de la sélection est triviale.
        // Si un des éléments de la puissance est sélectionné, alors la sélection
        // de l'autre élément entraîne la sélection de toute la puissance.
        Display base = (Display) displayToLay.getComponent(0);
        Display script = (Display) displayToLay.getComponent(1);
        if (base.gotSelectedElements() && script.gotSelectedElements()) {
            displayToLay.select();
            // On purge la liste des éléments sélectionnés.
            selEvt.setAction(SelectionEvent.PURGE, null);
            displayToLay.fireSelectionEvent(selEvt);
            // On y ajoute notre puissance.
            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.
        // Ex : on a l'expression A+B^C et on a A déjà sélectionné. On sélectionne C.
        // D'un pt de vue sémantique (oui, on va dire ça comme ça) A et C ne peuvent
        // être sélectionnés séparément. Tout doit être sélectionné. Et ça, c'est la 
        // validation de la sélection qui va le déterminer. oufff....
        Display display = displayToLay;
        if (displayToLay.getParent() instanceof Display) {
            display = (Display) displayToLay.getParent();
            FormulaTreeStructure fts = (FormulaTreeStructure) display.getListener();
            if (fts.getFather() != null) // Si fts n'est pas la racine de la formule, on valide la sélection
                ((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: