Removed ViewContext.
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 13 Jul 2018 23:44:52 +0000 (02:44 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 13 Jul 2018 23:44:52 +0000 (02:44 +0300)
src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/OctreeDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/PointCloudDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/RainingNumbersDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/SphereDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Main.java

index e2ee634..5e2009d 100644 (file)
@@ -22,7 +22,7 @@ public class GraphDemo {
 
     private static final double scale = 50d;
 
 
     private static final double scale = 50d;
 
-    private static Graph getCosinusGraph(final Point3D location)
+    private static Graph getCosineGraph(final Point3D location)
             throws IOException {
         final List<Point2D> data = new ArrayList<>();
         for (double x = 0; x < 20; x += 0.25) {
             throws IOException {
         final List<Point2D> data = new ArrayList<>();
         for (double x = 0; x < 20; x += 0.25) {
@@ -32,7 +32,7 @@ public class GraphDemo {
             data.add(p);
         }
 
             data.add(p);
         }
 
-        return new Graph(scale, data, "Cosinus", location);
+        return new Graph(scale, data, "Cosine", location);
     }
 
     private static Graph getFormula1Graph(final Point3D location)
     }
 
     private static Graph getFormula1Graph(final Point3D location)
@@ -74,7 +74,7 @@ public class GraphDemo {
         return new Graph(scale, data, "y = sin(x/2) + sin(x/1.26)", location);
     }
 
         return new Graph(scale, data, "y = sin(x/2) + sin(x/1.26)", location);
     }
 
-    private static Graph getSinusGraph(final Point3D location)
+    private static Graph getSineGraph(final Point3D location)
             throws IOException {
         final List<Point2D> data = new ArrayList<>();
         for (double x = 0; x < 20; x += 0.25) {
             throws IOException {
         final List<Point2D> data = new ArrayList<>();
         for (double x = 0; x < 20; x += 0.25) {
@@ -84,7 +84,7 @@ public class GraphDemo {
             data.add(p);
         }
 
             data.add(p);
         }
 
-        return new Graph(scale, data, "Sinus", location);
+        return new Graph(scale, data, "Sine", location);
     }
 
     private static Graph getTangentGraph(final Point3D location)
     }
 
     private static Graph getTangentGraph(final Point3D location)
@@ -110,16 +110,16 @@ public class GraphDemo {
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection geometryCollection = viewFrame.getViewPanel()
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection geometryCollection = viewFrame.getViewPanel()
-                .getContext().getRootShapeCollection();
+                .getRootShapeCollection();
 
         Point3D location = new Point3D(-600, -300, 0);
 
         Point3D location = new Point3D(-600, -300, 0);
-        geometryCollection.addShape(getSinusGraph(location));
+        geometryCollection.addShape(getSineGraph(location));
 
         location = new Point3D(600, -300, 0);
         geometryCollection.addShape(getFormula1Graph(location));
 
         location = new Point3D(-600, 0, 0);
 
         location = new Point3D(600, -300, 0);
         geometryCollection.addShape(getFormula1Graph(location));
 
         location = new Point3D(-600, 0, 0);
-        geometryCollection.addShape(getCosinusGraph(location));
+        geometryCollection.addShape(getCosineGraph(location));
 
         location = new Point3D(600, 0, 0);
         geometryCollection.addShape(getFormula2Graph(location));
 
         location = new Point3D(600, 0, 0);
         geometryCollection.addShape(getFormula2Graph(location));
@@ -130,7 +130,7 @@ public class GraphDemo {
         location = new Point3D(600, 300, 0);
         geometryCollection.addShape(getFormula3Graph(location));
 
         location = new Point3D(600, 300, 0);
         geometryCollection.addShape(getFormula3Graph(location));
 
-        viewFrame.getViewPanel().getContext().getAvatar()
+        viewFrame.getViewPanel().getAvatar()
                 .setLocation(new Point3D(0, 0, -500));
 
     }
                 .setLocation(new Point3D(0, 0, -500));
 
     }
index f5a9d08..5e5e15f 100755 (executable)
@@ -9,8 +9,8 @@
 package eu.svjatoslav.sixth.e3d.examples;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
 package eu.svjatoslav.sixth.e3d.examples;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.math.Transform;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationTracker;
 import eu.svjatoslav.sixth.e3d.renderer.octree.OctreeVolume;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationTracker;
 import eu.svjatoslav.sixth.e3d.renderer.octree.OctreeVolume;
@@ -37,7 +37,7 @@ public class OctreeDemo extends WorldNavigationTracker {
     private final Vector<LightSource> lights = new Vector<>();
     private OctreeVolume octreeVolume;
     private ShapeCollection shapeCollection;
     private final Vector<LightSource> lights = new Vector<>();
     private OctreeVolume octreeVolume;
     private ShapeCollection shapeCollection;
-    private ViewContext context;
+    private ViewPanel viewPanel;
 
     public static void main(final String[] args) {
         new OctreeDemo().init();
 
     public static void main(final String[] args) {
         new OctreeDemo().init();
@@ -90,13 +90,13 @@ public class OctreeDemo extends WorldNavigationTracker {
     private void init() {
 
         final ViewFrame viewFrame = new ViewFrame();
     private void init() {
 
         final ViewFrame viewFrame = new ViewFrame();
-        context = viewFrame.getViewPanel().getContext();
+        viewPanel = viewFrame.getViewPanel();
 
 
-        context.getAvatar().setLocation(new Point3D(0, -30, -300));
+        viewPanel.getAvatar().setLocation(new Point3D(0, -30, -300));
 
         octreeVolume = new OctreeVolume();
 
 
         octreeVolume = new OctreeVolume();
 
-        shapeCollection = context.getRootShapeCollection();
+        shapeCollection = viewPanel.getRootShapeCollection();
 
         shapeCollection.addShape(new Grid3D(
                 new Point3D(-10000, -10000, -10000), new Point3D(10000, 10000,
 
         shapeCollection.addShape(new Grid3D(
                 new Point3D(-10000, -10000, -10000), new Point3D(10000, 10000,
@@ -124,18 +124,18 @@ public class OctreeDemo extends WorldNavigationTracker {
                 Color.WHITE, Color.PURPLE);
         shapeCollection.addShape(message);
 
                 Color.WHITE, Color.PURPLE);
         shapeCollection.addShape(message);
 
-        context.getKeyboardFocusTracker().setFocusOwner(this);
-        context.getViewPanel().repaintDuringNextViewUpdate();
+        viewPanel.getKeyboardFocusTracker().setFocusOwner(this);
+        viewPanel.repaintDuringNextViewUpdate();
     }
 
     @Override
     }
 
     @Override
-    public void keyPressed(final KeyEvent event, final ViewContext viewContext) {
+    public void keyPressed(final KeyEvent event, final ViewPanel viewPanel) {
 
         if ('r' == event.getKeyChar()) {
             raytrace();
             return;
         }
 
         if ('r' == event.getKeyChar()) {
             raytrace();
             return;
         }
-        super.keyPressed(event, viewContext);
+        super.keyPressed(event, viewPanel);
     }
 
     private void putPixel(final int x, final int y, final int z,
     }
 
     private void putPixel(final int x, final int y, final int z,
@@ -159,12 +159,12 @@ public class OctreeDemo extends WorldNavigationTracker {
 
     private void raytrace() {
         // create and add camera object to scene
 
     private void raytrace() {
         // create and add camera object to scene
-        final Camera camera = new Camera(context.getAvatar(), magnification);
+        final Camera camera = new Camera(viewPanel.getAvatar(), magnification);
         shapeCollection.addShape(camera);
 
         // initialize and start Raytracer in a separate thread
         final RayTracer rayTracer = new RayTracer(camera.getTexture(),
         shapeCollection.addShape(camera);
 
         // initialize and start Raytracer in a separate thread
         final RayTracer rayTracer = new RayTracer(camera.getTexture(),
-                octreeVolume, lights, camera, context.getViewPanel());
+                octreeVolume, lights, camera, viewPanel);
         final Thread thread = new Thread(rayTracer);
         thread.start();
     }
         final Thread thread = new Thread(rayTracer);
         thread.start();
     }
index 63d1b38..0729693 100644 (file)
@@ -21,7 +21,7 @@ public class PointCloudDemo {
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection geometryCollection = viewFrame.getViewPanel()
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection geometryCollection = viewFrame.getViewPanel()
-                .getContext().getRootShapeCollection();
+                .getRootShapeCollection();
 
         Transform transform = new Transform(new Point3D(0, -1000, 1000), 0, 0);
 
 
         Transform transform = new Transform(new Point3D(0, -1000, 1000), 0, 0);
 
index 557d5ff..b88a105 100644 (file)
@@ -9,8 +9,8 @@
 package eu.svjatoslav.sixth.e3d.examples;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
 package eu.svjatoslav.sixth.e3d.examples;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.math.Transform;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewRenderListener;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewRenderListener;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
@@ -33,10 +33,10 @@ public class RainingNumbersDemo implements ViewRenderListener {
     }
 
     @Override
     }
 
     @Override
-    public boolean beforeRender(final ViewContext viewContext,
+    public boolean beforeRender(final ViewPanel viewPanel,
                                 final int millisecondsSinceLastFrame) {
 
                                 final int millisecondsSinceLastFrame) {
 
-        final Collection<AbstractShape> shapes = viewContext
+        final Collection<AbstractShape> shapes = viewPanel
                 .getRootShapeCollection().getShapes();
 
         final double translateAmount = millisecondsSinceLastFrame / 50d;
                 .getRootShapeCollection().getShapes();
 
         final double translateAmount = millisecondsSinceLastFrame / 50d;
@@ -53,11 +53,11 @@ public class RainingNumbersDemo implements ViewRenderListener {
         return true;
     }
 
         return true;
     }
 
-    private void run() throws IOException {
+    private void run() {
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection geometryCollection = viewFrame.getViewPanel()
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection geometryCollection = viewFrame.getViewPanel()
-                .getContext().getRootShapeCollection();
+                .getRootShapeCollection();
 
         Random random = new Random();
 
 
         Random random = new Random();
 
index 7534148..4f26470 100755 (executable)
@@ -62,7 +62,7 @@ public class RandomPolygonsDemo {
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
-                .getContext().getRootShapeCollection();
+                .getRootShapeCollection();
 
         // add grid
         final LineAppearance appearance = new LineAppearance(5, new Color(100,
 
         // add grid
         final LineAppearance appearance = new LineAppearance(5, new Color(100,
index d89486f..24b455f 100755 (executable)
@@ -9,8 +9,8 @@
 package eu.svjatoslav.sixth.e3d.examples;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
 package eu.svjatoslav.sixth.e3d.examples;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
@@ -56,9 +56,9 @@ public class SphereDemo {
     public static void main(final String[] args) {
 
         final ViewFrame viewFrame = new ViewFrame();
     public static void main(final String[] args) {
 
         final ViewFrame viewFrame = new ViewFrame();
-        final ViewContext context = viewFrame.getViewPanel().getContext();
+        final ViewPanel viewPanel = viewFrame.getViewPanel();
 
 
-        final ShapeCollection geometryCollection = context
+        final ShapeCollection geometryCollection = viewPanel
                 .getRootShapeCollection();
 
         final LineAppearance appearance = new LineAppearance(4, new Color(255,
                 .getRootShapeCollection();
 
         final LineAppearance appearance = new LineAppearance(4, new Color(255,
@@ -72,7 +72,7 @@ public class SphereDemo {
         makeWobblySurface(geometryCollection, 200);
         makeWobblySurface(geometryCollection, -200);
 
         makeWobblySurface(geometryCollection, 200);
         makeWobblySurface(geometryCollection, -200);
 
-        context.getAvatar().setLocation(new Point3D(0, 0, -340));
+        viewPanel.getAvatar().setLocation(new Point3D(0, 0, -340));
 
     }
 }
 
     }
 }
index ea2a867..4cc2a75 100644 (file)
@@ -11,8 +11,8 @@ package eu.svjatoslav.sixth.e3d.examples;
 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.geometry.Point2D;
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.math.Transform;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
@@ -36,10 +36,10 @@ public class TextEditorDemo {
     public static void main(final String[] args) {
 
         final ViewFrame viewFrame = new ViewFrame();
     public static void main(final String[] args) {
 
         final ViewFrame viewFrame = new ViewFrame();
-        final ViewContext viewContext = viewFrame.getViewPanel().getContext();
+        final ViewPanel viewPanel = viewFrame.getViewPanel();
 
         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
 
         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
-                .getContext().getRootShapeCollection();
+                .getRootShapeCollection();
 
         shapeCollection.addShape(createGrid());
 
 
         shapeCollection.addShape(createGrid());
 
@@ -48,15 +48,15 @@ public class TextEditorDemo {
             for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
 
                 final TextEditComponent textEditor = new TextEditComponent(
             for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
 
                 final TextEditComponent textEditor = new TextEditComponent(
-                        new Transform(new Point3D(x, 0, z)), viewContext,
+                        new Transform(new Point3D(x, 0, z)), viewPanel,
                         new Point2D(200, 120));
 
                 shapeCollection.addShape(textEditor);
             }
 
                         new Point2D(200, 120));
 
                 shapeCollection.addShape(textEditor);
             }
 
-        viewContext.getAvatar().setLocation(new Point3D(500, -300, -800));
-        viewContext.getAvatar().setAngleXZ(0.6);
-        viewContext.getAvatar().setAngleYZ(-0.5);
+        viewPanel.getAvatar().setLocation(new Point3D(500, -300, -800));
+        viewPanel.getAvatar().setAngleXZ(0.6);
+        viewPanel.getAvatar().setAngleYZ(-0.5);
 
     }
 }
 
     }
 }
index 99fc3e1..3a633df 100644 (file)
@@ -2,11 +2,11 @@ package eu.svjatoslav.sixth.e3d.examples.life;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
-import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.gui.Avatar;
 import eu.svjatoslav.sixth.e3d.gui.Avatar;
-import eu.svjatoslav.sixth.e3d.gui.ViewContext;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationTracker;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationTracker;
+import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
@@ -29,7 +29,7 @@ public class Main extends WorldNavigationTracker {
      * Handle keyboard input.
      */
     @Override
      * Handle keyboard input.
      */
     @Override
-    public void keyPressed(final KeyEvent event, final ViewContext viewContext) {
+    public void keyPressed(final KeyEvent event, final ViewPanel viewPanel) {
         switch (event.getKeyChar()) {
             case ' ': // space key
                 MATRIX.evolve(false);
         switch (event.getKeyChar()) {
             case ' ': // space key
                 MATRIX.evolve(false);
@@ -41,7 +41,7 @@ public class Main extends WorldNavigationTracker {
                 MATRIX.clear();
                 break;
             default:
                 MATRIX.clear();
                 break;
             default:
-                super.keyPressed(event, viewContext);
+                super.keyPressed(event, viewPanel);
         }
     }
 
         }
     }
 
@@ -51,27 +51,27 @@ public class Main extends WorldNavigationTracker {
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
         final ViewFrame viewFrame = new ViewFrame();
 
         final ShapeCollection shapeCollection = viewFrame.getViewPanel()
-                .getContext().getRootShapeCollection();
+                .getRootShapeCollection();
 
         // add matrix
         shapeCollection.addShape(MATRIX);
 
 
         // add matrix
         shapeCollection.addShape(MATRIX);
 
-        // add wireframe grid (optional)
+        // add wire-frame grid (optional)
         shapeCollection.addShape(createGrid());
 
         shapeCollection.addShape(createGrid());
 
-        final ViewContext context = viewFrame.getViewPanel().getContext();
+        final ViewPanel viewPanel = viewFrame.getViewPanel();
 
 
-        setAvatarOrientation(context.getAvatar());
+        setAvatarOrientation(viewPanel.getAvatar());
 
         // enable receiving of keyboard events
 
         // enable receiving of keyboard events
-        context.getKeyboardFocusTracker().setFocusOwner(this);
+        viewPanel.getKeyboardFocusTracker().setFocusOwner(this);
 
         // Done! World is built. So ensure screen is updated too.
 
         // Done! World is built. So ensure screen is updated too.
-        context.getViewPanel().repaintDuringNextViewUpdate();
+        viewPanel.repaintDuringNextViewUpdate();
     }
 
     /**
     }
 
     /**
-     * Create pink wireframe grid below (for decorative purposes).
+     * Create pink wire-frame grid below (for decorative purposes).
      */
     private Grid2D createGrid() {
         return new Grid2D(
      */
     private Grid2D createGrid() {
         return new Grid2D(