import 'dart:ui';

import 'package:fis_measure/interfaces/date_types/point.dart';
import 'package:fis_measure/interfaces/process/items/item.dart';
import 'package:fis_measure/interfaces/process/items/item_feature.dart';
import 'package:fis_measure/interfaces/process/visuals/visual_area.dart';
import 'package:flutter/foundation.dart';

abstract class MeasureItemFeature implements IMeasureItemFeature {
  late IMeasureItem _refItem;
  late List<DPoint> _innerPoints;
  IVisualArea? _hostVisualArea;
  bool _isActive = true;

  @protected
  final paintPan = Paint()
    ..color = const Color.fromARGB(255, 255, 255, 0)
    ..isAntiAlias = true
    ..strokeWidth = 2
    ..style = PaintingStyle.stroke;

  MeasureItemFeature(IMeasureItem refItem) {
    _refItem = refItem;
    _innerPoints = [];
  }
  @override
  List<DPoint> get innerPoints => _innerPoints;

  @override
  IMeasureItem get refItem => _refItem;

  ///   所在区域
  IVisualArea? get hostVisualArea => _hostVisualArea;
  set hostVisualArea(IVisualArea? value) {
    if (value != _hostVisualArea) {
      _hostVisualArea = value;
    }
  }

  @override
  bool get isActive => _isActive;
  set isActive(bool value) {
    if (value != _isActive) {
      _isActive = value;
    }
  }

  @protected
  DPoint convert2ViewPoint(Size size, DPoint logicPoint) {
    final x = size.width * logicPoint.x;
    final y = size.height * logicPoint.y;
    return DPoint(x, y);
  }
}
