Search in sources :

Example 1 with CustomShapeLabel

use of eu.esdihumboldt.hale.ui.util.graph.CustomShapeLabel in project hale by halestudio.

the class TransformationTreeLabelProvider method getFigure.

/**
 * @see GraphLabelProvider#getFigure(Object)
 */
@Override
public IFigure getFigure(Object element) {
    if (element instanceof IdentityWrapper<?>) {
        element = ((IdentityWrapper<?>) element).getValue();
    }
    ShapePainter shape = null;
    String contextText = null;
    String cardText = null;
    if (element instanceof TransformationTree) {
        shape = new TransformationNodeShape(10, SWT.NONE);
    } else if (element instanceof TargetNode) {
        TargetNode node = (TargetNode) element;
        contextText = AlignmentUtil.getContextText(node.getEntityDefinition());
        if (!hasTransformationAnnotations(element)) {
            cardText = getCardinalityText(node.getEntityDefinition().getDefinition());
        }
        if (node.getAssignments().isEmpty()) {
            shape = new TransformationNodeShape(10, SWT.NONE);
        } else {
            // shape = new TransformationNodeShape(10, SWT.LEFT);
            shape = new FingerPost(10, SWT.LEFT);
        }
    } else if (element instanceof SourceNode) {
        SourceNode node = (SourceNode) element;
        contextText = AlignmentUtil.getContextText(node.getEntityDefinition());
        if (!hasTransformationAnnotations(element)) {
            cardText = getCardinalityText(node.getEntityDefinition().getDefinition());
        }
        if (node.getParent() == null) {
            shape = new TransformationNodeShape(10, SWT.NONE);
        } else {
            shape = new FingerPost(10, SWT.RIGHT);
        }
    }
    if (shape != null) {
        CustomShapeFigure figure;
        if (contextText != null || cardText != null) {
            figure = new EntityFigure(shape, contextText, cardText, getCustomFigureFont());
        } else {
            figure = new CustomShapeLabel(shape, getCustomFigureFont());
        }
        figure.setMaximumWidth(MAX_FIGURE_WIDTH);
        return figure;
    }
    element = TransformationTreeUtil.extractObject(element);
    return super.getFigure(element);
}
Also used : SourceNode(eu.esdihumboldt.hale.common.align.model.transformation.tree.SourceNode) TargetNode(eu.esdihumboldt.hale.common.align.model.transformation.tree.TargetNode) EntityFigure(eu.esdihumboldt.hale.ui.common.graph.figures.EntityFigure) CustomShapeFigure(eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure) FingerPost(eu.esdihumboldt.hale.ui.util.graph.shapes.FingerPost) IdentityWrapper(eu.esdihumboldt.util.IdentityWrapper) TransformationTree(eu.esdihumboldt.hale.common.align.model.transformation.tree.TransformationTree) ShapePainter(eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure.ShapePainter) CustomShapeLabel(eu.esdihumboldt.hale.ui.util.graph.CustomShapeLabel) TransformationNodeShape(eu.esdihumboldt.hale.ui.common.graph.figures.TransformationNodeShape)

Example 2 with CustomShapeLabel

use of eu.esdihumboldt.hale.ui.util.graph.CustomShapeLabel in project hale by halestudio.

the class GraphMLLabelProvider method getFigure.

@Override
public IFigure getFigure(Object element) {
    ShapePainter shape = null;
    if (element instanceof Vertex) {
        Vertex vex = (Vertex) element;
        if (vex.getProperty("type").equals("root")) {
            shape = new TransformationNodeShape(10, SWT.NONE);
        } else if (vex.getProperty("type").equals("target")) {
            boolean assigns = false;
            for (Vertex v : vex.getVertices(Direction.BOTH)) {
                if (v.getProperty("type").equals("cell")) {
                    assigns = true;
                }
            }
            if (assigns) {
                shape = new FingerPost(10, SWT.LEFT);
            } else
                shape = new TransformationNodeShape(10, SWT.NONE);
        } else if (vex.getProperty("type").equals("source")) {
            if (vex.getVertices(Direction.IN).iterator().hasNext() && vex.getVertices(Direction.OUT).iterator().hasNext()) {
                shape = new FingerPost(10, SWT.RIGHT);
            } else
                shape = new TransformationNodeShape(10, SWT.NONE);
        } else if (vex.getProperty("type").equals("cell")) {
            shape = new StretchedHexagon(10);
        }
        if (shape != null) {
            CustomShapeLabel figure;
            figure = new CustomShapeLabel(shape);
            figure.setMaximumWidth(MAX_FIGURE_WIDTH);
            return figure;
        }
    }
    return null;
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) FingerPost(eu.esdihumboldt.hale.ui.util.graph.shapes.FingerPost) StretchedHexagon(eu.esdihumboldt.hale.ui.util.graph.shapes.StretchedHexagon) ShapePainter(eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure.ShapePainter) CustomShapeLabel(eu.esdihumboldt.hale.ui.util.graph.CustomShapeLabel) TransformationNodeShape(eu.esdihumboldt.hale.ui.common.graph.figures.TransformationNodeShape)

Aggregations

TransformationNodeShape (eu.esdihumboldt.hale.ui.common.graph.figures.TransformationNodeShape)2 ShapePainter (eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure.ShapePainter)2 CustomShapeLabel (eu.esdihumboldt.hale.ui.util.graph.CustomShapeLabel)2 FingerPost (eu.esdihumboldt.hale.ui.util.graph.shapes.FingerPost)2 Vertex (com.tinkerpop.blueprints.Vertex)1 SourceNode (eu.esdihumboldt.hale.common.align.model.transformation.tree.SourceNode)1 TargetNode (eu.esdihumboldt.hale.common.align.model.transformation.tree.TargetNode)1 TransformationTree (eu.esdihumboldt.hale.common.align.model.transformation.tree.TransformationTree)1 EntityFigure (eu.esdihumboldt.hale.ui.common.graph.figures.EntityFigure)1 CustomShapeFigure (eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure)1 StretchedHexagon (eu.esdihumboldt.hale.ui.util.graph.shapes.StretchedHexagon)1 IdentityWrapper (eu.esdihumboldt.util.IdentityWrapper)1