isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala
changeset 5202 a4d087dd5e5d
parent 5201 5c61af5d1fc8
child 5203 8fcdb69044d9
     1.1 --- a/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala	Thu Sep 07 09:27:43 2017 +0200
     1.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala	Thu Sep 07 09:41:06 2017 +0200
     1.3 @@ -1,16 +1,16 @@
     1.4  package isac.gui.mawen.editor
     1.5  
     1.6 +import isac.gui.mawen.editor.Box._
     1.7 +import isac.gui.mawen.syntax.Ast._
     1.8 +import isac.gui.mawen.syntax.Ast
     1.9 +import isac.gui.mawen.syntax.XSyntax
    1.10  import java.awt.Graphics
    1.11  import java.awt.Color
    1.12 +import java.awt.Dimension
    1.13 +import java.awt.Font
    1.14 +import java.awt.Graphics2D
    1.15 +import javax.swing.JButton
    1.16  import javax.swing.JTextField
    1.17 -import java.awt.Dimension
    1.18 -import javax.swing.JButton
    1.19 -import isac.gui.mawen.syntax.Ast._
    1.20 -import isac.gui.mawen.syntax.Ast
    1.21 -import java.awt.Font
    1.22 -import isac.gui.mawen.editor.Box._
    1.23 -import java.awt.Graphics2D
    1.24 -import isac.gui.mawen.syntax.XSyntax
    1.25  
    1.26  /**
    1.27   * <code>paint</code>s a <code>Box</code> according to 
    1.28 @@ -18,10 +18,7 @@
    1.29   * specific layouts defined in <code>CalcUtil</code>.
    1.30   */
    1.31  object BoxUtil {
    1.32 -  
    1.33 -  
    1.34 -  
    1.35 -  
    1.36 +
    1.37    def Draw(box : DrawBox, g: Graphics) : Unit = box.name match {
    1.38      case "GAP"                         => drawGap(g, box) 
    1.39      case "CURSOR"                      => drawCursor(g, box)
    1.40 @@ -36,12 +33,9 @@
    1.41        box.children.foreach( Draw(_, g) )
    1.42      }
    1.43    }
    1.44 -  
    1.45 -  
    1.46    def drawGap(g: Graphics, box : DrawBox) {
    1.47      g.fillRoundRect(box.x, box.y- box.height, box.width, box.height, 15, 15)
    1.48      drawBox(box, g)
    1.49 -    
    1.50    }
    1.51    def drawCursor(g: Graphics, box : DrawBox) = System.currentTimeMillis() match {
    1.52      case n if (n / 250) % 1 == 0  => box.ast match {
    1.53 @@ -49,19 +43,10 @@
    1.54          g.setColor(Color.RED)
    1.55          g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    1.56          g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x, box.y - box.height)
    1.57 -        
    1.58 -        
    1.59 -  //      g.drawRect(box.x, box.y - box.height, box.width, box.height)
    1.60 +
    1.61          g.setColor(Color.BLACK)
    1.62 -        if (box.children.length >= 1)
    1.63 -          Draw(box.children.head, g)
    1.64 -      
    1.65 -  		
    1.66 -  //		  Box.drawBox(box, g)
    1.67 -        
    1.68 -        
    1.69 +        if (box.children.length >= 1) Draw(box.children.head, g)
    1.70        }
    1.71 -      
    1.72        case Appl(List(a, Constant("CURSOR"))) => {
    1.73          g.setColor(Color.RED)
    1.74          g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    1.75 @@ -71,28 +56,19 @@
    1.76          if (box.children.length >= 1)
    1.77            Draw(box.children.head, g)
    1.78        }
    1.79 -      
    1.80      }
    1.81      case _ => {
    1.82        if (box.children.length >= 1)
    1.83            Draw(box.children.head, g)
    1.84      }
    1.85 -    
    1.86    }
    1.87 -    
    1.88 -    
    1.89 -    
    1.90 -    
    1.91 -  
    1.92    def drawPlus(g: Graphics, box : DrawBox) {
    1.93      val font_var = new Font("CMCSC8", Font.PLAIN,  CalcUtil.fontsizeOf(box.level))
    1.94      g.setFont(font_var)
    1.95      
    1.96      g.drawString("+", box.x0, box.y0)
    1.97      drawBox(box, g)
    1.98 -
    1.99    }
   1.100 -  
   1.101    def drawDivide(g: Graphics, box : DrawBox) {
   1.102      g.drawLine(box.x, box.y, box.x + box.width, box.y)
   1.103      drawBox(box, g)
   1.104 @@ -106,7 +82,6 @@
   1.105          g.setFont(font_var)
   1.106          g.drawString(charIndex.toChar.toString(), box.x0, box.y0)
   1.107          drawBox(box, g)
   1.108 -        
   1.109        }
   1.110        case None => {
   1.111          // Ident
   1.112 @@ -122,8 +97,6 @@
   1.113        }
   1.114      }
   1.115  
   1.116 -    
   1.117 -    
   1.118    }
   1.119    
   1.120