Added mutable writing functions. Vertical and Horizontal

def generate(background: Background, source: String, targetAreaInfo: TargetAreaInfo, alignVertical:Vertical, alignHorizontal: Horizontal, setFontInfo: String) {
  val backImage = ImageIO.read(new File(backImagePath(background)))
  val image = new BufferedImage(backImage.getWidth, backImage.getHeight, BufferedImage.TYPE_INT_ARGB)
  val g = image.createGraphics.asInstanceOf[Graphics2D]

    // antialiasing
    g.setRenderingHint(
      RenderingHints.KEY_TEXT_ANTIALIASING,
      RenderingHints.VALUE_TEXT_ANTIALIAS_ON)

    g.drawImage(backImage, 0, 0, null)

    g.setColor(Color.WHITE)
    g.fillRect(targetAreaInfo.xt, targetAreaInfo.yt, targetAreaInfo.xb - targetAreaInfo.xt, targetAreaInfo.yb - targetAreaInfo.yt)

    g.setColor(classOf[Color].getField(setFontInfo.toUpperCase).get(null).asInstanceOf[Color])

    /** For immutable VERTICAL */
    //immutableVerticalWrite(g, source, targetAreaInfo, alignVertical, alignHorizontal)

    /** For immutable HORIZONTAL */
    immutableHorizontalWrite(g, source, targetAreaInfo, alignVertical, alignHorizontal)

    /** For mutable Vertical */
    //mutableVerticalWrite(g, source, targetAreaInfo, alignVertical, alignHorizontal)

    /** For mutable Horizontal */
    //mutableHorizontalWrite(g, source, targetAreaInfo, alignVertical, alignHorizontal)

    ImageIO.write(image, "PNG", new File(output))
    g.dispose()
  }

  generate(
    Background("B"),
    "パターン認識ビャムバスレン教科書情報制御システムパターン認識ビャムバスレン教科書情報制御システム",
    //TargetAreaInfo(1415, 166, 1486, 553, 12),
    TargetAreaInfo(300, 400, 1200, 500, 20),
    // TargetAreaInfo(400, 300, 600, 900, 24),
    //TargetAreaInfo(300, 300, 900, 500, 24),
    Vertical.CenterBottom,
    Horizontal.CenterRight,
    setFontInfo
    )