Code refactoring
[sixth.git] / src / main / java / eu / svjatoslav / sixth / core / Main.java
1 /*
2  * Sixth core user interface. Author: Svjatoslav Agejenko.
3  * This project is released under Creative Commons Zero (CC0) license.
4  */
5
6 package eu.svjatoslav.sixth.core;
7
8 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
9 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
10 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
11 import eu.svjatoslav.sixth.e3d.gui.Avatar;
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 Main {
22
23     /**
24      * Creates nice looking neon grid. Makes it easier to navigate in space.
25      *
26      * @return grid
27      */
28     private static Grid2D createGrid() {
29         final Transform location = new Transform(
30                 new Point3D(0, 100, 0),
31                 0,
32                 Math.PI / 2);
33
34         return new Grid2D(location,
35                 new Rectangle(2000),
36                 10,
37                 10,
38                 new LineAppearance(10, new Color("00b3ad")));
39     }
40
41     public static void main(final String[] args) {
42
43         final ViewFrame viewFrame = new ViewFrame();
44         final ViewPanel viewPanel = viewFrame.getViewPanel();
45
46         final ShapeCollection rootShapeCollection = viewFrame.getViewPanel()
47                 .getRootShapeCollection();
48
49         rootShapeCollection.addShape(createGrid());
50         rootShapeCollection.addShape(createTextEditor(viewPanel));
51
52         setAvatarStartLocation(viewPanel.getAvatar());
53     }
54
55     private static TextEditComponent createTextEditor(ViewPanel viewPanel) {
56         return new TextEditComponent(
57                     new Transform(new Point3D(0, 0, 0)), viewPanel,
58                     new Point2D(200, 120));
59     }
60
61     private static void setAvatarStartLocation(Avatar avatar) {
62         avatar.setLocation(new Point3D(500, -300, -800));
63         avatar.setAngleXZ(0.6);
64         avatar.setAngleYZ(-0.5);
65     }
66 }