1.1 --- a/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala Tue Sep 12 13:34:41 2017 +0200
1.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala Tue Sep 12 14:33:21 2017 +0200
1.3 @@ -24,10 +24,8 @@
1.4 addMouseMotionListener(this)
1.5 var pressedMousePoint : Point = null
1.6 var marker : Rectangle = new Rectangle()
1.7 - //list of boxes touched by mouse while drawing a rectangle; the outmost is relevant
1.8 + // list of boxes touched by mouse while drawing a rectangle; the outmost is relevant
1.9 var markedBoxes : List[DrawBox] = List.empty[DrawBox]
1.10 - // TODOWN
1.11 - var mousePositionFunction : (Graphics, Int, Int, String, Box) => Unit = null
1.12 var box : DrawBox = null
1.13 setFocusable(true)
1.14 addKeyListener(EventUtil.CreateKeyEventHandler(this))
1.15 @@ -122,8 +120,6 @@
1.16 repaint()
1.17 }
1.18 );
1.19 - }else {
1.20 - mousePositionFunction = null
1.21 }
1.22 repaint()
1.23 }
2.1 --- a/isac-java/src/java/isac/gui/mawen/editor/AstInfoUtil.scala Tue Sep 12 13:34:41 2017 +0200
2.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/AstInfoUtil.scala Tue Sep 12 14:33:21 2017 +0200
2.3 @@ -108,7 +108,7 @@
2.4 }
2.5 case ast => None
2.6 }
2.7 - //TODOWN ..: Option[Ast] = ...
2.8 + // introducing Option[Ast] would cause delicate changes
2.9 def FindCursor(ast: Ast) : Ast = ast match {
2.10 case Appl(List(Constant("CURSOR"), a)) => ast
2.11 case Appl(List(a, Constant("CURSOR"))) => ast
2.12 @@ -121,7 +121,7 @@
2.13 }
2.14 case ast => null
2.15 }
2.16 - //TODOWN ..: Option[Ast] = ...
2.17 + // introducing Option[Ast] would cause delicate changes
2.18 def AstOfCursor(ast: Ast) : Ast = ast match {
2.19 case Appl(List(Constant("CURSOR"), a)) => a
2.20 case Appl(List(a, Constant("CURSOR"))) => a
3.1 --- a/isac-java/src/java/isac/gui/mawen/editor/Box.scala Tue Sep 12 13:34:41 2017 +0200
3.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/Box.scala Tue Sep 12 14:33:21 2017 +0200
3.3 @@ -33,19 +33,23 @@
3.4 def Contains(parent: DrawBox, box: DrawBox) : Boolean =
3.5 box == parent || parent.children.exists( y => Contains(y, box))
3.6
3.7 - def draw(b: DrawBox, g: Graphics) : Unit = draw(b, g, true)
3.8 + /*
3.9 + * draw a box around an <code>Ast</code>
3.10 + */
3.11 + def draw(b: DrawBox, g: Graphics) : Unit = draw(b, g, true) //save a param.
3.12 def draw(b: DrawBox, g: Graphics, withChildren: Boolean) : Unit = {
3.13 g.drawRect(b.x, b.y - b.height, b.width, b.height)
3.14 if (withChildren) b.children.foreach(draw(_,g))
3.15 }
3.16 // draw a box around an <code>Ast</code>
3.17 - def drawBox(b: DrawBox, g: Graphics) {
3.18 + def drawFrame(b: DrawBox, g: Graphics) {
3.19 if (b.isBoxed) {
3.20 g.setColor(Settings.CollorMapping(b.colorCode))
3.21 g.drawRect(b.x, b.y - b.height, b.width, b.height)
3.22 g.setColor(java.awt.Color.BLACK)
3.23 }
3.24 }
3.25 +
3.26 def BoxIn(b: DrawBox, rect: Rectangle) : Boolean =
3.27 rect.contains(b.x, b.y) || rect.contains(b.x + b.width, b.y) ||
3.28 rect.contains(b.x, b.y + b.height) || rect.contains(b.x + b.width, b.y + b.height)
4.1 --- a/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala Tue Sep 12 13:34:41 2017 +0200
4.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala Tue Sep 12 14:33:21 2017 +0200
4.3 @@ -22,20 +22,19 @@
4.4 def draw(box : DrawBox, g: Graphics) : Unit = box.name match {
4.5 case "GAP" => drawGap(g, box)
4.6 case "CURSOR" => drawCursor(g, box)
4.7 - case "Groups.plus_class.plus" => drawPlus(g, box) //TODOWN "+"
4.8 - case "Fields.inverse_class.divide" => drawDivide(g, box) //TODOWN "/"
4.9 case "" => {
4.10 - drawBox(box, g)
4.11 + drawFrame(box, g)
4.12 box.children.foreach( draw(_, g) )
4.13 }
4.14 + case str if XSyntax.ast_isa(str) == "/" => drawFraction(g, box)
4.15 case _ => {
4.16 - drawString(g, box)
4.17 + drawBoxContent(g, box)
4.18 box.children.foreach( draw(_, g) )
4.19 }
4.20 }
4.21 def drawGap(g: Graphics, box : DrawBox) {
4.22 g.fillRoundRect(box.x, box.y- box.height, box.width, box.height, 15, 15)
4.23 - drawBox(box, g)
4.24 + drawFrame(box, g)
4.25 }
4.26 def drawCursor(g: Graphics, box : DrawBox) = System.currentTimeMillis() match {
4.27 case n if (n / 250) % 1 == 0 => box.ast match {
4.28 @@ -62,33 +61,24 @@
4.29 draw(box.children.head, g)
4.30 }
4.31 }
4.32 - // TODOWN layout_class "linear"
4.33 - def drawPlus(g: Graphics, box : DrawBox) {
4.34 - val font_var = new Font("CMCSC8", Font.PLAIN, CalcUtil.fontsizeOf(box.level))
4.35 - g.setFont(font_var)
4.36 -
4.37 - g.drawString("+", box.x0, box.y0)
4.38 - drawBox(box, g)
4.39 + // different from <code>drawBoxContent</code> because of additional <code>drawLine</code>
4.40 + def drawFraction(g: Graphics, box : DrawBox) {
4.41 + g.drawLine(box.x, box.y, box.x + box.width, box.y)
4.42 + drawFrame(box, g)
4.43 }
4.44 - // TODOWN layout_class "fraction"
4.45 - def drawDivide(g: Graphics, box : DrawBox) {
4.46 - g.drawLine(box.x, box.y, box.x + box.width, box.y)
4.47 - drawBox(box, g)
4.48 - }
4.49 - // TODOWN <-?-> draw
4.50 - def drawString(g: Graphics, box : DrawBox) {
4.51 - // operator
4.52 + // draw a box, except <code>drawFraction</code>
4.53 + def drawBoxContent(g: Graphics, box : DrawBox) {
4.54 + // draw operators and parentheses
4.55 XSyntax.ast_const.get(box.name) match {
4.56 case Some((_,_,_,_, fontname, charIndex)) => {
4.57 // Operator
4.58 val font_var = new Font(fontname, Font.PLAIN, CalcUtil.fontsizeOf(box.level))
4.59 g.setFont(font_var)
4.60 g.drawString(charIndex.toChar.toString(), box.x0, box.y0)
4.61 - drawBox(box, g)
4.62 + drawFrame(box, g)
4.63 }
4.64 case None => {
4.65 -
4.66 - // Ident
4.67 + // draw numbers and identifiers
4.68 if (box.name.forall(c => EditingUtil.isNumber(c)) ) {
4.69 val font_var = new Font("AR PL KaitiM Big5", Font.PLAIN, CalcUtil.fontsizeOf(box.level))
4.70 g.setFont(font_var)
4.71 @@ -103,7 +93,7 @@
4.72 g.setFont(font_var)
4.73 }
4.74 g.drawString(box.name, box.x0, box.y0)
4.75 - drawBox(box, g)
4.76 + drawFrame(box, g)
4.77 }
4.78 }
4.79 }
5.1 --- a/isac-java/src/java/isac/gui/mawen/editor/CalcUtil.scala Tue Sep 12 13:34:41 2017 +0200
5.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/CalcUtil.scala Tue Sep 12 14:33:21 2017 +0200
5.3 @@ -60,8 +60,11 @@
5.4 case "Frac" => calcFrac( emptyBox, f)
5.5 case _ => calcDefault( operatorString, List(emptyBox.paramr, emptyBox.paraml), emptyBox.x0, emptyBox.y0, emptyBox.level, emptyBox.ast, f)
5.6 }
5.7 + /*
5.8 + * calc* calculates the size of a fram around <code>DrawBox</code> for
5.9 + */
5.10 // TODOWN rename f
5.11 - def calcVariable( emptybox: EmptyLeafOpBox, f:(DrawBox) => Unit) = {
5.12 + def calcVariable( emptybox: EmptyLeafOpBox, f:(DrawBox) => Unit): DrawBox = {
5.13 val level = emptybox.level
5.14 val x0 = emptybox.x0
5.15 val y0 = emptybox.y0
5.16 @@ -94,10 +97,10 @@
5.17 val ast = emptyBox.ast
5.18 val box : Rectangle = Settings.getStringBoundOf("xx", level, x0, y0) //getStringBounds(g.asInstanceOf[Graphics2D], "xx", x0, y0)
5.19 val b = new DrawBox("GAP", level, box.x, y0, box.width, fontWidthOf(fontsizeOf(level)),x0, y0, ast)
5.20 - f(b) // see mmahringer $4.3.1 p.53/54 and $4.3.2 p.56
5.21 + f(b) // see callback mmahringer $4.3.1 p.53/54 and $4.3.2 p.56
5.22 b
5.23 }
5.24 - // TODOWN why no f ?
5.25 + // NO f, because a frame does NOT accept a mouse interaction
5.26 def CalcBox( str: String, emptyBox: EmptyUniOpBox, f:(DrawBox) => Unit) = {
5.27 val box = assembleBoxesRec( new EmptyBox(emptyBox.level, emptyBox.x0, emptyBox.y0, emptyBox.param), f)
5.28 box.isBoxed = true