From 9d3a4458325082f83f71fef7adf2bec2f2e81f0a Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Fri, 22 May 2020 00:42:21 +0300 Subject: [PATCH] Code refactoring --- .../java/eu/svjatoslav/sixth/core/Main.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/svjatoslav/sixth/core/Main.java b/src/main/java/eu/svjatoslav/sixth/core/Main.java index c323932..ecec0a1 100644 --- a/src/main/java/eu/svjatoslav/sixth/core/Main.java +++ b/src/main/java/eu/svjatoslav/sixth/core/Main.java @@ -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); } } -- 2.20.1