Professional Documents
Culture Documents
Eee 444
Eee 444
Canvas;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
canvas.setSize(500, 500);
ctx = canvas.getGraphics();
selected_canvas.setSize(500, 500);
selected_ctx = selected_canvas.getGraphics();
if (o != "") {
deactivate_startbutton();
print_error(o, "img_errorbox");
} else {
userfilename = file.name;
try {
ImageIO.read(file);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
switch (e.id) {
case "projectname":
if (e.value != "") {
entries.put("projectname", e.value);
} else if (e.placeholder != "") {
entries.put("projectname", e.placeholder);
} else {
entries.put("projectname", "My Book Art Project");
}
if (entries.get("projectname").length() > 100) {
entries.put("projectname",
entries.get("projectname").substring(0, 100));
}
break;
case "firstpage":
if (e.value != "" && e.validity.valid != false) {
entries.put("firstpage", Integer.parseInt(e.value));
} else {
t = "The first page must be an even, positive number. ";
}
break;
case "lastpage":
if (e.value == "" || e.validity.valid == false ||
Integer.parseInt(e.value) <= entries.get("firstpage")) {
t = "The last page must be an even, positive number. It must be
larger than the number of the first page. (This will work with up to 2000 pages. If
you are working on a larger book, please contact the author of this website.) ";
} else {
entries.put("lastpage", Integer.parseInt(e.value));
}
break;
case "cm":
case "inch":
if (e.checked) {
entries.put("unit", e.id);
}
break;
case "bookheight":
if (e.value != "" && e.validity.valid != false) {
entries.put("bookheight", 100 * Float.parseFloat(e.value));
} else {
t = "The book's height must be a positive number with no more
than 1 digit after the decimal point. (This will work for heights between 1 and 40
cm/inch. If you are working on a larger book, please contact the author of this
website.) ";
}
break;
case "singleprecision":
if (e.checked) {
entries.put("singleprecision", true);
} else {
entries.put("singleprecision", false);
}
break;
case "smoothe":
if (e.value != "" && e.validity.valid != false) {
entries.put("smoothe", smoothe.value);
} else {
t = "The smoothing value you selected is invalid - please use a
number between 0 and 20. ";
}
break;
}
if (t != "") {
e.parentElement.classList.add("error");
Element r = document.createElement("p");
r.id = e.id + "_errorbox";
r.classList.add("errormsg");
Text a = document.createTextNode(t);
r.appendChild(a);
e.parentElement.appendChild(r);
return false;
}
return true;
}