1.1 --- a/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala Thu Sep 07 09:41:06 2017 +0200
1.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala Thu Sep 07 10:43:41 2017 +0200
1.3 @@ -26,6 +26,7 @@
1.4 var marker : Rectangle = new Rectangle()
1.5 //list of boxes touched by mouse while drawing a rectangle; the outmost is relevant
1.6 var markedBoxes : List[DrawBox] = List.empty[DrawBox]
1.7 + // TODWN
1.8 var mousePositionFunction : (Graphics, Int, Int, String, Box) => Unit = null
1.9 var box : DrawBox = null
1.10 setFocusable(true)
2.1 --- a/isac-java/src/java/isac/gui/mawen/editor/Box.scala Thu Sep 07 09:41:06 2017 +0200
2.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/Box.scala Thu Sep 07 10:43:41 2017 +0200
2.3 @@ -38,6 +38,7 @@
2.4 g.drawRect(b.x, b.y - b.height, b.width, b.height)
2.5 if (withChildren) b.children.foreach(draw(_,g))
2.6 }
2.7 + // draw a box around an <code>Ast</code>
2.8 def drawBox(b: DrawBox, g: Graphics) {
2.9 if (b.isBoxed) {
2.10 g.setColor(Settings.CollorMapping(b.colorCode))
3.1 --- a/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala Thu Sep 07 09:41:06 2017 +0200
3.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala Thu Sep 07 10:43:41 2017 +0200
3.3 @@ -19,11 +19,12 @@
3.4 */
3.5 object BoxUtil {
3.6
3.7 + // TODOWN rename "draw"
3.8 def Draw(box : DrawBox, g: Graphics) : Unit = box.name match {
3.9 case "GAP" => drawGap(g, box)
3.10 case "CURSOR" => drawCursor(g, box)
3.11 - case "Groups.plus_class.plus" => drawPlus(g, box)
3.12 - case "Fields.inverse_class.divide" => drawDivide(g, box)
3.13 + case "Groups.plus_class.plus" => drawPlus(g, box) //TODOWN "+"
3.14 + case "Fields.inverse_class.divide" => drawDivide(g, box) //TODOWN "/"
3.15 case "" => {
3.16 drawBox(box, g)
3.17 box.children.foreach( Draw(_, g) )
3.18 @@ -62,6 +63,7 @@
3.19 Draw(box.children.head, g)
3.20 }
3.21 }
3.22 + // TODOWN layout_class "linear"
3.23 def drawPlus(g: Graphics, box : DrawBox) {
3.24 val font_var = new Font("CMCSC8", Font.PLAIN, CalcUtil.fontsizeOf(box.level))
3.25 g.setFont(font_var)
3.26 @@ -69,10 +71,12 @@
3.27 g.drawString("+", box.x0, box.y0)
3.28 drawBox(box, g)
3.29 }
3.30 + // TODOWN layout_class "fraction"
3.31 def drawDivide(g: Graphics, box : DrawBox) {
3.32 g.drawLine(box.x, box.y, box.x + box.width, box.y)
3.33 drawBox(box, g)
3.34 }
3.35 + // TODOWN <-?-> draw
3.36 def drawString(g: Graphics, box : DrawBox) {
3.37 // operator
3.38 XSyntax.ast_const.get(box.name) match {
3.39 @@ -96,16 +100,6 @@
3.40 drawBox(box, g)
3.41 }
3.42 }
3.43 -
3.44 }
3.45
3.46 -
3.47 -
3.48 -
3.49 -
3.50 -
3.51 -
3.52 -
3.53 -
3.54 -
3.55 }
3.56 \ No newline at end of file
4.1 --- a/isac-java/src/java/isac/gui/mawen/editor/CalcUtil.scala Thu Sep 07 09:41:06 2017 +0200
4.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/CalcUtil.scala Thu Sep 07 10:43:41 2017 +0200
4.3 @@ -12,7 +12,6 @@
4.4 import java.awt.Color
4.5 import javax.swing.JComponent
4.6 import javax.swing.Spring.HeightSpring
4.7 -import sun.font.FontScaler //WHY non-java ?
4.8
4.9 /**
4.10 * Calculate a <code>Box</code> for each leaf
5.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EditingUtil.scala Thu Sep 07 09:41:06 2017 +0200
5.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EditingUtil.scala Thu Sep 07 10:43:41 2017 +0200
5.3 @@ -8,9 +8,12 @@
5.4 * Edit a formulas listening to key events
5.5 * according to a state-transition-system
5.6 * described in mmahringer Fig.TODO.TODOWN.
5.7 + *
5.8 + * "State" in identifiers refer to this system.
5.9 */
5.10 object EditingUtil {
5.11
5.12 + // TODOWN rename
5.13 def parse(c: AstContainer, inputCode: Int) : Unit = {
5.14 val cursorAst = AstInfoUtil.FindCursor(c.getAst())
5.15 val cursorAstElem = AstInfoUtil.AstOfCursor(cursorAst)
5.16 @@ -112,32 +115,23 @@
5.17 c.setAst(TransformAstUtil.Update(c.getAst(), AstInfoUtil.Parent(c.getAst(), cursorAst), (a) => newOperatorAst))
5.18 None
5.19 }
5.20 -
5.21 }
5.22 -
5.23 -
5.24 -
5.25 -
5.26 -
5.27 def isNumber(ch: Integer) : Boolean = ch >= '0' && ch <= '9'
5.28 def isIdentifier(ch: Integer) : Boolean = (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')
5.29 - def isDelim(ch: Integer) : Boolean= List('+', '-', '*', '/', '(', '=').contains(ch)
5.30 - def isActionCode(code: Integer) : Boolean = code == -KeyEvent.VK_ENTER ||
5.31 - code == -KeyEvent.VK_LEFT ||
5.32 - code == -KeyEvent.VK_UP ||
5.33 - code == -KeyEvent.VK_RIGHT ||
5.34 - code == -KeyEvent.VK_DOWN ||
5.35 - code == -KeyEvent.VK_DELETE ||
5.36 - code == -KeyEvent.VK_F2
5.37 + def isDelim(ch: Integer) : Boolean = List('+', '-', '*', '/', '(', '=').contains(ch)
5.38 + def isActionCode(code: Integer) : Boolean =
5.39 + code == -KeyEvent.VK_ENTER ||
5.40 + code == -KeyEvent.VK_LEFT ||
5.41 + code == -KeyEvent.VK_UP ||
5.42 + code == -KeyEvent.VK_RIGHT ||
5.43 + code == -KeyEvent.VK_DOWN ||
5.44 + code == -KeyEvent.VK_DELETE ||
5.45 + code == -KeyEvent.VK_F2
5.46 //TODOWN rename to isLongOp
5.47 def isLongDelim(ch: String) : Boolean= Settings.layout.keys.filter(x => x.length() > 1).toList.contains(ch)
5.48 -
5.49 - //TODOWN delete
5.50 + //TODOWN ???
5.51 def OperatorToAst(ch: Character) : Ast = Settings.OperatorToAst(ch.toString())
5.52 -
5.53 -
5.54 -
5.55 -
5.56 + // TODOWN why only first ?
5.57 def ReplaceFirstGap(ast: Ast, replace: Ast) : Ast = ast match {
5.58 case Appl(Constant("GAP") :: asts) => Appl(replace :: asts)
5.59 case Appl(a :: Constant("GAP") :: asts) => Appl(a :: replace :: asts)
5.60 @@ -146,6 +140,4 @@
5.61 case a => a
5.62 }
5.63
5.64 -
5.65 -
5.66 }
5.67 \ No newline at end of file
6.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EditorListenerHandler.scala Thu Sep 07 09:41:06 2017 +0200
6.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EditorListenerHandler.scala Thu Sep 07 10:43:41 2017 +0200
6.3 @@ -1,7 +1,11 @@
6.4 package isac.gui.mawen.editor
6.5 +
6.6 import isac.gui.mawen.syntax.Ast;
6.7 import isac.interfaces.IEditor
6.8
6.9 +/**
6.10 + * TODOWN
6.11 + */
6.12 object EditorListenerHandler {
6.13
6.14 var editorInstances= Map.empty[AstContainer, IEditor]
7.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EditorPanel.java Thu Sep 07 09:41:06 2017 +0200
7.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EditorPanel.java Thu Sep 07 10:43:41 2017 +0200
7.3 @@ -35,10 +35,10 @@
7.4 System.out.println(formula);
7.5 }
7.6 @Override
7.7 -/*err*/public void setFormula(isac.gui.mawen.syntax.Ast.Ast formula) {
7.8 +/*err*/public void setFormula(Ast.Ast formula) {
7.9 ((AstComponent)component).setAst(formula);
7.10 }
7.11 -/*err*/public isac.gui.mawen.syntax.Ast.Ast getFormula() {
7.12 +/*err*/public Ast.Ast getFormula() {
7.13 /*err*/return ((AstComponent)component).getAst();
7.14 }
7.15 public void addEditorListener(EditorListener l) {
8.1 --- a/isac-java/src/java/isac/gui/mawen/editor/Settings.scala Thu Sep 07 09:41:06 2017 +0200
8.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/Settings.scala Thu Sep 07 10:43:41 2017 +0200
8.3 @@ -148,6 +148,7 @@
8.4 case None => str
8.5 }
8.6 }
8.7 + // TODOWN ??
8.8 def OperatorToAst(o: String) : Ast = layout.get(o) match {
8.9 case Some((_, _,a)) => a
8.10 case None => Appl(List(Constant(o), Constant("GAP")))
9.1 --- a/isac-java/src/java/isac/gui/mawen/editor/TransformAstUtil.scala Thu Sep 07 09:41:06 2017 +0200
9.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/TransformAstUtil.scala Thu Sep 07 10:43:41 2017 +0200
9.3 @@ -102,6 +102,11 @@
9.4 }
9.5 }
9.6 }
9.7 + /* replace a sub-Ast with another Ast.
9.8 + * <code>eq</code> could be replaced by carrying around
9.9 + * an integer-list as key in <code>Ast.add</code>
9.10 + * as shown in <code>TestAst.test_update</code>.
9.11 + */
9.12 def Update(root : Ast, replace : Ast, updatefunc: Ast => Ast ) : Ast = root match {
9.13 case Appl(List(a)) if a eq replace => Appl(List(updatefunc(replace)))
9.14 case Appl(a :: param) if a eq replace => Appl(List(updatefunc(replace)) ::: param)
10.1 --- a/isac-java/src/java/isac/interfaces/IEditor.java Thu Sep 07 09:41:06 2017 +0200
10.2 +++ b/isac-java/src/java/isac/interfaces/IEditor.java Thu Sep 07 10:43:41 2017 +0200
10.3 @@ -13,6 +13,8 @@
10.4 JComponent getComponent();
10.5
10.6 /*err*/void setFormula(Ast.Ast formula); // Java cannot distinguish betwenn class and object
10.7 +
10.8 + // <code>Formula</code> still contains a String in parallel to an Ast, removed eventually.
10.9 void setFormula(String formula);
10.10 /*err*/Ast.Ast getFormula();
10.11 String getMathText();