e50c27f398f80f5f58474ddd7b1a7a9f6294de90
[sixth-3d-demos.git] / src / main / java / eu / svjatoslav / sixth / e3d / examples / TextEditorDemo.java
1 /*
2  * Sixth - System for data storage, computation, exploration and interaction.
3  * Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 3 of the GNU Lesser General Public License
7  * or later as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.sixth.e3d.examples;
11
12 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
13 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
14 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
15 import eu.svjatoslav.sixth.e3d.geometry.Transform;
16 import eu.svjatoslav.sixth.e3d.gui.ViewContext;
17 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
18 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
19 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
20 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
21 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
22 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid2D;
23
24 public class TextEditorDemo {
25
26     private static Grid2D createGrid() {
27         final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
28                 Math.PI / 2);
29
30         final Rectangle rectangle = new Rectangle(2000);
31         final LineAppearance appearance = new LineAppearance(10, new Color(
32                 "00b3ad"));
33
34         return new Grid2D(transform, rectangle, 10, 10, appearance);
35     }
36
37     public static void main(final String[] args) {
38
39         final ViewFrame viewFrame = new ViewFrame();
40         final ViewContext viewContext = viewFrame.getView().getContext();
41
42         final ShapeCollection shapeCollection = viewFrame.getView()
43                 .getContext().getRootShapeCollection();
44
45         shapeCollection.addShape(createGrid());
46
47         final double m = 1.5;
48         for (double z = -500 * m; z <= (500 * m); z += 250 * m)
49             for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
50
51                 final TextEditComponent textEditor = new TextEditComponent(
52                         new Transform(new Point3D(x, 0, z)), viewContext,
53                         new Point2D(200, 120));
54
55                 shapeCollection.addShape(textEditor);
56             }
57
58         viewContext.getAvatar().setLocation(new Point3D(500, -300, -800));
59         viewContext.getAvatar().setAngleXZ(0.6);
60         viewContext.getAvatar().setAngleYZ(-0.5);
61
62     }
63 }