Search in sources :

Example 1 with DefaultEdge

use of org.jgraph.graph.DefaultEdge in project cayenne by apache.

the class BaseGraphBuilder method createRelationshipCell.

protected DefaultEdge createRelationshipCell(Relationship rel) {
    if (!relCells.containsKey(getQualifiedName(rel))) {
        Relationship reverse = rel.getReverseRelationship();
        DefaultEdge edge = new DefaultEdge();
        // GraphConstants.setLineStyle(edge.getAttributes(),
        // GraphConstants.STYLE_ORTHOGONAL);
        // GraphConstants.setRouting(edge.getAttributes(),
        // GraphConstants.ROUTING_SIMPLE);
        GraphConstants.setEditable(edge.getAttributes(), false);
        GraphConstants.setLabelAlongEdge(edge.getAttributes(), true);
        GraphConstants.setSelectable(edge.getAttributes(), false);
        GraphConstants.setFont(edge.getAttributes(), EDGE_FONT);
        updateRelationshipLabels(edge, rel, reverse);
        relCells.put(getQualifiedName(rel), edge);
        if (reverse != null) {
            relCells.put(getQualifiedName(reverse), edge);
        }
        return edge;
    }
    return null;
}
Also used : Relationship(org.apache.cayenne.map.Relationship) DefaultEdge(org.jgraph.graph.DefaultEdge)

Example 2 with DefaultEdge

use of org.jgraph.graph.DefaultEdge in project cayenne by apache.

the class BaseGraphBuilder method updateRelationshipCell.

protected void updateRelationshipCell(Relationship rel) {
    if (rel.getSourceEntity() != null && rel.getTargetEntity() != null) {
        DefaultEdge edge = relCells.get(getQualifiedName(rel));
        if (edge != null) {
            updateRelationshipLabels(edge, rel, rel.getReverseRelationship());
            Map<DefaultEdge, AttributeMap> nested = new HashMap<>();
            nested.put(edge, edge.getAttributes());
            edit(nested);
        } else {
            insertRelationshipCell(rel);
        }
    }
}
Also used : AttributeMap(org.jgraph.graph.AttributeMap) HashMap(java.util.HashMap) DefaultEdge(org.jgraph.graph.DefaultEdge)

Example 3 with DefaultEdge

use of org.jgraph.graph.DefaultEdge in project cayenne by apache.

the class ObjGraphBuilder method postProcessEntity.

@Override
protected void postProcessEntity(Entity entity, DefaultGraphCell cell) {
    super.postProcessEntity(entity, cell);
    GraphConstants.setBackground(cell.getAttributes(), ENTITY_COLOR);
    GraphConstants.setOpaque(cell.getAttributes(), true);
    DefaultEdge edge = createInheritanceEdge((ObjEntity) entity);
    if (edge != null) {
        createdObjects.add(edge);
    }
}
Also used : DefaultEdge(org.jgraph.graph.DefaultEdge)

Example 4 with DefaultEdge

use of org.jgraph.graph.DefaultEdge in project cayenne by apache.

the class BaseGraphBuilder method insertRelationshipCell.

protected void insertRelationshipCell(Relationship rel) {
    DefaultEdge edge = createRelationshipCell(rel);
    insert(edge);
}
Also used : DefaultEdge(org.jgraph.graph.DefaultEdge)

Example 5 with DefaultEdge

use of org.jgraph.graph.DefaultEdge in project cayenne by apache.

the class BaseGraphBuilder method removeRelationshipCell.

protected void removeRelationshipCell(Relationship rel) {
    final DefaultEdge edge = relCells.get(getQualifiedName(rel));
    if (edge != null) {
        runWithUndoDisabled(() -> graph.getGraphLayoutCache().remove(new Object[] { edge }));
        relCells.remove(getQualifiedName(rel));
    }
}
Also used : 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