Updated readability of the code.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / renderer / raster / RenderAggregator.java
index 049938c..d6da472 100644 (file)
@@ -1,12 +1,7 @@
 /*
- * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 3 of the GNU Lesser General Public License
- * or later as published by the Free Software Foundation.
- *
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
  */
-
 package eu.svjatoslav.sixth.e3d.renderer.raster;
 
 import eu.svjatoslav.sixth.e3d.gui.RenderingContext;
@@ -14,21 +9,16 @@ import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape;
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
 
 public class RenderAggregator {
 
-    ArrayList<AbstractCoordinateShape> shapes = new ArrayList<>();
-    ShapesComparator comparator = new ShapesComparator();
+    private final ArrayList<AbstractCoordinateShape> shapes = new ArrayList<>();
+    private final ShapesZIndexComparator comparator = new ShapesZIndexComparator();
 
     public void paint(final RenderingContext renderBuffer) {
-
-        Collections.sort(shapes, comparator);
-
-        for (final AbstractCoordinateShape shape : shapes)
-            shape.paint(renderBuffer);
-
+        shapes.sort(comparator);
+        shapes.forEach(shape -> shape.paint(renderBuffer));
     }
 
     public void queueShapeForRendering(final AbstractCoordinateShape shape) {
@@ -39,7 +29,7 @@ public class RenderAggregator {
         shapes.clear();
     }
 
-    static class ShapesComparator implements Comparator<AbstractCoordinateShape>, Serializable {
+    static class ShapesZIndexComparator implements Comparator<AbstractCoordinateShape>, Serializable {
 
         @Override
         public int compare(final AbstractCoordinateShape o1, final AbstractCoordinateShape o2) {