use of com.cubrid.common.ui.cubrid.database.erwin.xmlmodel.DrawingObjectEntityProps in project cubrid-manager by CUBRID.
the class ExportSchemaTask method setDrawData.
private void setDrawData(Model model) {
int ENTITY_PER_ROW = 5;
model.setSubjectAreaGroups(new SubjectAreaGroups());
SubjectArea subjectArea = new SubjectArea();
model.getSubjectAreaGroups().getSubjectAreaList().add(subjectArea);
String name = "<Main Subject Area>";
subjectArea.setId(getUUID());
subjectArea.setName(name);
subjectArea.setSubjectAreaProps(new SubjectAreaProps());
subjectArea.getSubjectAreaProps().setName(new SubjectAreaProps.Name());
subjectArea.getSubjectAreaProps().getName().setValue(name);
subjectArea.setStoredDisplayGroups(new StoredDisplayGroups());
StoredDisplay storedDisplay = new StoredDisplay();
storedDisplay.setId(getUUID());
storedDisplay.setName("Display1");
subjectArea.getStoredDisplayGroups().getStoredDisplay().add(storedDisplay);
DrawingObjectEntityGroups groups = new DrawingObjectEntityGroups();
storedDisplay.setDrawingObjectEntityGroups(groups);
Map<String, String> locationMap = new HashMap<String, String>();
int idx = 1;
int row = 1;
for (Entry<String, Entity> entry : entityMap.entrySet()) {
if (idx > ENTITY_PER_ROW) {
idx = 1;
row++;
}
String id = entry.getValue().getId();
ReferencedEntity entity = new ReferencedEntity();
entity.setValue(id);
subjectArea.getSubjectAreaProps().getReferencedEntities().add(entity);
DrawingObjectEntity dEntity = new DrawingObjectEntity();
dEntity.setId(getUUID());
dEntity.setName(entry.getValue().getName());
dEntity.setDrawingObjectEntityProps(new DrawingObjectEntityProps());
dEntity.getDrawingObjectEntityProps().setDoEntityHeightAutoResizeable(new DOEntityHeightAutoResizeable());
dEntity.getDrawingObjectEntityProps().getDoEntityHeightAutoResizeable().setValue(Boolean.TRUE.toString());
dEntity.getDrawingObjectEntityProps().setDoEntityWidthAutoResizeable(new DOEntityWidthAutoResizeable());
dEntity.getDrawingObjectEntityProps().getDoEntityWidthAutoResizeable().setValue(Boolean.TRUE.toString());
dEntity.getDrawingObjectEntityProps().setDoReferenceObject(new DOReferenceObject());
dEntity.getDrawingObjectEntityProps().getDoReferenceObject().setValue(id);
dEntity.getDrawingObjectEntityProps().setDolocation(new DOLocation());
String location = row * 500 + "," + idx * 500;
dEntity.getDrawingObjectEntityProps().getDolocation().setValue("(" + location + ",0,0)");
groups.getDrawingObjectEntity().add(dEntity);
locationMap.put(id, location);
idx++;
}
DrawingObjectRelationshipGroups shipGroups = new DrawingObjectRelationshipGroups();
storedDisplay.setDrawingObjectRelationshipGroups(shipGroups);
for (Entry<String, Relationship> entry : relationshipMap.entrySet()) {
String relId = entry.getKey();
Relationship relEntity = entry.getValue();
ReferencedEntity entity = new ReferencedEntity();
entity.setValue(relId);
subjectArea.getSubjectAreaProps().getReferencedEntities().add(entity);
DrawingObjectRelation relation = new DrawingObjectRelation();
relation.setId(getUUID());
relation.setName(relEntity.getName());
shipGroups.getDrawingObjectRelationshipEntity().add(relation);
relation.setDrawingObjectRelationshipProps(new DrawingObjectRelationshipProps());
relation.getDrawingObjectRelationshipProps().setDoReferenceObject(new DOReferenceObject());
relation.getDrawingObjectRelationshipProps().getDoReferenceObject().setValue(relId);
String pId = relEntity.getRelationshipProps().getRelationshipParentEntity().getValue();
String cId = relEntity.getRelationshipProps().getRelationshipChildEntity().getValue();
String pl = locationMap.get(pId);
String cl = locationMap.get(cId);
int[] pco = parseLocation(pl);
int[] cco = parseLocation(cl);
int ydis = pco[0] - cco[0];
int xdis = pco[1] - cco[1];
boolean x = (Math.abs(xdis) > Math.abs(ydis)) ? false : true;
// int[] p1 = pco;
// int[] p2 = (x) ? new int[] { pco[0], pco[1] - (xdis / 2) }
// : new int[] { pco[0] - (ydis / 2), pco[1] };
// int[] p3 = (x) ? new int[] { cco[0], cco[1] + (xdis / 2) }
// : new int[] { cco[0] + (ydis / 2), cco[1] };
// int[] p4 = cco;
int[] p1 = new int[] { pco[1] + 10, pco[0] + 10 };
int[] p4 = new int[] { cco[1] + 10, cco[0] + 10 };
int[] p2 = (x) ? new int[] { p1[0] - (xdis / 2), p1[1] } : new int[] { p1[0], p1[1] - (ydis / 2) };
int[] p3 = (x) ? new int[] { p4[0] + (xdis / 2), p4[1] } : new int[] { p4[0], p4[1] + (ydis / 2) };
DORelationshipPath path = new DORelationshipPath();
path.setValue(arrayToString(p4));
path = new DORelationshipPath();
path.setValue(arrayToString(p3));
relation.getDrawingObjectRelationshipProps().getDoRelationshipPathList().add(path);
path = new DORelationshipPath();
path.setValue(arrayToString(p2));
relation.getDrawingObjectRelationshipProps().getDoRelationshipPathList().add(path);
path = new DORelationshipPath();
path.setValue(arrayToString(p1));
relation.getDrawingObjectRelationshipProps().setDoUserControledPath(new DOUserControledPath());
relation.getDrawingObjectRelationshipProps().getDoUserControledPath().setValue("true");
}
}
Aggregations