use of ini.trakem2.Project in project TrakEM2 by trakem2.
the class DBLoader method getChildrenTemplateThings.
/**
* Recursive into children.
*/
private ArrayList getChildrenTemplateThings(Project project, long parent_id) throws Exception {
ArrayList al = new ArrayList();
ResultSet r = connection.prepareStatement("SELECT * FROM ab_things WHERE parent_id=" + parent_id).executeQuery();
while (r.next()) {
long id = r.getLong("id");
String type = r.getString("type");
TemplateThing tt = new TemplateThing(type, project, id);
tt.setup(getChildrenTemplateThings(project, id));
al.add(tt);
}
r.close();
return al;
}
use of ini.trakem2.Project in project TrakEM2 by trakem2.
the class DBLoader method fetchProfile.
private Profile fetchProfile(Project project, long id) throws Exception {
// joint call
ResultSet r = connection.prepareStatement("SELECT ab_profiles.id, ab_displayables.id, title, width, height, alpha, visible, color_red, color_green, color_blue, closed, locked, m00, m10, m01, m11, m02, m12 FROM ab_profiles, ab_displayables WHERE ab_profiles.id=ab_displayables.id AND ab_profiles.id=" + id).executeQuery();
Profile p = null;
if (r.next()) {
p = new Profile(project, id, r.getString("title"), (float) r.getDouble("width"), (float) r.getDouble("height"), (float) r.getDouble("alpha"), r.getBoolean("visible"), new Color(r.getInt("color_red"), r.getInt("color_green"), r.getInt("color_blue")), r.getBoolean("closed"), r.getBoolean("locked"), new AffineTransform(r.getDouble("m00"), r.getDouble("m10"), r.getDouble("m01"), r.getDouble("m11"), r.getDouble("m02"), r.getDouble("m12")));
// the polygon is not loaded, only when repainting the profile.
}
r.close();
return p;
}
use of ini.trakem2.Project in project TrakEM2 by trakem2.
the class DBLoader method getProjectThing.
private ProjectThing getProjectThing(ResultSet r, Project project, HashMap<String, TemplateThing> hs_tt, HashMap<Long, Displayable> hs_d) throws Exception {
long id = r.getLong("id");
String type = r.getString("type");
TemplateThing tt = (TemplateThing) hs_tt.get(type);
if (null == tt) {
Utils.log("Loader.getProjectThing: can not find a proper TemplateThing of type " + type + " for the ProjectThing of id=" + id);
return null;
}
long object_id = r.getLong("object_id");
// may be null
Object ob = r.getString("title");
if (-1 != object_id) {
ob = getProjectObject(project, object_id);
if (ob instanceof Displayable)
hs_d.put(new Long(((Displayable) ob).getId()), (Displayable) ob);
else
Utils.log("Loader.getProjectThing: not adding to hs_d: " + ob);
}
return new ProjectThing(tt, project, id, ob, getChildrenProjectThings(project, id, type, hs_tt, hs_d));
}
use of ini.trakem2.Project in project TrakEM2 by trakem2.
the class DBLoader method fetchAreaList.
private AreaList fetchAreaList(Project project, long id) throws Exception {
ResultSet r = connection.createStatement().executeQuery("SELECT area_list_id, layer_id FROM ab_area_paths WHERE area_list_id=" + id);
ArrayList al_ul = new ArrayList();
while (r.next()) {
// the ids of the unloaded layers
al_ul.add(new Long(r.getLong(2)));
}
r.close();
r = connection.prepareStatement("SELECT ab_displayables.id, title, ab_displayables.width, height, alpha, visible, color_red, color_green, color_blue, locked, m00, m10, m01, m11, m02, m12, ab_zdisplayables.id FROM ab_zdisplayables, ab_displayables WHERE ab_zdisplayables.id=ab_displayables.id AND ab_zdisplayables.id=" + id).executeQuery();
AreaList area_list = null;
if (r.next()) {
area_list = new AreaList(project, id, r.getString("title"), (float) r.getDouble("width"), (float) r.getDouble("height"), r.getFloat("alpha"), r.getBoolean("visible"), new Color(r.getInt("color_red"), r.getInt("color_green"), r.getInt("color_blue")), r.getBoolean("locked"), al_ul, new AffineTransform(r.getDouble("m00"), r.getDouble("m10"), r.getDouble("m01"), r.getDouble("m11"), r.getDouble("m02"), r.getDouble("m12")));
}
r.close();
return area_list;
}
use of ini.trakem2.Project in project TrakEM2 by trakem2.
the class DBLoader method getLayerThing.
private LayerThing getLayerThing(ResultSet r, Project project, HashMap hs_pt, TemplateThing layer_set_tt, TemplateThing layer_tt) throws Exception {
long id = r.getLong("id");
String type = r.getString("type");
// if not a "Layer", then it's a "Layer Set"
TemplateThing template = type.equals("layer_set") ? layer_set_tt : layer_tt;
// HERE the order of the arguments layer_set_tt and layer_tt was inverted, and it worked??? There was a compensating bug, incredibly enough, in the type.equals(.. above.
return new LayerThing(template, project, id, r.getString("title"), getLayerThingObject(project, r.getLong("object_id"), template, hs_pt), getChildrenLayerThing(project, id, hs_pt, layer_set_tt, layer_tt));
}
Aggregations