import 'package:json_annotation/json_annotation.dart';

part 'job_handwriting.g.dart';

@JsonSerializable()
class JobHandwriting extends Object {
  @JsonKey(name: 'lattices')
  List<Lattices> lattices;

  @JsonKey(name: 'paperPicture')
  String paperPicture;

  @JsonKey(name: 'pageNum')
  int pageNum;

  @JsonKey(name: 'pageCount')
  int pageCount;

  JobHandwriting(this.lattices, this.paperPicture, this.pageNum, this.pageCount);

  factory JobHandwriting.fromJson(Map<String, dynamic> srcJson) => _$JobHandwritingFromJson(srcJson);

  Map<String, dynamic> toJson() => _$JobHandwritingToJson(this);
}

@JsonSerializable()
class Lattices extends Object {
  // 笔画
  @JsonKey(name: 'stroke')
  int stroke;

  @JsonKey(name: 'x')
  double x;

  @JsonKey(name: 'y')
  double y;

  @JsonKey(name: 'time')
  int time;

  @JsonKey(name: 'intervalTime')
  int intervalTime;

  @JsonKey(name: 'initialization')
  bool initialization;

  Lattices(this.stroke, this.x, this.y, this.time, [this.intervalTime = 0, this.initialization = false]);

  factory Lattices.fromJson(Map<String, dynamic> srcJson) => _$LatticesFromJson(srcJson);

  Map<String, dynamic> toJson() => _$LatticesToJson(this);

  /**
   * 根据基准初始化坐标数据
   * @param double scaleRatio
   */
  void toInitialization(double scaleRatio) {
    x = x * scaleRatio;
    y = y * scaleRatio;
    initialization = true;
  }
}
