Statement statement = conn.createStatement();
// elements
ResultSet rs = statement.executeQuery ("SELECT * FROM elements");
while (rs.next()) {
ElementEntity element = new ElementEntity (
rs.getInt ("element_id"),
rs.getString ("pattern"),
new int[] { rs.getInt ("p1_element_id"),
rs.getInt ("p2_element_id"),
rs.getInt ("p3_element_id"),
rs.getInt ("p4_element_id") }
);
allElements.put (new Integer (element.elementId), element);
}
// element_glyphs
rs = statement.executeQuery ("SELECT * FROM element_glyphs");
while (rs.next()) {
Integer elementId = new Integer (rs.getInt ("element_id"));
Integer glyphVariant = new Integer (rs.getInt ("glyph_variant"));
String strokes = rs.getString ("strokes");
// FIXME bodge - fix in database
if ((strokes.length() > 0) && (strokes.charAt (strokes.length() - 1) != '\n'))
strokes += "\n";
Glyph glyph = new Glyph (
rs.getInt ("width"),
rs.getInt ("height"),
new int[] { rs.getInt ("p1_glyph_variant"),
rs.getInt ("p2_glyph_variant"),
rs.getInt ("p3_glyph_variant"),
rs.getInt ("p4_glyph_variant") },
new int[] { rs.getInt ("p1_x"),
rs.getInt ("p2_x"),
rs.getInt ("p3_x"),
rs.getInt ("p4_x") },
new int[] { rs.getInt ("p1_y"),
rs.getInt ("p2_y"),
rs.getInt ("p3_y"),
rs.getInt ("p4_y") },
new int[] { rs.getInt ("p1_width"),
rs.getInt ("p2_width"),
rs.getInt ("p3_width"),
rs.getInt ("p4_width") },
new int[] { rs.getInt ("p1_height"),
rs.getInt ("p2_height"),
rs.getInt ("p3_height"),
rs.getInt ("p4_height") },
strokes,
rs.getInt ("centrepoint")
);
ElementEntity element = (ElementEntity)allElements.get (elementId);
element.glyphs.set (glyphVariant, glyph);
}
} catch (SQLException s) {
System.out.println (s);
Runtime.getRuntime().halt(1);