1 package demo;
2
3 import java.util.Collection;
4 import java.util.Iterator;
5 import java.util.LinkedHashSet;
6
7 import org.djutils.draw.Drawable2d;
8 import org.djutils.draw.bounds.Bounds2d;
9 import org.djutils.draw.line.LineSegment2d;
10 import org.djutils.draw.line.PolyLine2d;
11 import org.djutils.draw.line.Ray2d;
12 import org.djutils.draw.point.Point2d;
13
14
15
16
17
18
19
20
21
22
23 public final class BoundsDemos
24 {
25
26
27
28 private BoundsDemos()
29 {
30
31 }
32
33
34
35
36
37 public static void main(final String[] args)
38 {
39 Bounds2d b1 = new Bounds2d(3.4, 6.7, -5.6, 2.3);
40 System.out.println("b1: " + b1);
41 Bounds2d b2 = new Bounds2d(12.3, 23.4);
42 System.out.println("b2: " + b2);
43 PolyLine2d line = new PolyLine2d(new Point2d(1, 2), new Point2d(3, 4), new Point2d(-5, 12));
44 Bounds2d b3 = new Bounds2d(line.getPoints());
45 System.out.println("b3: " + b3);
46 Bounds2d b4 = line.getBounds();
47 System.out.println("b4: " + b4);
48 Point2d[] pointArray = new Point2d[] { new Point2d(1, 2), new Point2d(3, 4), new Point2d(-5, 12) };
49 Bounds2d b5 = new Bounds2d(pointArray);
50 System.out.println("b5: " + b5);
51 Collection<Drawable2d> drawableCollection = new LinkedHashSet<>();
52 drawableCollection.add(new Point2d(1, 2));
53 drawableCollection.add(new Point2d(3, 4));
54 drawableCollection.add(new Point2d(-5, 12));
55 Bounds2d b6 = new Bounds2d(drawableCollection);
56 System.out.println("b6: " + b6);
57 Bounds2d b7 = new Bounds2d(new Point2d(1, 2), new LineSegment2d(3, 4, -5, 12));
58 System.out.println("b7: " + b7);
59
60 Bounds2d bounds = new Bounds2d(new Ray2d(1, 2, Math.toRadians(45)));
61 for (Iterator<Point2d> iterator = bounds.getPoints(); iterator.hasNext();)
62 {
63 System.out.println(iterator.next());
64 }
65 }
66 }