use of org.jgraph.graph.DefaultGraphCell in project cayenne by apache.
the class BaseGraphBuilder method updateRelationshipLabels.
/**
* Updates relationship labels for specified relationship edge.
*/
protected void updateRelationshipLabels(DefaultEdge edge, Relationship rel, Relationship reverse) {
DefaultGraphCell sourceCell = entityCells.get(rel.getSourceEntity().getName());
DefaultGraphCell targetCell = entityCells.get(rel.getTargetEntity().getName());
edge.setSource(sourceCell != null ? sourceCell.getChildAt(0) : null);
edge.setTarget(targetCell != null ? targetCell.getChildAt(0) : null);
Object[] labels = { rel.getName() + " " + getRelationshipLabel(rel), reverse == null ? "" : reverse.getName() + " " + getRelationshipLabel(reverse) };
GraphConstants.setExtraLabels(edge.getAttributes(), labels);
Point2D[] labelPositions = { new Point2D.Double(GraphConstants.PERMILLE * (0.1 + 0.2 * Math.random()), 10), new Point2D.Double(GraphConstants.PERMILLE * (0.9 - 0.2 * Math.random()), -10) };
GraphConstants.setExtraLabelPositions(edge.getAttributes(), labelPositions);
}
use of org.jgraph.graph.DefaultGraphCell in project cayenne by apache.
the class BaseGraphBuilder method removeEntityCell.
protected void removeEntityCell(Entity e) {
final DefaultGraphCell cell = entityCells.get(e.getName());
if (cell != null) {
runWithUndoDisabled(() -> graph.getGraphLayoutCache().remove(new Object[] { cell }, true, true));
entityCells.remove(e.getName());
}
}
use of org.jgraph.graph.DefaultGraphCell in project cayenne by apache.
the class BaseGraphBuilder method createEntityCell.
protected DefaultGraphCell createEntityCell(Entity entity) {
DefaultGraphCell cell = new DefaultGraphCell(getCellMetadata(entity));
GraphConstants.setResize(cell.getAttributes(), true);
GraphConstants.setBorder(cell.getAttributes(), new LineBorder(Color.BLACK));
GraphConstants.setEditable(cell.getAttributes(), false);
entityCells.put(entity.getName(), cell);
cell.addPort();
return cell;
}
use of org.jgraph.graph.DefaultGraphCell 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