package org.AlbumGenerator.Misc;
import org.AlbumGenerator.Gui.Interface;
import org.AlbumGenerator.List.Foto;
import javax.swing.*;
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
* Author : Serenity
* From : Rune-server.org
* Date : 9-feb-2010
* Time : 19:31:43
* Package : org.AlbumGenerator.Misc
*/
public class Constant {
private Interface gui;
public Constant(Interface gui) {
this.gui = gui;
for (int i = 0; i < 500; i++) {
fotolist.add(new Foto("dc500" + i));
}
}
public void createFotoOverzicht() {
boolean shouldInsert = false;
try {
instr
= new URL("http://www.boskabouters.nl/Foto's.html").
openStream();
for (String j
= in.
readLine(); j
!= null; j
= in.
readLine()) {
if (shouldInsert)
if (!(j.contains(" <p><strong><a href=\"foto's/"))) {
if (j.contains(" <p> </p>")) {
j = "\t <p><strong><a href=\"foto's/" + gui.getAlbumName() + "/index.html\">" + gui.getAlbumName() + "</a></strong></p>";
} else {
j += "\n\t <p><strong><a href=\"foto's/" + gui.getAlbumName() + "/index.html\">" + gui.getAlbumName() + "</a></strong></p>";
}
shouldInsert = false;
}
page += j + "\n";
if (j.contains("<td colspan=\"11\" align=\"center\" valign=\"top\" background=\"afbeeldingen/Foto's_07.gif\"><p> </p>")) {
shouldInsert = true;
}
}
e.printStackTrace();
}
try {
bf.write(page);
bf.flush();
bf.write(page);
e.printStackTrace();
}
}
public void createAlbumIndexPage(int index) {
int fotoIndex = 0;
int rowcount = 0;
boolean[] rows = new boolean[4];
boolean indexes = false;
try {
instr
= new URL("http://www.boskabouters.nl/AlbumIndex.html").
openStream();
for (String j
= in.
readLine(); j
!= null; j
= in.
readLine()) {
if (rows[0]) {
j = " <td><a href=\"" + ((index * 16) + fotoIndex) + ".html" + "\"><img src=\"" + (fotolist.get((index * 16) + fotoIndex++).getFoto()) + ".jpg\" alt=\"-\" width=\"100\" height=\"75\"border=\"0\"></a></td>";
rowcount++;
if (rowcount == 4)
rows[0] = false;
}
if (rows[1]) {
j = " <td><a href=\"" + ((index * 16) + fotoIndex) + ".html" + "\"><img src=\"" + (fotolist.get((index * 16) + fotoIndex++).getFoto()) + ".jpg\" alt=\"-\" width=\"100\" height=\"75\"border=\"0\"></a></td>";
rowcount++;
if (rowcount == 8)
rows[1] = false;
}
if (rows[2]) {
j = " <td><a href=\"" + ((index * 16) + fotoIndex) + ".html" + "\"><img src=\"" + (fotolist.get((index * 16) + fotoIndex++).getFoto()) + ".jpg\" alt=\"-\" width=\"100\" height=\"75\"border=\"0\"></a></td>";
rowcount++;
if (rowcount == 12)
rows[2] = false;
}
if (rows[3]) {
j = " <td><a href=\"" + ((index * 16) + fotoIndex) + ".html" + "\"><img src=\"" + (fotolist.get((index * 16) + fotoIndex++).getFoto()) + ".jpg\" alt=\"-\" width=\"100\" height=\"75\"border=\"0\"></a></td>";
rowcount++;
if (rowcount == 16)
rows[3] = false;
}
if (indexes) {
System.
out.
println("======================INdexes===================");
j = "";
int aantalIndexes = getAmountofIndexPages();
for (int i = 0; i < aantalIndexes; i++) {
if (i == (aantalIndexes / 2)) {
j += "<br>\n";
}
j += "<a href=\"http://www.boskabouters.nl/foto's/" + gui.getAlbumName() + "/index" + (i == 0 ? "" : i) + ".html\" target=\"_self\">[" + (i + 1) + "]</a>\n";
}
indexes = false;
}
page += j + "\n";
if (j.contains("<!-- insert row1 -->"))
rows[0] = true;
if (j.contains("<!-- insert row2 -->"))
rows[1] = true;
if (j.contains("<!-- insert row3 -->"))
rows[2] = true;
if (j.contains("<!-- insert row4 -->"))
rows[3] = true;
if (j.contains("<!-- insert Indexes -->"))
indexes = true;
}
e.printStackTrace();
}
}
public static int[] getTumbSize
(ImageIcon image
) {
return new int[]{image.getIconWidth(), image.getIconHeight()};
}
public static int[] getFotoSize
(ImageIcon image
) {
return new int[]{image.getIconWidth(), image.getIconHeight()};
}
public static ArrayList<Foto> fotolist = new ArrayList<Foto>();
public int getAmountofIndexPages() {
int size = fotolist.size();
int pages = 0;
for (int i = 0; i < 40; i++) {
if (size > 16) {
pages++;
size -= 16;
} else {
pages++;
break;
}
}
return pages;
}
}
/*
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index.html" target="_self">[1]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index1.html" target="_self">[2]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index2.html" target="_self">[3]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index3.html" target="_self">[4]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index4.html" target="_self">[5]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index5.html" target="_self">[6]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index6.html" target="_self">[7]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index7.html" target="_self">[8]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index8.html" target="_self">[9]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index9.html" target="_self">[10]</a><br>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index10.html" target="_self">[11]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index11.html" target="_self">[12]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index12.html" target="_self">[13]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index13.html" target="_self">[14]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index14.html" target="_self">[15]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index15.html" target="_self">[16]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index16.html" target="_self">[17]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index17.html" target="_self">[18]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index18.html" target="_self">[19]</a>
<a href="http://www.boskabouters.nl/foto's/Bulgarije%202009%20deel%201/index19.html" target="_self">[20]</a>
<br>
*/