View Javadoc
1   package demo;
2   
3   import java.util.Iterator;
4   
5   import org.djutils.draw.bounds.Bounds3d;
6   import org.djutils.draw.line.LineSegment2d;
7   import org.djutils.draw.point.Point2d;
8   import org.djutils.draw.point.Point3d;
9   
10  /**
11   * DrawableDemos.java.
12   * <p>
13   * Copyright (c) 2020-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14   * BSD-style license. See <a href="https://djutils.org/docs/current/djutils/licenses.html">DJUTILS License</a>.
15   * </p>
16   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   * @author <a href="https://www.tudelft.nl/pknoppers">Peter Knoppers</a>
18   */
19  public final class DrawableDemos
20  {
21      /**
22       * Do not instantiate.
23       */
24      private DrawableDemos()
25      {
26          // Do not instantiate
27      }
28  
29      /**
30       * Demonstrate the Drawable interface.
31       * @param args String...; the command line arguments; not used
32       */
33      public static void main(final String... args)
34      {
35          Point2d p = new Point2d(12.34, 23.45);
36          System.out.println("The iterator of a point yields one point (the point itself):");
37          for (Iterator<? extends Point2d> iterator = p.getPoints(); iterator.hasNext();)
38          {
39              System.out.println(iterator.next());
40          }
41          LineSegment2d ls = new LineSegment2d(12.34, 23.45, 34.56, 45.67);
42          System.out.println("The iterator of a line segment yields two points (the start point and the end point):");
43          for (Iterator<? extends Point2d> iterator = ls.getPoints(); iterator.hasNext();)
44          {
45              System.out.println(iterator.next());
46          }
47          Bounds3d b = new Bounds3d(12.34, 23.45, 34.56, 45.67, 56.78, 67.89);
48          System.out.println("The iterator of a bounds3d yields eight points (the vertices of the bounds):");
49          for (Iterator<? extends Point3d> iterator = b.getPoints(); iterator.hasNext();)
50          {
51              System.out.println(iterator.next());
52          }
53          
54          Point2d point2d = new Point2d(12.34, 23.45);
55          System.out.println("2D object has two dimensions: " + point2d.getDimensions());
56          Point3d point3d = new Point3d(12.34, 23.45, 34.56);
57          System.out.println("3D object has three dimensions: " + point3d.getDimensions());
58  
59      }
60  }