Class DirectRendererHitTester
Adapts DirectCanvasRenderer hit testing to the IGraphHitTester interface.
public class DirectRendererHitTester : IGraphHitTester
- Inheritance
-
DirectRendererHitTester
- Implements
- Inherited Members
Remarks
This adapter bridges the gap between the existing DirectCanvasRenderer hit testing (which returns separate results per element type) and the new unified IGraphHitTester interface (which returns a single GraphHitTestResult).
Coordinate Space: DirectCanvasRenderer expects screen/viewport coordinates and converts internally. This adapter expects canvas coordinates and converts to screen coordinates for the renderer.
Priority Order (determines actual hit priority):
- Node resize handles (highest - small targets on selected nodes)
- Shape resize handles (small targets on selected shapes)
- Edge endpoint handles (for reconnection)
- Ports (small targets)
- Nodes
- Edges
- Shapes (lowest - background elements)
Note: Since this hit tester returns a single topmost result, the InputDispatcher processor priorities are not used for determining which element is hit. Priority is enforced entirely by this class's if/else chain ordering.
Constructors
DirectRendererHitTester(Func<DirectCanvasRenderer?>, ViewportState)
Creates a new hit tester that wraps a DirectCanvasRenderer.
public DirectRendererHitTester(Func<DirectCanvasRenderer?> getRenderer, ViewportState viewport)
Parameters
getRendererFunc<DirectCanvasRenderer>Function to get the current renderer (may be null if not initialized).
viewportViewportStateThe viewport state for coordinate conversion.
Properties
InputCoordinateSpace
The coordinate space expected for hit test inputs.
Standard implementations expect Canvas coordinates. Callers using screen coordinates (e.g., from pointer events) must convert using ScreenToCanvas(double, double) first.
public CoordinateSpace InputCoordinateSpace { get; }
Property Value
Methods
HitTest(Point)
Performs a comprehensive hit test against all graph elements.
public GraphHitTestResult HitTest(Point canvasPosition)
Parameters
canvasPositionPoint
Returns
- GraphHitTestResult
The hit test result identifying what was hit. If nothing specific was hit, returns a result with Canvas.
HitTest(Point, params HitTargetType[])
Performs a hit test filtering to specific element types.
public GraphHitTestResult HitTest(Point position, params HitTargetType[] targetTypes)
Parameters
positionPointPosition to test.
targetTypesHitTargetType[]Which element types to consider.
Returns
- GraphHitTestResult
The hit test result, only matching specified types.
HitTest(Point, double, double, double)
Performs a hit test with custom tolerance values.
public GraphHitTestResult HitTest(Point position, double nodeTolerance = 0, double edgeTolerance = 5, double portTolerance = 8)
Parameters
positionPointPosition to test.
nodeTolerancedoubleExtra tolerance for node bounds.
edgeTolerancedoubleExtra tolerance for edge paths.
portTolerancedoubleExtra tolerance for port targets.
Returns
- GraphHitTestResult
The hit test result.