Example #1
0
  private void generatePage(Page page, Page previousPage, Page nextPage) throws IOException {
    System.out.println("Generating page " + page.getFile());
    try (PrintWriter pw = new PrintWriter(new FileOutputStream(page.getFile()))) {

      pw.println(
          "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
      pw.println("<html>\n");
      pw.println("<head>\n");
      pw.println("<title>Expert Minesweeper Strategies</title>\n");
      pw.println(
          "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\" />\n");
      pw.println("<link rel=\"stylesheet\" href=\"../styles.css\" />\n");
      pw.println("</head>\n");
      pw.println("<body>\n");
      pw.println("    <div id=\"conteneur\">\n");
      pw.println("    <div id=\"header\">Minesweeper Patterns</div>\n");
      pw.println("    <div id=\"haut\">\n");
      pw.println("    <ul class=\"menuhaut\">\n");
      pw.println("        <li><a href=\"index.html\">Intro</a></li>\n");
      pw.println("		<li>Basics</li>\n");
      pw.println("		<li><a href=\"triangles.html\">Triangles</a></li>\n");
      pw.println("		<li><a href=\"combos.html\">Combos</a></li>\n");
      pw.println("		<li><a href=\"holes.html\">Holes</a></li>\n");
      pw.println("		<li><a href=\"advanced.html\">Advanced</a></li>\n");
      pw.println("		<li><a href=\"links.html\">Links</a></li>\n");
      pw.println("	</ul>\n");
      pw.println("    </div>\n");
      pw.println("\n");
      pw.println("    <div id=\"centre\">\n");

      for (GifDescriptor gifDescriptor : page.getGifs()) {
        generateGif(gifDescriptor, page.getDir());
        pw.println("<p align=\"center\">");
        pw.println("<img src=\"" + gifDescriptor.getName() + ".gif\"/>");
        pw.println("</p>\n");
      }
      //            pw.println("    </div>\n");
      if (previousPage != null) {
        pw.println(
            "    <div id=\"prevlink\"><a href=\""
                + previousPage.getFile().getCanonicalPath()
                + "\">Prev: "
                + previousPage.getTitle()
                + "</a></div>\n");
      }
      if (nextPage != null) {
        pw.println(
            "    <div id=\"nextlink\"><a href=\""
                + nextPage.getFile().getCanonicalPath()
                + "\">Next: "
                + nextPage.getTitle()
                + "</a></div>\n");
      }
      pw.println("     </div>\n");
      pw.println("    </div>\n");
      pw.println("</body>\n");
      pw.println("</html>\n");
    }
  }
Example #2
0
  private void generateGif(GifDescriptor descriptor, File dir) throws IOException {

    try (ImageOutputStream output =
            new FileImageOutputStream(new File(dir, descriptor.getName() + ".gif"));
        GifSequenceWriter writer =
            new GifSequenceWriter(output, IMAGE_TYPE_GIF, TIME_BETWEEN_FRAMES_MS, true)) {
      for (GifFrame gifFrame : descriptor.getFrames()) {
        BufferedImage layer = generateFrame(gifFrame);
        writer.writeToSequence(layer);
      }
    }
  }