reformat package isac.gui.mawen.editor
authorWalther Neuper <wneuper@ist.tugraz.at>
Wed, 06 Sep 2017 13:45:58 +0200
changeset 51993799cb07f123
parent 5195 7151cbfc9f54
child 5201 5c61af5d1fc8
reformat package isac.gui.mawen.editor
isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala
isac-java/src/java/isac/gui/mawen/editor/AstInfoUtil.scala
isac-java/src/java/isac/gui/mawen/editor/Box.scala
isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala
isac-java/src/java/isac/gui/mawen/editor/CalcUtil.scala
isac-java/src/java/isac/gui/mawen/editor/EditingUtil.scala
isac-java/src/java/isac/gui/mawen/editor/EditorPanel.java
isac-java/src/java/isac/gui/mawen/editor/EventUtil.scala
isac-java/src/java/isac/gui/mawen/editor/Settings.scala
isac-java/src/java/isac/gui/mawen/editor/TransformAstUtil.scala
     1.1 --- a/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala	Wed Sep 06 12:50:24 2017 +0200
     1.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala	Wed Sep 06 13:45:58 2017 +0200
     1.3 @@ -1,18 +1,19 @@
     1.4  package isac.gui.mawen.editor
     1.5  
     1.6 +import isac.gui.mawen.editor.Box.DrawBox
     1.7 +import isac.gui.mawen.syntax.Ast._
     1.8 +import isac.interfaces.IEditor
     1.9 +import edu.tum.cs.isabelle.api.Implementation
    1.10 +
    1.11  import javax.swing._
    1.12 -import isac.gui.mawen.syntax.Ast._
    1.13  import java.awt._
    1.14  import java.awt.geom._
    1.15  import java.awt.font._
    1.16 -import edu.tum.cs.isabelle.api.Implementation
    1.17  import java.awt.event._
    1.18  import java.awt.font._
    1.19 -import shapeless.Widen //WHY not java ?
    1.20  import org.drools.xml.ExtensibleXmlParser.Null
    1.21  import scala.collection.immutable.List
    1.22 -import isac.gui.mawen.editor.Box.DrawBox
    1.23 -import isac.interfaces.IEditor
    1.24 +import shapeless.Widen //WHY not java ?
    1.25  
    1.26  /**
    1.27   * The Java Swing component for a formula
    1.28 @@ -22,20 +23,15 @@
    1.29  
    1.30    addMouseListener(this)
    1.31    addMouseMotionListener(this)
    1.32 -  
    1.33    var pressedMousePoint : Point = null
    1.34    var marker : Rectangle = new Rectangle()
    1.35    //list of boxes touched by mouse while drawing a rectangle; the outmost is relevant 
    1.36    var markedBoxes : List[DrawBox] = List.empty[DrawBox]
    1.37 -
    1.38    var mousePositionFunction : (Graphics, Int, Int, String, Box) => Unit = null
    1.39 -  
    1.40    var box : DrawBox  = null
    1.41 -  
    1.42    setFocusable(true)
    1.43    addKeyListener(EventUtil.CreateKeyEventHandler(this))
    1.44    addMouseWheelListener(EventUtil.CreateMouseWheelHandler(this))
    1.45 -  
    1.46    setSize(50,150)
    1.47    
    1.48    new Thread(new Runnable() {
    1.49 @@ -52,32 +48,22 @@
    1.50      repaint()
    1.51    }
    1.52    def getAst() : Ast = this.ast
    1.53 -  
    1.54 -  
    1.55 +
    1.56    override def paint(g: Graphics) = {
    1.57      Settings.g = g
    1.58      val g2 = g.asInstanceOf[Graphics2D]
    1.59 -    
    1.60      // enable antialiasing for Text
    1.61      val rh = new RenderingHints(
    1.62        RenderingHints.KEY_TEXT_ANTIALIASING,
    1.63        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    1.64      g2.setRenderingHints(rh);
    1.65 -    
    1.66 -    
    1.67 -    
    1.68 -    
    1.69      // white background
    1.70      g.setColor(Color.WHITE)
    1.71      g.fillRect(0, 0, getWidth, getHeight)
    1.72 -    
    1.73 -    
    1.74      g.setColor(Color.BLACK)
    1.75      g.translate(Settings.translateX, Settings.translateY)
    1.76      g2.scale(Settings.zoom, Settings.zoom)
    1.77 -    
    1.78      Settings.fillStringbounds(ast, g2)
    1.79 -    
    1.80      box =  CalcUtil.assembleBoxes(ast, (box: DrawBox) => 
    1.81          {
    1.82            if (EventUtil.foreachBoxFunction != null) {
    1.83 @@ -85,29 +71,16 @@
    1.84            }
    1.85          }
    1.86        )
    1.87 -      
    1.88        BoxUtil.Draw(box , g)
    1.89 -      
    1.90        setSize((box.width * Settings.zoom).round + 50 + Settings.translateX, Math.max((box.height * Settings.zoom).round, 50)  + Settings.translateY)
    1.91        setPreferredSize(getSize)
    1.92 -      
    1.93 -      
    1.94 -      
    1.95        EventUtil.foreachBoxFunction = null
    1.96 -      
    1.97        g.drawRect(marker.x, marker.y, marker.width, marker.height)
    1.98    }
    1.99 -  
   1.100 -  
   1.101 +
   1.102    // /--- enforced by trait MouseListener --------------------------------------\
   1.103 -	def mouseEntered(e: MouseEvent) {
   1.104 -		
   1.105 -		
   1.106 -	}
   1.107 -	def mouseExited(e: MouseEvent ) {
   1.108 -		
   1.109 -
   1.110 -	}
   1.111 +	def mouseEntered(e: MouseEvent) {}
   1.112 +	def mouseExited(e: MouseEvent ) {}
   1.113  	def mousePressed(e: MouseEvent ) {
   1.114  	  val boxAst : Ast = AstInfoUtil.FindBox(ast)
   1.115  	  if (boxAst != null) {
   1.116 @@ -117,8 +90,6 @@
   1.117  	  if (cursorAst != null) {
   1.118    	  ast =TransformAstUtil.Update(ast, cursorAst , TransformAstUtil.CursorToAst)    
   1.119  	  }
   1.120 -	  
   1.121 -	  
   1.122  		pressedMousePoint = new Point ( Settings.translateX - e.getX , Settings.translateY - e.getY)
   1.123  		marker.setLocation((e.getX / Settings.zoom ).round   -  (Settings.translateX / Settings.zoom).round, 
   1.124  		                   (e.getY / Settings.zoom ).round   -  (Settings.translateY / Settings.zoom).round)
   1.125 @@ -132,9 +103,6 @@
   1.126  		  }
   1.127  		  case None => {}
   1.128  		}
   1.129 -		
   1.130 -  		
   1.131 -		
   1.132  		markedBoxes = List.empty[DrawBox]
   1.133  		repaint()
   1.134  	}
   1.135 @@ -157,9 +125,6 @@
   1.136  		}
   1.137  		repaint()
   1.138  	}
   1.139 -	
   1.140 -	
   1.141 -	
   1.142    def mouseDragged(e:MouseEvent) {
   1.143      if (e.isControlDown() &&  Settings.isdraggingAllowed) {
   1.144        if (pressedMousePoint != null) {
   1.145 @@ -182,19 +147,11 @@
   1.146        repaint()
   1.147      }
   1.148  	}
   1.149 -
   1.150  	def mouseMoved(e: MouseEvent ) {
   1.151  	  EventUtil.drawBoxAt(e.getPoint())
   1.152      repaint()
   1.153  	}
   1.154    // \--- enforced by trait MouseMotionListener --------------------------------/
   1.155 - 
   1.156 -  
   1.157 -  
   1.158 -  
   1.159 -  
   1.160 -	
   1.161 -  
   1.162  
   1.163    def findHighestBoxOf(rootbox: DrawBox, markedBoxes : List[DrawBox]) : Option[DrawBox] = {
   1.164      if (markedBoxes != null && rootbox != null && rootbox.children != null) {
   1.165 @@ -216,6 +173,7 @@
   1.166      }
   1.167      return None
   1.168    }
   1.169 +  
   1.170  }
   1.171  
   1.172  
     2.1 --- a/isac-java/src/java/isac/gui/mawen/editor/AstInfoUtil.scala	Wed Sep 06 12:50:24 2017 +0200
     2.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/AstInfoUtil.scala	Wed Sep 06 13:45:58 2017 +0200
     2.3 @@ -34,7 +34,6 @@
     2.4      case _                                                       => false
     2.5      
     2.6    }
     2.7 -  
     2.8    //TODOWN def FirstChild(ast: Ast): Option[Ast] = ...
     2.9    def FirstChild(ast: Ast) = ast match {
    2.10      case Appl(asts) => asts.head
    2.11 @@ -83,7 +82,6 @@
    2.12        return null
    2.13      }
    2.14      case _ => null
    2.15 -    
    2.16    }
    2.17    def hasBox(ast: Ast) : Boolean = ast match {
    2.18      case Constant(str) if str.startsWith("BOX") => true
    2.19 @@ -97,7 +95,6 @@
    2.20      case Variable(str) => false
    2.21      case Appl(asts) => asts.exists(x => hasBox(x))
    2.22    }
    2.23 -  
    2.24     //TODOWN ..: Option[Ast] = ...
    2.25    def FindBox(ast: Ast) : Ast = ast match {
    2.26       case Appl(List(Constant(str), a)) if str.startsWith("BOX") => ast
     3.1 --- a/isac-java/src/java/isac/gui/mawen/editor/Box.scala	Wed Sep 06 12:50:24 2017 +0200
     3.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/Box.scala	Wed Sep 06 13:45:58 2017 +0200
     3.3 @@ -21,23 +21,13 @@
     3.4    case class EmptyLeafOpBox(override val level: Int, override val x0: Int, override val y0: Int, override val ast: Ast) extends EmptyBox(level, x0, y0, ast)
     3.5    case class EmptyUniOpBox(override val level: Int, override val x0: Int, override val y0: Int, param: Ast, override val ast: Ast) extends EmptyBox(level, x0, y0, ast)
     3.6    case class EmptyBinOpBox(override val level: Int, override val x0: Int, override val y0: Int, operator: Ast, paraml: Ast, paramr: Ast, override val ast: Ast) extends EmptyBox(level, x0, y0, ast)
     3.7 -  
     3.8 -  
     3.9  
    3.10    case class DrawBox(name: String, val level: Int, val x: Int, val y: Int, val width: Int, val height: Int, x0 : Int, y0 : Int, override val ast: Ast) extends Box(ast) {
    3.11 -    
    3.12      var children : List[DrawBox] = List.empty[DrawBox]
    3.13      var isBoxed: Boolean  = false
    3.14      var colorCode : Int = 0
    3.15      var boxedElement : Int = 0
    3.16 -    
    3.17 -    
    3.18    }
    3.19 -  
    3.20 -  
    3.21 -
    3.22 -  
    3.23 -  
    3.24    def isLeaf(b: DrawBox) : Boolean = b.children.length == 0
    3.25    
    3.26    def Contains(parent: DrawBox, box: DrawBox) : Boolean  =
    3.27 @@ -55,7 +45,6 @@
    3.28        g.setColor(java.awt.Color.BLACK)
    3.29      }
    3.30    }
    3.31 -  
    3.32    def BoxIn(b: DrawBox, rect: Rectangle) : Boolean = 
    3.33      rect.contains(b.x, b.y) || rect.contains(b.x + b.width, b.y) ||
    3.34      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	Wed Sep 06 12:50:24 2017 +0200
     4.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala	Wed Sep 06 13:45:58 2017 +0200
     4.3 @@ -1,16 +1,16 @@
     4.4  package isac.gui.mawen.editor
     4.5  
     4.6 +import isac.gui.mawen.editor.Box._
     4.7 +import isac.gui.mawen.syntax.Ast._
     4.8 +import isac.gui.mawen.syntax.Ast
     4.9 +import isac.gui.mawen.syntax.XSyntax
    4.10  import java.awt.Graphics
    4.11  import java.awt.Color
    4.12 +import java.awt.Dimension
    4.13 +import java.awt.Font
    4.14 +import java.awt.Graphics2D
    4.15 +import javax.swing.JButton
    4.16  import javax.swing.JTextField
    4.17 -import java.awt.Dimension
    4.18 -import javax.swing.JButton
    4.19 -import isac.gui.mawen.syntax.Ast._
    4.20 -import isac.gui.mawen.syntax.Ast
    4.21 -import java.awt.Font
    4.22 -import isac.gui.mawen.editor.Box._
    4.23 -import java.awt.Graphics2D
    4.24 -import isac.gui.mawen.syntax.XSyntax
    4.25  
    4.26  /**
    4.27   * <code>paint</code>s a <code>Box</code> according to 
    4.28 @@ -18,10 +18,7 @@
    4.29   * specific layouts defined in <code>CalcUtil</code>.
    4.30   */
    4.31  object BoxUtil {
    4.32 -  
    4.33 -  
    4.34 -  
    4.35 -  
    4.36 +
    4.37    def Draw(box : DrawBox, g: Graphics) : Unit = box.name match {
    4.38      case "GAP"                         => drawGap(g, box) 
    4.39      case "CURSOR"                      => drawCursor(g, box)
    4.40 @@ -36,12 +33,9 @@
    4.41        box.children.foreach( Draw(_, g) )
    4.42      }
    4.43    }
    4.44 -  
    4.45 -  
    4.46    def drawGap(g: Graphics, box : DrawBox) {
    4.47      g.fillRoundRect(box.x, box.y- box.height, box.width, box.height, 15, 15)
    4.48      drawBox(box, g)
    4.49 -    
    4.50    }
    4.51    def drawCursor(g: Graphics, box : DrawBox) = System.currentTimeMillis() match {
    4.52      case n if (n / 250) % 1 == 0  => box.ast match {
    4.53 @@ -49,19 +43,10 @@
    4.54          g.setColor(Color.RED)
    4.55          g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    4.56          g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x, box.y - box.height)
    4.57 -        
    4.58 -        
    4.59 -  //      g.drawRect(box.x, box.y - box.height, box.width, box.height)
    4.60 +
    4.61          g.setColor(Color.BLACK)
    4.62 -        if (box.children.length >= 1)
    4.63 -          Draw(box.children.head, g)
    4.64 -      
    4.65 -  		
    4.66 -  //		  Box.drawBox(box, g)
    4.67 -        
    4.68 -        
    4.69 +        if (box.children.length >= 1) Draw(box.children.head, g)
    4.70        }
    4.71 -      
    4.72        case Appl(List(a, Constant("CURSOR"))) => {
    4.73          g.setColor(Color.RED)
    4.74          g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    4.75 @@ -71,28 +56,19 @@
    4.76          if (box.children.length >= 1)
    4.77            Draw(box.children.head, g)
    4.78        }
    4.79 -      
    4.80      }
    4.81      case _ => {
    4.82        if (box.children.length >= 1)
    4.83            Draw(box.children.head, g)
    4.84      }
    4.85 -    
    4.86    }
    4.87 -    
    4.88 -    
    4.89 -    
    4.90 -    
    4.91 -  
    4.92    def drawPlus(g: Graphics, box : DrawBox) {
    4.93      val font_var = new Font("CMCSC8", Font.PLAIN,  CalcUtil.fontsizeOf(box.level))
    4.94      g.setFont(font_var)
    4.95      
    4.96      g.drawString("+", box.x0, box.y0)
    4.97      drawBox(box, g)
    4.98 -
    4.99    }
   4.100 -  
   4.101    def drawDivide(g: Graphics, box : DrawBox) {
   4.102      g.drawLine(box.x, box.y, box.x + box.width, box.y)
   4.103      drawBox(box, g)
   4.104 @@ -106,20 +82,16 @@
   4.105          g.setFont(font_var)
   4.106          g.drawString(charIndex.toChar.toString(), box.x0, box.y0)
   4.107          drawBox(box, g)
   4.108 -        
   4.109        }
   4.110        case None => {
   4.111          // Ident
   4.112          val font_var = new Font("CMMI12", Font.PLAIN,  CalcUtil.fontsizeOf(box.level))
   4.113          g.setFont(font_var)
   4.114 -        
   4.115          g.drawString(box.name, box.x0, box.y0)
   4.116          drawBox(box, g)
   4.117        }
   4.118      }
   4.119  
   4.120 -    
   4.121 -    
   4.122    }
   4.123    
   4.124    
     5.1 --- a/isac-java/src/java/isac/gui/mawen/editor/CalcUtil.scala	Wed Sep 06 12:50:24 2017 +0200
     5.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/CalcUtil.scala	Wed Sep 06 13:45:58 2017 +0200
     5.3 @@ -1,18 +1,18 @@
     5.4  package isac.gui.mawen.editor
     5.5  
     5.6 +import isac.gui.mawen.editor.Box._
     5.7  import isac.gui.mawen.syntax.Ast._
     5.8  import isac.gui.mawen.syntax.Ast.raw_string_of
     5.9  import isac.gui.mawen.syntax.AstException
    5.10 -import javax.swing.JComponent
    5.11 +import isac.gui.mawen.syntax.XSyntax
    5.12  import java.awt.Graphics
    5.13  import java.awt.Font
    5.14  import java.awt.Rectangle
    5.15  import java.awt.Graphics2D
    5.16  import java.awt.Color
    5.17 +import javax.swing.JComponent
    5.18 +import javax.swing.Spring.HeightSpring
    5.19  import sun.font.FontScaler  //WHY non-java ?
    5.20 -import javax.swing.Spring.HeightSpring
    5.21 -import isac.gui.mawen.syntax.XSyntax
    5.22 -import isac.gui.mawen.editor.Box._
    5.23  
    5.24  /**
    5.25   * Calculate a <code>Box</code> for each leaf
    5.26 @@ -22,115 +22,82 @@
    5.27  object CalcUtil {
    5.28    
    5.29    val emptyFunc = (box: Box) => {}
    5.30 -  
    5.31 -
    5.32 -  def assembleComponent(ast : Ast) : JComponent = new AstComponent(ast)
    5.33 -
    5.34 -  def assembleBoxes (ast : Ast, f: (DrawBox) => Unit ) =  assembleBoxesRec(new EmptyBox(0,0,0,ast), f)
    5.35 +  def assembleComponent(ast: Ast): JComponent = new AstComponent(ast)
    5.36 +  def assembleBoxes (ast: Ast, f: (DrawBox) => Unit ) =
    5.37 +    assembleBoxesRec(new EmptyBox(0,0,0,ast), f)
    5.38  
    5.39    def assembleBoxesRec(emptyBox: EmptyBox, f:(DrawBox) => Unit) : DrawBox = emptyBox.ast match {
    5.40 -    case Appl(operator :: param :: Nil)                =>   assembleUniopBoxes(EmptyUniOpBox(emptyBox.level, emptyBox.x0, emptyBox.y0, param, emptyBox.ast), f)
    5.41 -    case Appl(operator :: paraml :: paramr :: Nil)     =>   assembleBinopBoxes(AstInfoUtil.OperatorString(operator), EmptyBinOpBox(emptyBox.level,emptyBox.x0, emptyBox.y0, operator, paraml, paramr,emptyBox.ast), f)
    5.42 -    case Appl(Constant(str) :: param)                  =>   calcDefault(str,param, emptyBox.x0, emptyBox.y0, emptyBox.level, emptyBox.ast, f)
    5.43 -    case a                                             =>   assembleLeafBoxes(EmptyLeafOpBox(emptyBox.level, emptyBox.x0, emptyBox.y0, emptyBox.ast), f)
    5.44 +    case Appl(operator :: param :: Nil)
    5.45 +      => assembleUniopBoxes(EmptyUniOpBox(emptyBox.level, emptyBox.x0, emptyBox.y0, param, emptyBox.ast), f)
    5.46 +    case Appl(operator :: paraml :: paramr :: Nil)
    5.47 +      => assembleBinopBoxes(AstInfoUtil.OperatorString(operator), EmptyBinOpBox(emptyBox.level,emptyBox.x0, emptyBox.y0, operator, paraml, paramr,emptyBox.ast), f)
    5.48 +    case Appl(Constant(str) :: param)
    5.49 +      => calcDefault(str,param, emptyBox.x0, emptyBox.y0, emptyBox.level, emptyBox.ast, f)
    5.50 +    case a
    5.51 +      => assembleLeafBoxes(EmptyLeafOpBox(emptyBox.level, emptyBox.x0, emptyBox.y0, emptyBox.ast), f)
    5.52    }
    5.53 -  
    5.54    def assembleLeafBoxes(emptyBox: EmptyLeafOpBox, f:(DrawBox) => Unit) : DrawBox = emptyBox.ast match {
    5.55 -    case Variable("GAP")                                                          => calcGAP( emptyBox, f)
    5.56 -    case Constant("GAP")                                                          => calcGAP( emptyBox, f)
    5.57 -    case Constant(str)                                                            => calcConstant( emptyBox, f)
    5.58 -    case Variable(str)                                                            => calcVariable( emptyBox, f)
    5.59 +    case Variable("GAP") => calcGAP( emptyBox, f)
    5.60 +    case Constant("GAP") => calcGAP( emptyBox, f)
    5.61 +    case Constant(str)   => calcConstant( emptyBox, f)
    5.62 +    case Variable(str)   => calcVariable( emptyBox, f)
    5.63      case ast => throw new AstException("assembleBoxesRec, uncovered match: " + raw_string_of(ast))
    5.64    }
    5.65 -  
    5.66    def assembleUniopBoxes(emptyBox: EmptyUniOpBox, f:(DrawBox) => Unit) : DrawBox = emptyBox.ast match {
    5.67 -    case Appl(Constant(str) ::  ast :: Nil)       if str.startsWith("BOX")        => CalcBox( str.replace("BOX.", ""), emptyBox, f)
    5.68 -    case Appl(Constant("CURSOR") :: param :: Nil)                                 => calcCursor( EmptyUniOpBox(emptyBox.level,emptyBox.x0,emptyBox.y0, param, emptyBox.ast), f)
    5.69 -    case Appl(param :: Constant("CURSOR") :: Nil)                                 => calcCursor( EmptyUniOpBox(emptyBox.level,emptyBox.x0,emptyBox.y0, param, emptyBox.ast), f)
    5.70 -    case Appl(op :: param :: Nil)                                                  => calcDefault( AstInfoUtil.OperatorString(op), List(param), emptyBox.x0, emptyBox.y0, emptyBox.level, emptyBox.ast, f)
    5.71 -    case ast => throw new AstException("assembleBoxesRec, uncovered match: " + raw_string_of(ast))
    5.72 +    case Appl(Constant(str) ::  ast :: Nil) if str.startsWith("BOX")
    5.73 +      => CalcBox( str.replace("BOX.", ""), emptyBox, f)
    5.74 +    case Appl(Constant("CURSOR") :: param :: Nil)
    5.75 +      => calcCursor( EmptyUniOpBox(emptyBox.level,emptyBox.x0,emptyBox.y0, param, emptyBox.ast), f)
    5.76 +    case Appl(param :: Constant("CURSOR") :: Nil)
    5.77 +      => calcCursor( EmptyUniOpBox(emptyBox.level,emptyBox.x0,emptyBox.y0, param, emptyBox.ast), f)
    5.78 +    case Appl(op :: param :: Nil)
    5.79 +      => calcDefault( AstInfoUtil.OperatorString(op), List(param), emptyBox.x0, emptyBox.y0, emptyBox.level, emptyBox.ast, f)
    5.80 +    case ast
    5.81 +      => throw new AstException("assembleBoxesRec, uncovered match: " + raw_string_of(ast))
    5.82    }
    5.83 -  
    5.84 -  
    5.85    def assembleBinopBoxes( operatorString: String, emptyBox: EmptyBinOpBox, f:(DrawBox) => Unit) : DrawBox = Settings.layoutName(XSyntax.isa_ast(operatorString) ) match {
    5.86 -    case "binOp"     => calcDefaultBinOp( emptyBox, f)
    5.87 -    case "Pow"       => calcPow( emptyBox, f)
    5.88 -    case "Frac"      => calcFrac( emptyBox, f)
    5.89 -    case _           => calcDefault( operatorString, List(emptyBox.paramr, emptyBox.paraml), emptyBox.x0, emptyBox.y0, emptyBox.level, emptyBox.ast, f)
    5.90 +    case "binOp" => calcDefaultBinOp( emptyBox, f)
    5.91 +    case "Pow"   => calcPow( emptyBox, f)
    5.92 +    case "Frac"  => calcFrac( emptyBox, f)
    5.93 +    case _       => calcDefault( operatorString, List(emptyBox.paramr, emptyBox.paraml), emptyBox.x0, emptyBox.y0, emptyBox.level, emptyBox.ast, f)
    5.94    }
    5.95 -  
    5.96 -  
    5.97 -  
    5.98 -
    5.99 -  
   5.100    def calcVariable( emptybox: EmptyLeafOpBox, f:(DrawBox) => Unit) = {
   5.101      val level = emptybox.level
   5.102      val x0 = emptybox.x0
   5.103      val y0 = emptybox.y0
   5.104      val ast =  emptybox.ast
   5.105      val str = AstInfoUtil.VariableString(emptybox.ast)
   5.106 -    
   5.107 -//    val font_var = new Font("CMMI12", Font.PLAIN, fontsizeOf(level))
   5.108 -//    g.setFont(font_var)
   5.109 -    
   5.110      val box : Rectangle =  Settings.getStringBoundOf(str, level, x0, y0) //  getStringBounds(g.asInstanceOf[Graphics2D], str, x0, y0) // TODO: Why does this work without x0,y0?
   5.111 -
   5.112      val b = DrawBox(str, level, box.x, box.y + box.height, box.width, box.height, x0, y0, ast)
   5.113 -    f(b)
   5.114 -      
   5.115 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.116      b
   5.117    }
   5.118 -
   5.119 -  
   5.120 -  
   5.121 -  
   5.122    def calcConstant( emptyBox: EmptyLeafOpBox, f:(DrawBox) => Unit) = {
   5.123      val level = emptyBox.level
   5.124      val x0 = emptyBox.x0
   5.125      val y0 = emptyBox.y0
   5.126      val ast =  emptyBox.ast
   5.127      val op = XSyntax.isa_ast((AstInfoUtil.OperatorString(emptyBox.ast)))
   5.128 -
   5.129 -//    val font_var = new Font("CMCSC8", Font.PLAIN,  fontsizeOf(level))
   5.130 -//    g.setFont(font_var)
   5.131 -    
   5.132      val box : Rectangle = Settings.getStringBoundOf(op, level,x0,y0)  //getStringBounds(g.asInstanceOf[Graphics2D], op, x0, y0)
   5.133 -
   5.134      val midline = y0 - (fontsizeOf(level) * (2f / 3f)*(1f / 3f)).round
   5.135      val newY = ((box.y - y0) * -1) - box.height /2 + midline
   5.136 -    
   5.137 -    
   5.138      val b = DrawBox(op, level, box.x, y0, box.width, fontWidthOf(fontsizeOf(level)),x0, newY, ast)
   5.139 -    
   5.140 -    f(b)
   5.141 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.142      b
   5.143 -    
   5.144    }
   5.145    def calcGAP( emptyBox: EmptyLeafOpBox, f:(DrawBox) => Unit) = {
   5.146      val level = emptyBox.level
   5.147      val x0 = emptyBox.x0
   5.148      val y0 = emptyBox.y0
   5.149      val ast =  emptyBox.ast
   5.150 -    
   5.151      val box : Rectangle = Settings.getStringBoundOf("xx", level, x0, y0) //getStringBounds(g.asInstanceOf[Graphics2D], "xx", x0, y0)
   5.152 -    
   5.153 -
   5.154 -    
   5.155 -    
   5.156      val b = new DrawBox("GAP", level, box.x, y0, box.width, fontWidthOf(fontsizeOf(level)),x0, y0, ast)
   5.157 -    //g.setColor(Color.BLACK)
   5.158 -    //g.fillRect(b.x, y0 - g.getFontMetrics.getHeight, b.width - 10, g.getFontMetrics.getHeight - 25)
   5.159 -    
   5.160 -    f(b)
   5.161 -    
   5.162 -    
   5.163 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.164      b
   5.165    }
   5.166 -   
   5.167    def CalcBox( str: String, emptyBox: EmptyUniOpBox, f:(DrawBox) => Unit) = {
   5.168       val box = assembleBoxesRec( new EmptyBox(emptyBox.level, emptyBox.x0, emptyBox.y0, emptyBox.param), f)
   5.169       box.isBoxed = true
   5.170 -     
   5.171       if (str.split('.').head == "MAIN") {
   5.172         box.boxedElement = str.split('.').tail.head.toInt
   5.173         box.colorCode = 0
   5.174 @@ -138,35 +105,20 @@
   5.175         box.boxedElement = 0
   5.176         box.colorCode = str.split('.').head.toInt
   5.177       }
   5.178 -     
   5.179 -     
   5.180 -     
   5.181       box
   5.182    }
   5.183 -   
   5.184 -   
   5.185 -   
   5.186 -   def calcCursor( emptyBox: EmptyUniOpBox, f:(DrawBox) => Unit) = {
   5.187 -     val x0 = emptyBox.x0
   5.188 -     val y0 = emptyBox.y0
   5.189 -     val level = emptyBox.level
   5.190 -     val ast = emptyBox.ast
   5.191 -     val param = emptyBox.param
   5.192 -    
   5.193 -    
   5.194 -     
   5.195 +  def calcCursor( emptyBox: EmptyUniOpBox, f:(DrawBox) => Unit) = {
   5.196 +    val x0 = emptyBox.x0
   5.197 +    val y0 = emptyBox.y0
   5.198 +    val level = emptyBox.level
   5.199 +    val ast = emptyBox.ast
   5.200 +    val param = emptyBox.param
   5.201      val childBox = assembleBoxesRec( new EmptyBox(level, x0, y0, param), f)
   5.202 -    
   5.203      val b = new DrawBox("CURSOR", level, childBox.x - 1, childBox.y + 1, childBox.width + 2,  childBox.height + 2, x0, y0, ast)
   5.204 -    
   5.205 -    f(b)
   5.206 -    
   5.207 -    
   5.208 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.209      b.children = List(childBox)
   5.210      b
   5.211    }
   5.212 -  
   5.213 -  
   5.214    /*
   5.215     * layout of horizontal type +, (binary)-, *, =
   5.216     */
   5.217 @@ -178,22 +130,16 @@
   5.218      val y0 = emptyBox.y0
   5.219      val level= emptyBox.level
   5.220      val ast = emptyBox.ast
   5.221 -    
   5.222      val horizontalCloseBracketSpace = Settings.getStringBoundOf(")", level, x0, y0) //getStringBounds(g.asInstanceOf[Graphics2D], ")", x0, y0)
   5.223      val constantSpace = Settings.getStringBoundOf("(i", level, x0, y0)
   5.224 -    
   5.225      val (leftSpace:Int, op:String, rightSpace:Int) = {
   5.226        val str = Settings.layoutStyle(XSyntax.isa_ast(AstInfoUtil.OperatorString(operator)))
   5.227        (Settings.SpaceOf(str.charAt(0)), str.charAt(1).toString(), Settings.SpaceOf(str.charAt(2)))
   5.228      }
   5.229 -    
   5.230 -    
   5.231      var lspaceOpen  = 0
   5.232      var lspaceClose = 0
   5.233      var rspaceOpen  = 0
   5.234      var rspaceClose = 0
   5.235 -    
   5.236 -    
   5.237      if (AstInfoUtil.priorOfAst(paraml) != 0 && AstInfoUtil.priorOfAst(paraml) < AstInfoUtil.priorOfAst(ast)) {
   5.238        lspaceOpen = constantSpace.width
   5.239        lspaceClose  = horizontalCloseBracketSpace.width
   5.240 @@ -202,9 +148,6 @@
   5.241        rspaceOpen = constantSpace.width
   5.242        rspaceClose  = horizontalCloseBracketSpace.width
   5.243      }
   5.244 -    
   5.245 -    
   5.246 -    
   5.247      val l_box = assembleBoxesRec( emptyBox.toEmptyBox(x0 + lspaceOpen, y0, paraml), f)
   5.248      val l_width = l_box.width
   5.249      val l_height = l_box.height
   5.250 @@ -217,21 +160,15 @@
   5.251      val r_width = r_box.width
   5.252      val r_height = r_box.height
   5.253      
   5.254 -    
   5.255      val newX = x0
   5.256      val newY = Math.max(l_box.y, r_box.y)
   5.257      val newWidth = l_width + leftSpace + operator_width + rightSpace + r_width + lspaceOpen + lspaceClose
   5.258      val newHeight = Math.max(l_height, r_height)
   5.259  
   5.260      val b = new DrawBox("", level,
   5.261 -        newX,
   5.262 -        newY,
   5.263 -        newWidth,
   5.264 -        newHeight
   5.265 -        , x0, y0, ast)
   5.266 -    
   5.267 -    
   5.268 -    
   5.269 +        newX, newY,
   5.270 +        newWidth, newHeight, 
   5.271 +        x0, y0, ast)
   5.272      b.children =  o_box :: l_box :: r_box :: List.empty[DrawBox]
   5.273      
   5.274      if (AstInfoUtil.priorOfAst(paraml) != 0 && AstInfoUtil.priorOfAst(paraml) < AstInfoUtil.priorOfAst(ast)) {
   5.275 @@ -252,11 +189,9 @@
   5.276       
   5.277        b.children =  openBracketR :: closeBracketR :: b.children
   5.278      }
   5.279 -    
   5.280 -    f(b)
   5.281 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.282      b
   5.283    }
   5.284 -  
   5.285    /*
   5.286     * layout of vertical type ^
   5.287     */
   5.288 @@ -279,9 +214,7 @@
   5.289      
   5.290      val b = DrawBox ("", level, x0, y0, l_width + Settings.POWHORIZONTALSPACE + r_width, l_height + r_height,x0, y0,ast)
   5.291      b.children =  l_box :: r_box :: List.empty[DrawBox]
   5.292 -    
   5.293 -    f(b);
   5.294 -    
   5.295 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.296      b
   5.297    }
   5.298    
   5.299 @@ -296,9 +229,7 @@
   5.300      var y0 = emptyBox.y0
   5.301      val level= emptyBox.level
   5.302      val ast = emptyBox.ast
   5.303 -    
   5.304 -    
   5.305 -    
   5.306 +
   5.307      val u_box = assembleBoxesRec( new EmptyBox(level+1, x0, y0, paramUpper), emptyFunc)
   5.308      val l_box = assembleBoxesRec( new EmptyBox(level+1, x0, y0, paramLower), emptyFunc)
   5.309      
   5.310 @@ -306,56 +237,33 @@
   5.311      if (lowestY0(u_box) > y0) {
   5.312        difY0lower = lowestY0(u_box) - y0
   5.313      }
   5.314 -    
   5.315      var difY0upper = 0
   5.316      if (highestY0(l_box) < y0) {
   5.317        difY0upper = y0 - highestY0(l_box)
   5.318      }
   5.319 -    
   5.320 -
   5.321 -    
   5.322 -    
   5.323 -    
   5.324      val y_midline = y0 - (fontsizeOf(level) * (2f / 3f)*(1f / 3f)).round
   5.325      
   5.326      val maxWidth = Math.max(u_box.width, l_box.width)
   5.327 -    
   5.328 -    
   5.329      val line_box = new DrawBox("Fields.inverse_class.divide", level, x0, y_midline, maxWidth, 3, x0, y0, ast);
   5.330 -    
   5.331      // calc position for upper Frac
   5.332      val u_x0 = x0 + (maxWidth / 2f - u_box.width / 2f).round
   5.333      val u_y0 = y_midline - Settings.FRACVERTIKALSPACE - difY0lower
   5.334 -    
   5.335 -
   5.336 -    
   5.337 -    
   5.338      // calc position for lower Frac
   5.339      val l_x0 = x0 + (maxWidth / 2f - l_box.width / 2f).round
   5.340      val l_y0 = y_midline + Settings.FRACVERTIKALSPACE + fontWidthOf(fontsizeOf(level)) + difY0upper
   5.341      
   5.342 -    
   5.343      val u_res_box = assembleBoxesRec( new EmptyBox(level+1,  u_x0, u_y0,paramUpper), f)
   5.344      val l_res_box = assembleBoxesRec( new EmptyBox(level+1, l_x0, l_y0, paramLower), f)
   5.345      
   5.346 -    val b = new DrawBox("", level, 
   5.347 -        x0, 
   5.348 -        l_res_box.y, 
   5.349 -        maxWidth, 
   5.350 +    val b = new DrawBox(
   5.351 +        "", level, x0, l_res_box.y, maxWidth, 
   5.352          u_res_box.height + l_res_box.height + line_box.height + Settings.FRACVERTIKALSPACE + Settings.FRACVERTIKALSPACE, 
   5.353          x0, y0, ast)
   5.354      b.children = line_box :: u_res_box :: l_res_box :: List.empty[DrawBox]
   5.355 -    
   5.356 -    f(b)
   5.357 -    
   5.358 -//    if (level == 1)
   5.359 -//      b.draw( false)
   5.360 -    
   5.361 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.362      b
   5.363    }
   5.364 -  
   5.365    def calcDefault( str: String, param: List[Ast], x0: Int, y0: Int, level: Int, ast : Ast, f:(DrawBox) => Unit) = {
   5.366 -    
   5.367      val boxes = param.map(x => assembleBoxesRec( new EmptyBox(level, x0, y0, x),emptyFunc))
   5.368      
   5.369      val horizontalSpace =             Settings.getStringBoundOf(",x", level, x0, y0)
   5.370 @@ -365,11 +273,8 @@
   5.371     
   5.372      var x = x0 + constantSpace.width + constant.width
   5.373      var y = y0
   5.374 -    
   5.375 -    
   5.376      var resBoxes = List.empty[DrawBox]
   5.377 -    
   5.378 -    
   5.379 +
   5.380      for (box <- boxes) {
   5.381        val b = assembleBoxesRec( new EmptyBox(level, x, y, box.ast), f)
   5.382        resBoxes = b :: resBoxes 
   5.383 @@ -380,16 +285,10 @@
   5.384          resBoxes =  new DrawBox(", ", level, b.x,b.y,horizontalSpace.width,horizontalSpace.height,b.x + b.width,b.y,null) :: resBoxes
   5.385          x = x + horizontalSpace.width  + b.width
   5.386        }
   5.387 -      
   5.388 -      
   5.389 -      
   5.390      }
   5.391 -    
   5.392 -    
   5.393      val resultBox = new DrawBox(XSyntax.isa_ast(str) + "(", level, x0, y0, x - x0 , boxes.map(mb => mb.height).max, x0, y0, ast);
   5.394      resultBox.children = resBoxes
   5.395 -    f(resultBox)
   5.396 -    
   5.397 +    f(resultBox) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.398      resultBox
   5.399    }
   5.400    
   5.401 @@ -405,14 +304,11 @@
   5.402      val y0 = emptyBox.y0
   5.403      val level= emptyBox.level
   5.404      val ast = emptyBox.ast
   5.405 -    
   5.406 -    
   5.407 -    
   5.408 +
   5.409      val l_box = assembleBoxesRec( new EmptyBox(level, x0, y0, paraml), f)
   5.410      val l_width = l_box.width
   5.411      val l_height = l_box.height
   5.412 -    
   5.413 -    
   5.414 +
   5.415      val o_box = assembleBoxesRec( new EmptyBox(level, x0 + l_width + Settings.LARGESPACE, y0, Constant("=")), f)
   5.416      val operator_width = o_box.width
   5.417      val operator_height  = o_box.height
   5.418 @@ -420,21 +316,12 @@
   5.419      val r_box = assembleBoxesRec( new EmptyBox(level, x0 + l_width + Settings.LARGESPACE + operator_width + Settings.LARGESPACE, y0, paramr), f)
   5.420      val r_width = r_box.width
   5.421      val r_height = r_box.height
   5.422 -    
   5.423  
   5.424      val b = new DrawBox("", level, x0, y0, l_width + Settings.LARGESPACE + operator_width + Settings.LARGESPACE + r_width, Math.max(l_height, r_height),x0, y0, ast)
   5.425      b.children =  o_box :: l_box :: r_box :: List.empty[DrawBox]
   5.426 -    
   5.427 -    f(b)
   5.428 +    f(b) // makes call-back to <code>AstComponent</code> for <code>mouseMoved</code>
   5.429      b
   5.430    }
   5.431 -  
   5.432 -  
   5.433 -
   5.434 -  
   5.435 -  
   5.436 -  
   5.437 -  
   5.438    def lowestY0(b: DrawBox): Int = {
   5.439      if (b.children.isEmpty) {
   5.440        return b.y0
   5.441 @@ -445,7 +332,6 @@
   5.442      }
   5.443      return maxY0
   5.444    }
   5.445 -  
   5.446    def highestY0(b: DrawBox): Int = {
   5.447      if (b.children.isEmpty) {
   5.448        return b.y0
   5.449 @@ -456,8 +342,6 @@
   5.450      }
   5.451      return maxY0
   5.452    }
   5.453 -  
   5.454 -  
   5.455    def fontWidthOf(fontsize: Int) = ((fontsize * 2f) / 3f).round
   5.456  
   5.457    //TODOWN rename to decreaseFontOfLevel
   5.458 @@ -471,7 +355,5 @@
   5.459      case 1 => (Settings.INITIALFONTSIZE * 0.7f).round
   5.460      case _ => (Settings.INITIALFONTSIZE * 0.7f * 0.7f).round
   5.461    }
   5.462 -  
   5.463 -  
   5.464 -  
   5.465 +
   5.466  }
     6.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EditingUtil.scala	Wed Sep 06 12:50:24 2017 +0200
     6.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EditingUtil.scala	Wed Sep 06 13:45:58 2017 +0200
     6.3 @@ -11,22 +11,15 @@
     6.4   */
     6.5  object EditingUtil {
     6.6    
     6.7 -  //TODOWN delete ?
     6.8    def parse(c: AstContainer, inputCode: Int) : Unit =  {
     6.9      val cursorAst = AstInfoUtil.FindCursor(c.getAst()) 
    6.10      val cursorAstElem = AstInfoUtil.AstOfCursor(cursorAst)
    6.11 -   
    6.12      findState(c, cursorAst, inputCode) match {
    6.13        case Some(ast) => c.setAst(TransformAstUtil.Update(c.getAst(), cursorAst, TransformAstUtil.ReplaceCursor(ast)))
    6.14        case None => {}
    6.15      }
    6.16 -    
    6.17 -    
    6.18 -    
    6.19    }
    6.20 -  
    6.21    def findState(c: AstContainer, cursorAst: Ast, inputCode: Int) : Option[Ast] = cursorAst match {
    6.22 -    
    6.23      case Appl(List(Variable(str), Constant("CURSOR"))) if str forall Character.isDigit  => numberState(AstInfoUtil.AstOfCursor(cursorAst), inputCode) match {
    6.24        case Some(ast) => Some(ast)
    6.25        case None => startState(c, inputCode, cursorAst)
    6.26 @@ -38,7 +31,6 @@
    6.27      case _ => startState(c, inputCode, cursorAst)
    6.28    }
    6.29    
    6.30 -  
    6.31    def startState(c: AstContainer, inputCode: Int, cursorAst: Ast) : Option[Ast] = {
    6.32      println("startstate")
    6.33      if (isActionCode(inputCode)) {
    6.34 @@ -47,12 +39,8 @@
    6.35      } else if (isDelim(inputCode) ) {
    6.36        return delimerState(c, inputCode.toChar , cursorAst)
    6.37      }
    6.38 -    
    6.39      return None
    6.40 -    
    6.41    }
    6.42 -  
    6.43 -  
    6.44    def identState(cursorAstElem: Ast, inputCode: Int) = cursorAstElem match {
    6.45      case Variable(str) if isIdentifier(inputCode) || isNumber(inputCode) => Some(Appl(List(Variable(str + inputCode.toChar), Constant("CURSOR"))))
    6.46      case Constant("GAP") if isIdentifier(inputCode) || isNumber(inputCode) => Some(Appl(List(Variable("" + inputCode.toChar), Constant("CURSOR"))))
    6.47 @@ -60,8 +48,6 @@
    6.48      case Variable(str) if inputCode == -KeyEvent.VK_BACK_SPACE => Some(Appl(List(Variable(str.slice(0, str.length - 1)), Constant("CURSOR"))))
    6.49      case _ => None
    6.50    }
    6.51 -  
    6.52 -  
    6.53    def numberState(cursorAstElem: Ast, inputCode: Int) : Option[Ast] = cursorAstElem match {
    6.54      case Variable(str) if (isNumber(inputCode.toChar))                             =>  Some(Appl(List(Variable(str + inputCode.toChar), Constant("CURSOR"))))
    6.55      case Constant("GAP") if isIdentifier(inputCode) || isNumber(inputCode)         => Some(Appl(List(Variable("" + inputCode.toChar), Constant("CURSOR"))))
    6.56 @@ -71,8 +57,6 @@
    6.57        println("none")
    6.58        None
    6.59      }
    6.60 -    
    6.61 -     
    6.62    }
    6.63    def ActionState(c: AstContainer, code: Int, cursorAst: Ast) : Option[Ast] = code match {
    6.64      case KeyEvent.VK_RIGHT => TransformAstUtil.CursorNextChild(c); None
    6.65 @@ -97,24 +81,23 @@
    6.66        None
    6.67      }
    6.68    }
    6.69 -  
    6.70    def delimerState(c: AstContainer, input: Character, cursorAst: Ast) : Option[Ast] =  AstInfoUtil.AstOfCursor(cursorAst) match {
    6.71 -    case Variable(str)   if input == '(' && isLongDelim(str)           => Some(ReplaceFirstGap(Settings.OperatorToAst(str), Appl(List(Constant("CURSOR"), Constant("GAP")))))
    6.72 -    case Variable(str) => Some(
    6.73 -                            ReplaceFirstGap(
    6.74 -                              ReplaceFirstGap(
    6.75 -                                Settings.OperatorToAst(input.toString()),
    6.76 -                                Variable(str)),
    6.77 -                              Appl(List(Constant("CURSOR"), Constant("GAP")))
    6.78 -                            )
    6.79 -                          )
    6.80 -    case Appl(asts)  =>  Some(
    6.81 -                          ReplaceFirstGap(
    6.82 -                           ReplaceFirstGap(
    6.83 -                             Settings.OperatorToAst(input.toString()),
    6.84 -                             Appl(asts)),
    6.85 -                           Appl(List(Constant("CURSOR"), Constant("GAP")))
    6.86 -                         ))
    6.87 +    case Variable(str)   if input == '(' && isLongDelim(str)
    6.88 +      => Some(ReplaceFirstGap(
    6.89 +           Settings.OperatorToAst(str),
    6.90 +           Appl(List(Constant("CURSOR"), Constant("GAP")))))
    6.91 +    case Variable(str)
    6.92 +      => Some(ReplaceFirstGap(
    6.93 +           ReplaceFirstGap(
    6.94 +             Settings.OperatorToAst(input.toString()),
    6.95 +             Variable(str)),
    6.96 +           Appl(List(Constant("CURSOR"), Constant("GAP")))))
    6.97 +    case Appl(asts)
    6.98 +      => Some(ReplaceFirstGap(
    6.99 +           ReplaceFirstGap(
   6.100 +             Settings.OperatorToAst(input.toString()),
   6.101 +             Appl(asts)),
   6.102 +           Appl(List(Constant("CURSOR"), Constant("GAP")))))
   6.103      case Constant("GAP") => Some(Settings.OperatorToAst(input.toString()))
   6.104      case Constant(str) => {
   6.105        val operatorParams = AstInfoUtil.Parent(c.getAst(), cursorAst).asInstanceOf[Appl].name.tail
   6.106 @@ -130,7 +113,6 @@
   6.107        None
   6.108      }
   6.109                          
   6.110 -                        
   6.111    }
   6.112    
   6.113  
     7.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EditorPanel.java	Wed Sep 06 12:50:24 2017 +0200
     7.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EditorPanel.java	Wed Sep 06 13:45:58 2017 +0200
     7.3 @@ -1,14 +1,11 @@
     7.4  package isac.gui.mawen.editor;
     7.5  
     7.6 -import javax.swing.*;
     7.7 -
     7.8  import isac.gui.mawen.syntax.Ast;
     7.9  import isac.interfaces.IEditor;
    7.10  
    7.11  import java.awt.*;
    7.12  import java.util.ArrayList;
    7.13 -
    7.14 -
    7.15 +import javax.swing.*;
    7.16  
    7.17  /**
    7.18   * Manages the editor for one formula represented by an <code>Ast</code>
    7.19 @@ -16,36 +13,23 @@
    7.20   */
    7.21  public class EditorPanel extends JPanel implements IEditor  {
    7.22  
    7.23 -	private static final long serialVersionUID = 1L;
    7.24 -	
    7.25 -	protected ArrayList<EditorListener> listeners;
    7.26 -
    7.27 -	
    7.28 -
    7.29 -
    7.30 +  private static final long serialVersionUID = 1L;
    7.31 +  protected ArrayList<EditorListener> listeners;
    7.32    private JComponent component;
    7.33  
    7.34 -/*err*/public EditorPanel( isac.gui.mawen.syntax.Ast.Ast ast) {
    7.35 -  listeners = new ArrayList<EditorListener>();
    7.36 -		
    7.37 +/*err*/public EditorPanel(Ast.Ast ast) {
    7.38 +    listeners = new ArrayList<EditorListener>();
    7.39      LayoutManager overlay = new OverlayLayout(this);
    7.40      this.setBackground(Color.GREEN);
    7.41 -    
    7.42 -		setLayout(overlay);
    7.43 -		
    7.44 -		
    7.45 -
    7.46 -		component = CalcUtil.assembleComponent(ast);
    7.47 -		EditorListenerHandler.addListenerHandler((IEditor)this, (AstContainer)component);
    7.48 -		add(component);
    7.49 -	}
    7.50 -
    7.51 +    setLayout(overlay);
    7.52 +	component = CalcUtil.assembleComponent(ast);
    7.53 +	EditorListenerHandler.addListenerHandler((IEditor)this, (AstContainer)component);
    7.54 +	add(component);
    7.55 +  }
    7.56    @Override
    7.57    public JComponent getComponent() {
    7.58 -    
    7.59      return this;
    7.60    }
    7.61 -
    7.62    @Override
    7.63    public void setFormula(String formula) {
    7.64      System.out.println(formula);
    7.65 @@ -57,15 +41,12 @@
    7.66  /*err*/public isac.gui.mawen.syntax.Ast.Ast getFormula() {
    7.67  /*err*/return ((AstComponent)component).getAst();
    7.68    }
    7.69 -  
    7.70 -  
    7.71    public void addEditorListener(EditorListener l) {
    7.72      listeners.add(l);
    7.73    }
    7.74    public void removeEditorListener(EditorListener l) {
    7.75      listeners.remove(l);
    7.76    }
    7.77 -  
    7.78    public void fireNotifyLocalCheck() {
    7.79      for(EditorListener l : listeners) {
    7.80        l.notifyLocalCheck();
    7.81 @@ -81,23 +62,18 @@
    7.82  	      l.notifyBraille(formula);
    7.83  	    }
    7.84  	  }
    7.85 -
    7.86    @Override
    7.87    public Dimension getExpressionSize() {
    7.88 -    
    7.89      return new Dimension(Math.max(component.getSize().width, 50), Math.max(component.getSize().height, 50)) ;
    7.90    }
    7.91 -
    7.92    @Override
    7.93    public boolean setEditable() {
    7.94 -    // TODO Auto-generated method stub
    7.95      return false;
    7.96    }
    7.97 -
    7.98    @Override
    7.99    public String getMathText() {
   7.100  /*err*/System.out.println(isac.gui.mawen.syntax.Ast$.MODULE$.math_string_of(getFormula()));
   7.101 -/*err*/return Ast.math_string_of( getFormula() );
   7.102 +/*err*/return Ast.math_string_of(getFormula() );
   7.103    }
   7.104  
   7.105  	
     8.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EventUtil.scala	Wed Sep 06 12:50:24 2017 +0200
     8.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EventUtil.scala	Wed Sep 06 13:45:58 2017 +0200
     8.3 @@ -24,20 +24,13 @@
     8.4  object EventUtil {
     8.5    
     8.6    var foreachBoxFunction : (Graphics, DrawBox) => Unit = null
     8.7 -  
     8.8 -  
     8.9 -  
    8.10 -  
    8.11 +
    8.12    def drawBoxAt(p: Point) = {
    8.13      foreachBoxFunction = EventUtil.doInBox(p, (g, box) => {
    8.14          Box.draw(box, g, false)
    8.15        }
    8.16      )
    8.17    }
    8.18 -  
    8.19 -
    8.20 -  
    8.21 -  
    8.22    /*
    8.23     * return-value is stored in <code>foreachBoxFunction</code>
    8.24     */
    8.25 @@ -55,19 +48,11 @@
    8.26    	    f(g, box)
    8.27  	  }
    8.28  	}
    8.29 -  
    8.30    //TODOWN unused
    8.31    def CreateMouseMotionHandler(c: AstContainer) : MouseMotionListener = new MouseMotionListener() {
    8.32 -    def mouseDragged(e:MouseEvent) {
    8.33 -      
    8.34 -  	}
    8.35 -  
    8.36 -  	def mouseMoved(e: MouseEvent ) {
    8.37 -  	  
    8.38 -  	}
    8.39 -
    8.40 +    def mouseDragged(e:MouseEvent) {}
    8.41 +  	def mouseMoved(e: MouseEvent ) {}
    8.42    }
    8.43 -  
    8.44    def CreateMouseWheelHandler(c: AstContainer) : MouseWheelListener = new MouseWheelListener() {
    8.45      def mouseWheelMoved(e: MouseWheelEvent): Unit = {
    8.46        if (Settings.isZoomAllowed) {
    8.47 @@ -83,20 +68,13 @@
    8.48        c.repaint()
    8.49      }
    8.50    }
    8.51 -  
    8.52 -  
    8.53    def CreateKeyEventHandler(c: AstContainer) : KeyListener = new KeyListener () {
    8.54 -    
    8.55 -    
    8.56      def keyPressed(event: KeyEvent): Unit = {
    8.57        if (event.getKeyCode == KeyEvent.VK_BACK_SPACE) { 
    8.58          EditingUtil.parse(c, -event.getKeyCode)
    8.59        }
    8.60 -      
    8.61 -      
    8.62      }
    8.63      def keyReleased(event: KeyEvent): Unit = {
    8.64 -      
    8.65        if (AstInfoUtil.hasBox(c.getAst())) {
    8.66          println("has Box")
    8.67           if (event.getKeyCode == KeyEvent.VK_DOWN) {
    8.68 @@ -112,7 +90,6 @@
    8.69          println("has Cursor")
    8.70          EditingUtil.parse(c, -event.getKeyCode)
    8.71        }
    8.72 -     
    8.73        if (event.getKeyCode == KeyEvent.VK_DOWN) {
    8.74          TransformAstUtil.CursorChild(c)
    8.75        } else if (event.getKeyCode == KeyEvent.VK_RIGHT) {
    8.76 @@ -140,7 +117,6 @@
    8.77          Toolkit.getDefaultToolkit().getSystemClipboard().setContents(astString, null)
    8.78          EditorListenerHandler.fireNotifyIsaCheck(c)
    8.79        }
    8.80 -      
    8.81        else if (
    8.82            (event.getKeyChar >= '0' && event.getKeyChar <= '9') 
    8.83            || (event.getKeyChar >= 'a' && event.getKeyChar <= 'z')
    8.84 @@ -153,21 +129,9 @@
    8.85            event.getKeyCode == KeyEvent.VK_F2) {
    8.86          EditingUtil.parse(c, -event.getKeyCode)
    8.87        }
    8.88 -      
    8.89        if (event.getKeyCode == KeyEvent.VK_ENTER)
    8.90          println(c.getAst()) // Output ast on key enter
    8.91 -      
    8.92 -      
    8.93      }
    8.94 -    def keyTyped(event: KeyEvent): Unit = {
    8.95 -      
    8.96 -      
    8.97 -    }
    8.98 -    
    8.99 -  }
   8.100 -  
   8.101 -
   8.102 -  
   8.103 -  
   8.104 -  
   8.105 +    def keyTyped(event: KeyEvent): Unit = {}
   8.106 +  } //CreateKeyEventHandler
   8.107  }
   8.108 \ No newline at end of file
     9.1 --- a/isac-java/src/java/isac/gui/mawen/editor/Settings.scala	Wed Sep 06 12:50:24 2017 +0200
     9.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/Settings.scala	Wed Sep 06 13:45:58 2017 +0200
     9.3 @@ -1,15 +1,16 @@
     9.4  package isac.gui.mawen.editor
     9.5  
     9.6 +import isac.gui.mawen.syntax.XSyntax
     9.7 +import isac.gui.mawen.syntax.Ast._
     9.8 +import isac.util.WindowApplicationPaths
     9.9 +
    9.10 +import java.awt.Font
    9.11 +import java.awt.Graphics2D
    9.12 +import java.awt.Graphics
    9.13 +import java.awt.Rectangle
    9.14  import java.io.InputStream
    9.15  import java.util.Properties
    9.16 -import isac.util.WindowApplicationPaths
    9.17  import scala.io.Source
    9.18 -import java.awt.Rectangle
    9.19 -import isac.gui.mawen.syntax.XSyntax
    9.20 -import isac.gui.mawen.syntax.Ast._
    9.21 -import java.awt.Graphics2D
    9.22 -import java.awt.Font
    9.23 -import java.awt.Graphics
    9.24  
    9.25  /**
    9.26   * Call preset properties for editor and store LaTeX settings.
    9.27 @@ -35,14 +36,11 @@
    9.28      } catch { case e: Exception => 
    9.29        println("Error loading Property file: " + e.getMessage())
    9.30      }
    9.31 -	      
    9.32 -	      
    9.33    println("isdraggingAllowed: " + isdraggingAllowed);
    9.34    println("isZoomAllowed: " + isZoomAllowed);
    9.35    println("zoom: " + zoom);
    9.36    println("translateX: " + translateX);
    9.37    println("translateY: " + translateY);
    9.38 -  
    9.39  
    9.40    def LARGESPACE = ((( 50f / 100f ) * INITIALFONTSIZE) ).round
    9.41    def MEDIUMSPACE = ((( 30f / 100f ) * INITIALFONTSIZE) ).round
    9.42 @@ -53,20 +51,11 @@
    9.43      case 'M' => MEDIUMSPACE
    9.44      case 'F' => FRACVERTIKALSPACE
    9.45    }
    9.46 -  
    9.47 -  
    9.48    val INITIALFONTSIZE = 25
    9.49 -  
    9.50 -  //var zoom = 1f
    9.51 -  //var translateX = 15
    9.52 -  //var translateY = 15
    9.53 -  
    9.54    val POWHORIZONTALSPACE = (INITIALFONTSIZE / 100f * 8f).round
    9.55 -  
    9.56    var ast_Stringbounds = Map.empty[String, (Rectangle, Rectangle, Rectangle)]
    9.57    
    9.58    def getStringBoundOf(key: String, level: Int) : Rectangle = {
    9.59 -
    9.60      ast_Stringbounds(key).productElement(Math.min(2, level)).asInstanceOf[Rectangle].clone().asInstanceOf[Rectangle]
    9.61    }
    9.62    def getStringBoundOf(key: String, level: Int, dx: Int, dy: Int) : Rectangle =  {
    9.63 @@ -74,7 +63,6 @@
    9.64      r.translate(dx, dy)
    9.65      return r;
    9.66    }
    9.67 -  
    9.68    def fillStringbounds(ast: Ast, g: Graphics2D) {
    9.69      fillStringboundsRec(Variable(",x"), g)
    9.70      fillStringboundsRec(Variable(")"), g)
    9.71 @@ -82,7 +70,6 @@
    9.72      fillStringboundsRec(Variable("xx"), g)
    9.73      fillStringboundsRec(ast, g)
    9.74    }
    9.75 -  
    9.76    def fillStringboundsRec(ast: Ast, g: Graphics2D) : Unit = ast match {
    9.77      case Constant(str) => {
    9.78        val op = XSyntax.isa_ast(str)
    9.79 @@ -105,24 +92,13 @@
    9.80      }
    9.81      case Appl(asts) => asts.foreach(x => fillStringbounds(x, g))
    9.82    }
    9.83 -
    9.84 -  
    9.85 -  
    9.86 -  
    9.87 -  def getStringBounds (g2: Graphics2D, str: String , x: Float , y: Float ) : Rectangle = 
    9.88 -  {
    9.89 +  def getStringBounds (g2: Graphics2D, str: String , x: Float , y: Float ) : Rectangle = {
    9.90      val frc = g2.getFontRenderContext()
    9.91      val gv = g2.getFont().createGlyphVector(frc, str)
    9.92      val rect : Rectangle = gv.getPixelBounds(null, x, y)
    9.93 -
    9.94      val norm_rect = new Rectangle((rect.x / Settings.zoom).round, (rect.y / Settings.zoom).round, (rect.width / Settings.zoom).round, (rect.height / Settings.zoom).round)
    9.95 -    
    9.96      new Rectangle(norm_rect.x, norm_rect.y, norm_rect.width, norm_rect.height)
    9.97    }
    9.98 -  
    9.99 -  
   9.100 -  
   9.101 -  
   9.102    val CollorMapping: Map[Int, java.awt.Color] =  Map(
   9.103      0 -> java.awt.Color.BLACK, 
   9.104      1 -> java.awt.Color.BLACK, 
   9.105 @@ -138,8 +114,6 @@
   9.106      11 -> java.awt.Color.RED,
   9.107      12 -> java.awt.Color.YELLOW,
   9.108      13 -> new java.awt.Color(128,64,0))
   9.109 -  
   9.110 -      
   9.111    val layout = Map (
   9.112      "=" -> ("binOp","L=L",   Appl(List(Constant("HOL.eq"),   Constant("GAP"), Constant("GAP")))),
   9.113      "+" -> ("binOp","M+M",   Appl(List(Constant("Groups.plus_class.plus"),   Constant("GAP"), Constant("GAP")))),
   9.114 @@ -152,7 +126,6 @@
   9.115      "tan" -> ("UniOp","",    Appl(List(Constant("Transcendental.tan"), Constant("GAP"), Constant("GAP")))),
   9.116      "Integral" -> ("Int","", Appl(List(Constant("Integrate.Integral"), Constant("GAP"), Constant("GAP"), Constant("GAP"), Constant("GAP"))))
   9.117    )
   9.118 -  
   9.119    def layoutName(str: String): String = { 
   9.120      layout.get(str) match {
   9.121        case Some((str, _,_)) => str 
   9.122 @@ -169,5 +142,4 @@
   9.123      case Some((_, _,a)) => a 
   9.124      case None => Appl(List(Constant(o), Constant("GAP")))
   9.125    }
   9.126 -  
   9.127  }
   9.128 \ No newline at end of file
    10.1 --- a/isac-java/src/java/isac/gui/mawen/editor/TransformAstUtil.scala	Wed Sep 06 12:50:24 2017 +0200
    10.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/TransformAstUtil.scala	Wed Sep 06 13:45:58 2017 +0200
    10.3 @@ -10,44 +10,28 @@
    10.4   */
    10.5  object TransformAstUtil {
    10.6    
    10.7 -  
    10.8 -  //TODOWN remove stuff for tests
    10.9 -  def a() = Variable("a")
   10.10 -  def b() = Appl(List(Constant("+"), Variable("a"), Variable("b")))
   10.11 -  
   10.12 -  
   10.13    def AstToCursor(ast : Ast) = ast match {
   10.14      case Constant("GAP")      =>  Appl(List(Constant("CURSOR"), ast))
   10.15      case Variable(str)        =>  Appl(List(ast, Constant("CURSOR")))
   10.16      case Constant(str)        =>  Appl(List(ast, Constant("CURSOR")))
   10.17      case Appl(asts)           =>  Appl(List(ast, Constant("CURSOR")))
   10.18    }
   10.19 -  
   10.20 -  
   10.21    def ReplaceCursor(newCursor: Ast)(ast: Ast) = ast match {
   10.22      case  Appl(List(Constant("CURSOR"), a)) => newCursor
   10.23      case  Appl(List(a, Constant("CURSOR"))) => newCursor
   10.24 -    
   10.25    }
   10.26 -  
   10.27    def CursorToAst(ast : Ast) =  ast match {
   10.28      case Appl(List(Constant("CURSOR"), a)) => a
   10.29      case Appl(List(a, Constant("CURSOR"))) => a
   10.30      case _ =>  throw new AstException("CursorToAst, Cursor has a false structure(required: Appl(List(Constant(\"CURSOR\"), ast), get: " + raw_string_of(ast) + ")")
   10.31    }
   10.32 -  
   10.33    def Delete(ast : Ast) = Constant("GAP")
   10.34 -  
   10.35    def Box(ast: Ast) = Appl(List(Constant("BOX.MAIN.0"), ast))
   10.36    
   10.37    def UnBox(ast: Ast) = ast match {
   10.38       case Appl(List(Constant(str), a)) if str.startsWith("BOX") => a
   10.39       case _ =>  throw new AstException("UnBox, Box has a false structure(required: Appl(List(Constant(\"BOX.1\"), ast), get: " + raw_string_of(ast) + ")")
   10.40    }
   10.41 -  
   10.42 -  
   10.43 -  
   10.44 -  
   10.45    def BoxNextChild(c: AstContainer) = {
   10.46       val boxAst = AstInfoUtil.FindBox(c.getAst())
   10.47       if (boxAst != null) {// check if there is a box
   10.48 @@ -83,7 +67,6 @@
   10.49         }
   10.50       }
   10.51    }
   10.52 -  
   10.53    def CursorNextChild(c: AstContainer) = {
   10.54       val boxAst = AstInfoUtil.FindCursor(c.getAst())
   10.55       if (boxAst != null) {
   10.56 @@ -119,11 +102,7 @@
   10.57         }
   10.58       }
   10.59    }
   10.60 -  
   10.61 -  
   10.62 -  
   10.63    def Update(root : Ast, replace : Ast, updatefunc: Ast => Ast ) : Ast = root match {
   10.64 -    
   10.65      case Appl(List(a))                                             if  a eq replace                              => Appl(List(updatefunc(replace)))
   10.66      case Appl(a :: param)                                          if  a eq replace                              => Appl(List(updatefunc(replace)) :::  param)
   10.67      case Appl(param :: a :: Nil)                                   if  a eq replace                              => Appl(param :: List(updatefunc(replace)) )
   10.68 @@ -141,7 +120,6 @@
   10.69      case a => {      
   10.70        return a
   10.71      }
   10.72 -    
   10.73    }
   10.74    
   10.75  }
   10.76 \ No newline at end of file