View Javadoc

1   package fr.ove.openmath.jome.ctrlview.bidim;
2   
3   import java.awt.*;
4   import java.awt.event.*;
5   import java.text.*;
6   import fr.ove.utils.NumberUtils;
7   import fr.ove.openmath.jome.ctrlview.bidim.StringLayout;
8   import fr.ove.openmath.jome.ctrlview.bidim.Display;
9   import fr.ove.openmath.jome.ctrlview.bidim.GraphicContext;
10  import fr.ove.openmath.jome.model.*;
11  import fr.ove.openmath.jome.model.events.ModelEvent;
12  
13  /***
14  * The display for subsitution of parts of a expression with frienfly name.
15  *
16  * @author © 1999 DIRAT Laurent
17  * @version 2.0  04/08/1999
18  */
19  public class SubstitutionDisplay extends AbstractStringDisplay {
20      /***
21      * The constructor.
22      * @param graphicContext the graphic context of the display.
23      * @param string the string to display
24      */
25      public SubstitutionDisplay(GraphicContext graphicContext, String string) {
26          super(graphicContext, string);
27          Font font = getFont();
28          font = new Font(font.getName(), Font.BOLD, font.getSize());
29          setFont(font);
30          
31          SubstitutionLayout layout = new SubstitutionLayout();
32          layout.initDisplay(this);
33          setLayout(layout);
34      }
35      
36      /***
37      * Consumes (i.e. treats) the event received from the model.
38      * @param modelEvent the event to consume.
39      */
40      public void consumeModelEvent(ModelEvent modelEvent) {
41          // En principe, c'est le seul ÈvÈnement que doit recevoir ce type de display
42          // De plus, forcÈment, le display reprÈsentÈ n'est pas le display d'un opÈrateur.
43          switch (modelEvent.getAction()) {
44              case ModelEvent.UPDATE :
45                  //System.out.println("ModelEvent.UPDATE : on update le StringDisplay");
46                  Icon src = (Icon) modelEvent.getSource();
47                  
48                  // On met ? jour le display.
49                  setString(src.getIconName());
50  
51                  computeAncestorsAttributes();
52                  invalidate();
53          }
54      }
55  }