isac-java/src/java/isac/gui/mawen/editor/BoxUtil.scala
changeset 5213 1f3173a59903
parent 5206 766b810ae181
child 5214 733780043a0a
equal deleted inserted replaced
5212:51971c00458f 5213:1f3173a59903
    17  * a <code>Box.name</code>, which refers to
    17  * a <code>Box.name</code>, which refers to
    18  * specific layouts defined in <code>CalcUtil</code>.
    18  * specific layouts defined in <code>CalcUtil</code>.
    19  */
    19  */
    20 object BoxUtil {
    20 object BoxUtil {
    21 
    21 
    22   // TODOWN rename "draw"
    22   def draw(box : DrawBox, g: Graphics) : Unit = box.name match {
    23   def Draw(box : DrawBox, g: Graphics) : Unit = box.name match {
       
    24     case "GAP"                         => drawGap(g, box) 
    23     case "GAP"                         => drawGap(g, box) 
    25     case "CURSOR"                      => drawCursor(g, box)
    24     case "CURSOR"                      => drawCursor(g, box)
    26     case "Groups.plus_class.plus"      => drawPlus(g, box)   //TODOWN "+" 
    25     case "Groups.plus_class.plus"      => drawPlus(g, box)   //TODOWN "+" 
    27     case "Fields.inverse_class.divide" => drawDivide(g, box) //TODOWN "/"
    26     case "Fields.inverse_class.divide" => drawDivide(g, box) //TODOWN "/"
    28     case ""                            => {
    27     case ""                            => {
    29       drawBox(box, g)
    28       drawBox(box, g)
    30       box.children.foreach( Draw(_, g) )
    29       box.children.foreach( draw(_, g) )
    31     }
    30     }
    32     case _ =>  {
    31     case _ =>  {
    33       drawString(g, box)
    32       drawString(g, box)
    34       box.children.foreach( Draw(_, g) )
    33       box.children.foreach( draw(_, g) )
    35     }
    34     }
    36   }
    35   }
    37   def drawGap(g: Graphics, box : DrawBox) {
    36   def drawGap(g: Graphics, box : DrawBox) {
    38     g.fillRoundRect(box.x, box.y- box.height, box.width, box.height, 15, 15)
    37     g.fillRoundRect(box.x, box.y- box.height, box.width, box.height, 15, 15)
    39     drawBox(box, g)
    38     drawBox(box, g)
    44         g.setColor(Color.RED)
    43         g.setColor(Color.RED)
    45         g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    44         g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    46         g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x, box.y - box.height)
    45         g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x, box.y - box.height)
    47 
    46 
    48         g.setColor(Color.BLACK)
    47         g.setColor(Color.BLACK)
    49         if (box.children.length >= 1) Draw(box.children.head, g)
    48         if (box.children.length >= 1) draw(box.children.head, g)
    50       }
    49       }
    51       case Appl(List(a, Constant("CURSOR"))) => {
    50       case Appl(List(a, Constant("CURSOR"))) => {
    52         g.setColor(Color.RED)
    51         g.setColor(Color.RED)
    53         g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    52         g.asInstanceOf[Graphics2D].drawLine(box.x, box.y, box.x + box.width , box.y)
    54         g.asInstanceOf[Graphics2D].drawLine(box.x+ box.width, box.y, box.x + box.width, box.y - box.height)
    53         g.asInstanceOf[Graphics2D].drawLine(box.x+ box.width, box.y, box.x + box.width, box.y - box.height)
    55         
    54         
    56         g.setColor(Color.BLACK)
    55         g.setColor(Color.BLACK)
    57         if (box.children.length >= 1)
    56         if (box.children.length >= 1)
    58           Draw(box.children.head, g)
    57           draw(box.children.head, g)
    59       }
    58       }
    60     }
    59     }
    61     case _ => {
    60     case _ => {
    62       if (box.children.length >= 1)
    61       if (box.children.length >= 1)
    63           Draw(box.children.head, g)
    62           draw(box.children.head, g)
    64     }
    63     }
    65   }
    64   }
    66   // TODOWN layout_class "linear"
    65   // TODOWN layout_class "linear"
    67   def drawPlus(g: Graphics, box : DrawBox) {
    66   def drawPlus(g: Graphics, box : DrawBox) {
    68     val font_var = new Font("CMCSC8", Font.PLAIN,  CalcUtil.fontsizeOf(box.level))
    67     val font_var = new Font("CMCSC8", Font.PLAIN,  CalcUtil.fontsizeOf(box.level))