use of org.jgraph.graph.DefaultEdge in project cayenne by apache.
the class ObjGraphBuilder method objEntityChanged.
public void objEntityChanged(EntityEvent e) {
remapEntity(e);
updateEntityCell(e.getEntity());
// maybe super entity was changed
ObjEntity entity = (ObjEntity) e.getEntity();
DefaultEdge inheritanceEdge = inheritanceEdges.get(entity);
if (inheritanceEdge != null) {
if (entity.getSuperEntity() == null) {
graph.getGraphLayoutCache().remove(new Object[] { inheritanceEdge });
inheritanceEdges.remove(entity);
} else {
inheritanceEdge.setTarget(entityCells.get(entity.getSuperEntity().getName()).getChildAt(0));
Map<DefaultEdge, AttributeMap> nested = new HashMap<>();
nested.put(inheritanceEdge, inheritanceEdge.getAttributes());
graph.getGraphLayoutCache().edit(nested);
}
} else {
if (entity.getSuperEntity() != null) {
DefaultEdge edge = createInheritanceEdge(entity);
graph.getGraphLayoutCache().insert(edge);
}
}
}
use of org.jgraph.graph.DefaultEdge in project cayenne by apache.
the class ObjGraphBuilder method createInheritanceEdge.
DefaultEdge createInheritanceEdge(ObjEntity entity) {
if (!inheritanceEdges.containsKey(entity)) {
ObjEntity superEntity = entity.getSuperEntity();
if (superEntity != null) {
DefaultGraphCell sourceCell = entityCells.get(entity.getName());
DefaultGraphCell targetCell = entityCells.get(superEntity.getName());
DefaultEdge edge = new DefaultEdge();
edge.setSource(sourceCell.getChildAt(0));
edge.setTarget(targetCell.getChildAt(0));
GraphConstants.setDashPattern(edge.getAttributes(), new float[] { 5, 5 });
GraphConstants.setLineEnd(edge.getAttributes(), GraphConstants.ARROW_TECHNICAL);
GraphConstants.setSelectable(edge.getAttributes(), false);
inheritanceEdges.put(entity, edge);
return edge;
}
}
return null;
}
Aggregations