1 package isac.gui.mawen.editor;
3 import isac.gui.mawen.syntax.Ast;
4 import isac.interfaces.IEditor;
7 import java.util.ArrayList;
11 * Manages the editor for one formula represented by an <code>Ast</code>
12 * in the <code>Worksheet</code>.
14 public class EditorPanel extends JPanel implements IEditor {
16 private static final long serialVersionUID = 1L;
17 protected ArrayList<EditorListener> listeners;
18 private JComponent component;
20 /*err*/public EditorPanel(Ast.Ast ast) {
21 listeners = new ArrayList<EditorListener>();
22 LayoutManager overlay = new OverlayLayout(this);
23 this.setBackground(Color.GREEN);
25 component = CalcUtil.assembleComponent(ast);
26 EditorListenerHandler.addListenerHandler((IEditor)this, (AstContainer)component);
30 public JComponent getComponent() {
34 public void setFormula(String formula) {
35 System.out.println(formula);
38 /*err*/public void setFormula(isac.gui.mawen.syntax.Ast.Ast formula) {
39 ((AstComponent)component).setAst(formula);
41 /*err*/public isac.gui.mawen.syntax.Ast.Ast getFormula() {
42 /*err*/return ((AstComponent)component).getAst();
44 public void addEditorListener(EditorListener l) {
47 public void removeEditorListener(EditorListener l) {
50 public void fireNotifyLocalCheck() {
51 for(EditorListener l : listeners) {
55 public void fireNotifyIsaCheck() {
56 for(EditorListener l : listeners) {
60 /*err*/public void fireNotifyBraille(Ast.Ast formula) {
61 for(EditorListener l : listeners) {
62 l.notifyBraille(formula);
66 public Dimension getExpressionSize() {
67 return new Dimension(Math.max(component.getSize().width, 50), Math.max(component.getSize().height, 50)) ;
70 public boolean setEditable() {
74 public String getMathText() {
75 /*err*/System.out.println(isac.gui.mawen.syntax.Ast$.MODULE$.math_string_of(getFormula()));
76 /*err*/return Ast.math_string_of(getFormula() );