X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Frenderer%2Fraster%2Fshapes%2Fcomposite%2Ftextcanvas%2FTextCanvas.java;h=737a5b81bdfa083a600d6d99e3e9bf35d8375a3b;hp=4419908bc37f4e2f2a00eef7882a99470dd2774f;hb=e56f9b775bd49c31e8efab7204bee699036942b3;hpb=b1e8d7bd8c9d0905e9fe3c46fc84a11779b95982 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java index 4419908..737a5b8 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/composite/textcanvas/TextCanvas.java @@ -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 @@ -10,10 +10,10 @@ 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;