use of eu.esdihumboldt.hale.ui.common.graph.figures.TransformationNodeShape 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);
}
use of eu.esdihumboldt.hale.ui.common.graph.figures.TransformationNodeShape 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;
}
Aggregations