Code refactoring
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 28 May 2021 23:21:59 +0000 (02:21 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 28 May 2021 23:21:59 +0000 (02:21 +0300)
src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java

index 7eb519c..fa8630d 100644 (file)
@@ -20,17 +20,6 @@ import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid2D
 
 public class TextEditorDemo {
 
-    private static Grid2D createGrid() {
-        final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
-                Math.PI / 2);
-
-        final Rectangle rectangle = new Rectangle(2000);
-        final LineAppearance appearance = new LineAppearance(10, new Color(
-                "00b3ad"));
-
-        return new Grid2D(transform, rectangle, 10, 10, appearance);
-    }
-
     public static void main(final String[] args) {
 
         final ViewFrame viewFrame = new ViewFrame();
@@ -39,8 +28,25 @@ public class TextEditorDemo {
         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
                 .getRootShapeCollection();
 
-        shapeCollection.addShape(createGrid());
+        setAvatarLocation(viewPanel);
+
+        addGrid(shapeCollection);
+
+        addTextEditors(viewPanel, shapeCollection);
+    }
 
+    private static void addGrid(ShapeCollection shapeCollection) {
+        final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
+                Math.PI / 2);
+
+        final Rectangle rectangle = new Rectangle(2000);
+        final LineAppearance appearance = new LineAppearance(10, new Color(
+                "00b3ad"));
+
+        shapeCollection.addShape(new Grid2D(transform, rectangle, 10, 10, appearance));
+    }
+
+    private static void addTextEditors(ViewPanel viewPanel, ShapeCollection shapeCollection) {
         final double m = 1.5;
         for (double z = -500 * m; z <= (500 * m); z += 250 * m)
             for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
@@ -51,10 +57,11 @@ public class TextEditorDemo {
 
                 shapeCollection.addShape(textEditor);
             }
+    }
 
+    private static void setAvatarLocation(ViewPanel viewPanel) {
         viewPanel.getAvatar().setLocation(new Point3D(500, -300, -800));
         viewPanel.getAvatar().setAngleXZ(0.6);
         viewPanel.getAvatar().setAngleYZ(-0.5);
-
     }
 }