Search in sources :

Example 6 with DefaultEdge

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);
        }
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) AttributeMap(org.jgraph.graph.AttributeMap) HashMap(java.util.HashMap) DefaultEdge(org.jgraph.graph.DefaultEdge)

Example 7 with DefaultEdge

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;
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DefaultGraphCell(org.jgraph.graph.DefaultGraphCell) DefaultEdge(org.jgraph.graph.DefaultEdge)

Aggregations

DefaultEdge (org.jgraph.graph.DefaultEdge)7 HashMap (java.util.HashMap)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 AttributeMap (org.jgraph.graph.AttributeMap)2 Relationship (org.apache.cayenne.map.Relationship)1 DefaultGraphCell (org.jgraph.graph.DefaultGraphCell)1