1 package org.opentrafficsim.draw;
2
3 import org.djutils.draw.bounds.Bounds2d;
4 import org.djutils.draw.line.PolyLine2d;
5 import org.djutils.draw.point.Point2d;
6 import org.opentrafficsim.base.geometry.OtsShape;
7
8
9
10
11
12
13
14
15
16 public interface ClickableLineLocatable extends ClickableLocatable
17 {
18
19 @Override
20 default Bounds2d getBounds()
21 {
22 OtsShape shape = getShape();
23 return new Bounds2d(shape.getMaxX() - shape.getMinX(), shape.getMaxY() - shape.getMinY())
24 {
25
26 private static final long serialVersionUID = 20241006L;
27
28 @Override
29 public boolean contains(final double x, final double y)
30 {
31 Point2d point = new Point2d(x, y);
32 return getLine().closestPointOnPolyLine(point).distance(point) < 0.5 * EXPANSE;
33 }
34 };
35 }
36
37
38
39
40
41
42 PolyLine2d getLine();
43
44 }