diff --git a/src/main/java/eu/m724/Renderer.java b/src/main/java/eu/m724/Renderer.java index ba7e5d3..f3e892f 100644 --- a/src/main/java/eu/m724/Renderer.java +++ b/src/main/java/eu/m724/Renderer.java @@ -3,27 +3,75 @@ package eu.m724; import org.jfree.svg.SVGGraphics2D; import java.awt.*; +import java.awt.font.FontRenderContext; +import java.awt.geom.Rectangle2D; public class Renderer { + private static final int TILE_SIZE = 50; + public static String render(Crossword crossword) { - SVGGraphics2D g2 = new SVGGraphics2D(crossword.width() * 10, crossword.height() * 10); + SVGGraphics2D g2 = new SVGGraphics2D(crossword.width() * TILE_SIZE, crossword.height() * TILE_SIZE); g2.setPaint(Color.BLACK); + FontRenderContext frc = g2.getFontRenderContext(); + Font font = g2.getFont(); + for (PlacedWord word : crossword.words()) { int x = word.x(); int y = word.y(); + String hint = word.word().hint(); + if (word.vertical()) { - for (int _y=y; _y TILE_SIZE) { // TODO ideally this should be splitting by word + int linesAmount = (int) Math.ceil((double) textWidth / TILE_SIZE); + + lines = new String[linesAmount]; + int partLength = text.length() / linesAmount; + + for (int i=0; i