7eb519cf68d74c93b3fc070b5840d23246cf325a
[sixth-3d-demos.git] / src / main / java / eu / svjatoslav / sixth / e3d / examples / TextEditorDemo.java
1 /*
2  * Sixth 3D engine demos. Author: Svjatoslav Agejenko. 
3  * This project is released under Creative Commons Zero (CC0) license.
4  *
5 */
6
7 package eu.svjatoslav.sixth.e3d.examples;
8
9 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
10 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
11 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
12 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
13 import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
14 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
15 import eu.svjatoslav.sixth.e3d.math.Transform;
16 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
17 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
18 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
19 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid2D;
20
21 public class TextEditorDemo {
22
23     private static Grid2D createGrid() {
24         final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
25                 Math.PI / 2);
26
27         final Rectangle rectangle = new Rectangle(2000);
28         final LineAppearance appearance = new LineAppearance(10, new Color(
29                 "00b3ad"));
30
31         return new Grid2D(transform, rectangle, 10, 10, appearance);
32     }
33
34     public static void main(final String[] args) {
35
36         final ViewFrame viewFrame = new ViewFrame();
37         final ViewPanel viewPanel = viewFrame.getViewPanel();
38
39         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
40                 .getRootShapeCollection();
41
42         shapeCollection.addShape(createGrid());
43
44         final double m = 1.5;
45         for (double z = -500 * m; z <= (500 * m); z += 250 * m)
46             for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
47
48                 final TextEditComponent textEditor = new TextEditComponent(
49                         new Transform(new Point3D(x, 0, z)), viewPanel,
50                         new Point2D(200, 120));
51
52                 shapeCollection.addShape(textEditor);
53             }
54
55         viewPanel.getAvatar().setLocation(new Point3D(500, -300, -800));
56         viewPanel.getAvatar().setAngleXZ(0.6);
57         viewPanel.getAvatar().setAngleYZ(-0.5);
58
59     }
60 }