OptimizedNetworkPainter constructor

OptimizedNetworkPainter({
  1. required int particleCount,
  2. required List<Particle> particles,
  3. required Offset? touchPoint,
  4. required double lineDistance,
  5. required Color particleColor,
  6. required Color lineColor,
  7. required Color touchColor,
  8. required bool touchActivation,
  9. required double lineWidth,
  10. required bool isComplex,
  11. required bool fill,
  12. required bool drawNetwork,
  13. bool showQuadTree = false,
})

Constructor with dependency initialization

Implementation

OptimizedNetworkPainter({
  required this.particleCount,
  required this.particles,
  required this.touchPoint,
  required this.lineDistance,
  required this.particleColor,
  required this.lineColor,
  required this.touchColor,
  required this.touchActivation,
  required this.lineWidth,
  required this.isComplex,
  required this.fill,
  required this.drawNetwork,
  this.showQuadTree = false, // Default to false
}) {
  // Get viewport dimensions for QuadTree initialization
  // final mw = MediaQuery.of(context).size.width + 10;
  // final mh = double.infinity ;

  // final s = Size(width, height)

  // Initialize QuadTree with viewport bounds
  _quadTree = CompressedQuadTree(
    Rectangle(
      -5,
      -5,
      double.maxFinite,
      double.maxFinite,
    ), // Placeholder, will be updated in paint
  );
  // Initialize particle paint
  particlePaint = Paint()
    ..style = fill ? PaintingStyle.fill : PaintingStyle.stroke
    ..color = particleColor;

  // Initialize line paint with stroke configuration
  linePaint = Paint()
    ..style = fill ? PaintingStyle.stroke : PaintingStyle.fill
    ..strokeWidth = lineWidth
    ..color = lineColor; // Added line color

  // Initialize performance tracking components
  _accelerationTracker = AccelerationTracker();
  _quadTreeManager = AdaptiveQuadTreeManager();
  _poolManager = PoolManager.getInstance();
  _intListPool = _poolManager.intListPool;
  _connectionDataPool = _poolManager.connectionDataPool;

  // Initialize sub-components with dependency injection
  _distanceCalculator = DistanceCalculator();
  _touchHandler = TouchInteractionHandler(
    particles: particles,
    touchPoint: touchPoint,
    lineDistance: lineDistance,
    touchColor: touchColor,
    linePaint: linePaint,
  );
}