OptimizedNetworkPainter constructor
OptimizedNetworkPainter({
- required int particleCount,
- required List<
Particle> particles, - required Offset? touchPoint,
- required double lineDistance,
- required Color particleColor,
- required Color lineColor,
- required Color touchColor,
- required bool touchActivation,
- required double lineWidth,
- required bool isComplex,
- required bool fill,
- required bool drawNetwork,
- 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,
);
}