clause method

  1. @override
CommandClause clause()
override

Implementation

@override
CommandClause clause() {
  int textLength = 0;
  textLength = _content.length;

  int startx, starty, endx, endy, height;
  startx = starty = endx = endy = height = 0;

  switch (_rotation) {
    case CRotation.rotation_90:
      startx = _x;
      starty = (_y - textLength * (_font.getHeight() / 2)).toInt();
      endx = _x + _font.getHeight();
      endy = (_y - textLength * (_font.getHeight() / 2)).toInt();
      height = (textLength * (_font.getHeight() / 2)).toInt();
      break;
    case CRotation.rotation_180:
      startx = (_x - textLength * (_font.getHeight() / 2)).toInt();
      starty = _y - _font.getHeight();
      endx = _x;
      endy = _y - _font.getHeight();
      height = _font.getHeight();
      break;
    case CRotation.rotation_270:
      startx = _x - _font.getHeight();
      starty = _y;
      endx = _x;
      endy = _y;
      height = (textLength * (_font.getHeight() / 2)).toInt();
      break;
    default:
      startx = _x;
      starty = _y;
      endx = (_x + textLength * (_font.getHeight() / 2)).toInt();
      endy = _y;
      height = _font.getHeight();
      break;
  }
  return CPCLCommand(header: header())
      .appendNumber(startx)
      .appendNumber(starty)
      .appendNumber(endx)
      .appendNumber(endy)
      .appendNumber(height)
      .clause();
}