Code cleanup and formatting.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / renderer / raster / shapes / composite / textcanvas / TextCanvas.java
index 4419908..737a5b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sixth 3D engine. Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * 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
 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas;
 
 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
-import eu.svjatoslav.sixth.e3d.geometry.Transform;
-import eu.svjatoslav.sixth.e3d.geometry.TransformPipe;
 import eu.svjatoslav.sixth.e3d.gui.RenderingContext;
 import eu.svjatoslav.sixth.e3d.gui.TextPointer;
+import eu.svjatoslav.sixth.e3d.math.Transform;
+import eu.svjatoslav.sixth.e3d.math.TransformPipe;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.TexturedRectangle;
 
@@ -38,8 +38,7 @@ public class TextCanvas extends TexturedRectangle {
     private Color foregroundColor = Color.WHITE;
 
     public TextCanvas(final Transform location, final String text,
-                      final Color foregroundColor, final Color backgroundColor)
-            throws IOException {
+                      final Color foregroundColor, final Color backgroundColor) {
         this(location, getTextDimensions(text), foregroundColor,
                 backgroundColor);
         setText(text);
@@ -86,8 +85,7 @@ public class TextCanvas extends TexturedRectangle {
         setRenderMode(RenderMode.TEXTURE);
     }
 
-    public static TextPointer getTextDimensions(final String text)
-            throws IOException {
+    public static TextPointer getTextDimensions(final String text) {
 
         final BufferedReader reader = new BufferedReader(new StringReader(text));
 
@@ -95,7 +93,12 @@ public class TextCanvas extends TexturedRectangle {
         int columns = 0;
 
         while (true) {
-            final String line = reader.readLine();
+            final String line;
+            try {
+                line = reader.readLine();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
 
             if (line == null)
                 return new TextPointer(rows, columns);
@@ -147,7 +150,7 @@ public class TextCanvas extends TexturedRectangle {
     }
 
     private void drawCharToTexture(final int row, final int column,
-                                   final char character, final Color background, final Color foreground) {
+                                   final char character, final Color foreground) {
         final Graphics2D graphics = getTexture().graphics;
 
         getTexture().primaryBitmap.drawRectangle(column * FONT_CHAR_WIDTH, row
@@ -212,7 +215,7 @@ public class TextCanvas extends TexturedRectangle {
         canvasCharacter.setValue(character);
         canvasCharacter.setBackgroundColor(backgroundColor);
         canvasCharacter.setForegroundColor(foregroundColor);
-        drawCharToTexture(row, column, character, backgroundColor,
+        drawCharToTexture(row, column, character,
                 foregroundColor);
     }
 
@@ -248,13 +251,18 @@ public class TextCanvas extends TexturedRectangle {
         renderMode = mode;
     }
 
-    public void setText(final String text) throws IOException {
+    public void setText(final String text) {
         final BufferedReader reader = new BufferedReader(new StringReader(text));
 
         int row = 0;
 
         while (true) {
-            final String line = reader.readLine();
+            final String line;
+            try {
+                line = reader.readLine();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
 
             if (line == null)
                 return;