X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d-demos.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fexamples%2Flife%2FMain.java;h=47698df296cb2ae9b41c903a8ac416666fa13597;hp=539527dfa5eef8ee0ce8a5dbe80a2071fe989e6b;hb=3fcaabac00ae23c054b6ea0bda6fa624b4513915;hpb=41488a79c65efc82fc794957613d8273ca76c9a0 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Main.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Main.java index 539527d..47698df 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Main.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Main.java @@ -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.Transform; 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.ViewPanel; 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; @@ -29,7 +29,7 @@ public class Main extends WorldNavigationTracker { * Handle keyboard input. */ @Override - public void keyPressed(final KeyEvent event, final ViewContext viewContext) { + public boolean keyPressed(final KeyEvent event, final ViewPanel viewPanel) { switch (event.getKeyChar()) { case ' ': // space key MATRIX.evolve(false); @@ -41,8 +41,9 @@ public class Main extends WorldNavigationTracker { MATRIX.clear(); break; default: - super.keyPressed(event, viewContext); + return super.keyPressed(event, viewPanel); } + return true; } private void run() { @@ -50,28 +51,28 @@ public class Main extends WorldNavigationTracker { // create application frame visible to the user final ViewFrame viewFrame = new ViewFrame(); - final ShapeCollection shapeCollection = viewFrame.getView() - .getContext().getRootShapeCollection(); + final ShapeCollection shapeCollection = viewFrame.getViewPanel() + .getRootShapeCollection(); // add matrix shapeCollection.addShape(MATRIX); - // add wireframe grid (optional) + // add wire-frame grid (optional) shapeCollection.addShape(createGrid()); - final ViewContext context = viewFrame.getView().getContext(); + final ViewPanel viewPanel = viewFrame.getViewPanel(); - setAvatarOrientation(context.getAvatar()); + setAvatarOrientation(viewPanel.getAvatar()); // enable receiving of keyboard events - context.getKeyboardFocusTracker().setFocusOwner(this); + viewPanel.getKeyboardFocusTracker().setFocusOwner(this); // Done! World is built. So ensure screen is updated too. - context.getView().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(