Code refactoring
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 21 May 2020 21:42:21 +0000 (00:42 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 21 May 2020 21:42:21 +0000 (00:42 +0300)
src/main/java/eu/svjatoslav/sixth/core/Main.java

index c323932..ecec0a1 100644 (file)
@@ -8,6 +8,7 @@ package eu.svjatoslav.sixth.core;
 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
+import eu.svjatoslav.sixth.e3d.gui.Avatar;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
@@ -19,6 +20,11 @@ import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid2D
 
 public class Main {
 
+    /**
+     * Creates nice looking neon grid. Makes it easier to navigate in space.
+     *
+     * @return grid
+     */
     private static Grid2D createGrid() {
         final Transform location = new Transform(
                 new Point3D(0, 100, 0),
@@ -37,21 +43,24 @@ public class Main {
         final ViewFrame viewFrame = new ViewFrame();
         final ViewPanel viewPanel = viewFrame.getViewPanel();
 
-        final ShapeCollection shapeCollection = viewFrame.getViewPanel()
+        final ShapeCollection rootShapeCollection = viewFrame.getViewPanel()
                 .getRootShapeCollection();
 
-        shapeCollection.addShape(createGrid());
+        rootShapeCollection.addShape(createGrid());
+        rootShapeCollection.addShape(createTextEditor(viewPanel));
 
+        setAvatarStartLocation(viewPanel.getAvatar());
+    }
 
-        final TextEditComponent textEditor = new TextEditComponent(
-                new Transform(new Point3D(0, 0, 0)), viewPanel,
-                new Point2D(200, 120));
-
-        shapeCollection.addShape(textEditor);
-
-        viewPanel.getAvatar().setLocation(new Point3D(500, -300, -800));
-        viewPanel.getAvatar().setAngleXZ(0.6);
-        viewPanel.getAvatar().setAngleYZ(-0.5);
+    private static TextEditComponent createTextEditor(ViewPanel viewPanel) {
+        return new TextEditComponent(
+                    new Transform(new Point3D(0, 0, 0)), viewPanel,
+                    new Point2D(200, 120));
+    }
 
+    private static void setAvatarStartLocation(Avatar avatar) {
+        avatar.setLocation(new Point3D(500, -300, -800));
+        avatar.setAngleXZ(0.6);
+        avatar.setAngleYZ(-0.5);
     }
 }