Search in sources :

Example 1 with CustomShapeFigure

use of eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure 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)

Aggregations

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 TransformationNodeShape (eu.esdihumboldt.hale.ui.common.graph.figures.TransformationNodeShape)1 CustomShapeFigure (eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure)1 ShapePainter (eu.esdihumboldt.hale.ui.util.graph.CustomShapeFigure.ShapePainter)1 CustomShapeLabel (eu.esdihumboldt.hale.ui.util.graph.CustomShapeLabel)1 FingerPost (eu.esdihumboldt.hale.ui.util.graph.shapes.FingerPost)1 IdentityWrapper (eu.esdihumboldt.util.IdentityWrapper)1