Search in sources :

Example 1 with Edge

use of eu.esdihumboldt.hale.ui.common.graph.content.Edge in project hale by halestudio.

the class AlignmentViewContentProvider method getEdges.

/**
 * Get all edges for the given type cell and its property cells.
 *
 * @param typeCell the type cell to show
 * @return the array of edges
 */
private Object[] getEdges(Cell typeCell) {
    List<Edge> edges = new ArrayList<Edge>();
    AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
    Alignment alignment = as.getAlignment();
    boolean dummyCell;
    if (typeCell.getId() != null) {
        // XXX really filter type cell out?
        if (select(typeCell)) {
            addEdges(typeCell, edges);
        }
        dummyCell = false;
    } else {
        // dummy cell, look for matching type cells
        for (Cell cell : alignment.getTypeCells(typeCell)) if (select(cell))
            addEdges(cell, edges);
        dummyCell = true;
    }
    for (Cell cell : sortCells(as.getAlignment().getPropertyCells(typeCell, true, dummyCell))) {
        if (!select(cell))
            continue;
        Cell reparentCell = AlignmentUtil.reparentCell(cell, typeCell, false);
        // to the original cell
        if (reparentCell == cell)
            addEdges(cell, edges);
        else {
            // add edges leading to the cell for each source entity
            if (reparentCell.getSource() != null) {
                for (Entry<String, ? extends Entity> entry : reparentCell.getSource().entries()) {
                    edges.add(new Edge(entry.getValue(), cell, entry.getKey()));
                }
            }
            // add edges leading to the target entities from the cell
            for (Entry<String, ? extends Entity> entry : reparentCell.getTarget().entries()) {
                edges.add(new Edge(cell, entry.getValue(), entry.getKey()));
            }
        }
    }
    return edges.toArray();
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) ArrayList(java.util.ArrayList) Edge(eu.esdihumboldt.hale.ui.common.graph.content.Edge) Cell(eu.esdihumboldt.hale.common.align.model.Cell)

Aggregations

Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 Cell (eu.esdihumboldt.hale.common.align.model.Cell)1 Edge (eu.esdihumboldt.hale.ui.common.graph.content.Edge)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 ArrayList (java.util.ArrayList)1