use of org.whole.lang.ui.figures.IEntityFigure in project whole by wholeplatform.
the class EntityOutlineRightFigure method paintConnections.
@SuppressWarnings("unchecked")
protected void paintConnections(Graphics graphics) {
graphics.setForegroundColor(FigureConstants.contentLighterColor);
Point rootPoint = getFoldingToggle(0).getBounds().getBottom();
Object childrenFigure = getContentPane(1).getChildren().get(0);
Point[] childrenPoints = null;
if (childrenFigure instanceof TableFigure) {
TableFigure tableFigure = (TableFigure) childrenFigure;
TableLayout layoutManager = tableFigure.getLayoutManager();
int childrenSize = layoutManager.rows();
childrenPoints = new Point[childrenSize];
if (childrenSize == 0)
return;
for (int i = 0; i < childrenSize; i++) {
IFigure row = layoutManager.getRow(i);
List<IFigure> rowChildren = row.getChildren();
if (row instanceof TableRowFigure && !rowChildren.isEmpty()) {
childrenPoints[i] = row.getBounds().getLeft().translate(-8, 0);
childrenPoints[i].y = ((TableRowLayout) row.getLayoutManager()).getBaseline(0);
} else if (row instanceof IEntityFigure) {
childrenPoints[i] = row.getBounds().getTopLeft().translate(-4, ((IEntityFigure) row).getAscent());
} else
childrenPoints[i] = row.getBounds().getLeft().translate(-4, 0);
}
} else {
IFigure childFigure = (IFigure) childrenFigure;
List<IFigure> children = childFigure.getChildren();
int childrenSize = children.size();
if (childrenSize == 0 || childFigure instanceof ITextFigure) {
childrenPoints = new Point[1];
if (childFigure instanceof IEntityFigure)
childrenPoints[0] = childFigure.getBounds().getTopLeft().translate(-4, ((IEntityFigure) childFigure).getAscent());
else
childrenPoints[0] = childFigure.getBounds().getLeft().translate(-4, 0);
} else {
childrenPoints = new Point[childrenSize];
for (int i = 0; i < childrenSize; i++) {
childFigure = children.get(i);
if (childFigure instanceof IEntityFigure)
childrenPoints[i] = childFigure.getBounds().getTopLeft().translate(-6, ((IEntityFigure) childFigure).getAscent());
else
childrenPoints[i] = childFigure.getBounds().getLeft().translate(-6, 0);
}
}
}
graphics.setForegroundColor(ColorConstants.lightGray);
graphics.setLineStyle(SWT.LINE_CUSTOM);
graphics.setLineDash(new int[] { 1, 1 });
DrawUtils.drawOutline(graphics, rootPoint, childrenPoints);
graphics.setLineStyle(SWT.LINE_SOLID);
graphics.setLineDash((int[]) null);
}
use of org.whole.lang.ui.figures.IEntityFigure in project whole by wholeplatform.
the class OutlineCompositeNodeFigure method paintConnections.
protected void paintConnections(Graphics graphics) {
IFigure contentPane = getContentPane(getContentPanesSize() - 1);
List<?> list = contentPane.getChildren();
if (contentPane.isVisible() && !list.isEmpty()) {
IFigure contentsFigure = (IFigure) list.get(0);
Point[] children;
if (contentsFigure instanceof CompositeFigure) {
int compositeChildrenNumber = contentsFigure.getChildren().size();
if (compositeChildrenNumber == 0)
return;
children = new Point[compositeChildrenNumber];
for (int i = 0; i < compositeChildrenNumber; i++) {
IFigure compositeChild = (IFigure) contentsFigure.getChildren().get(i);
// calculate target point position
Point targetLocation;
if (compositeChild instanceof INodeFigure)
targetLocation = ((INodeFigure) compositeChild).getTargetAnchor(0).getLocation(null);
else {
Rectangle compositeChildBounds = compositeChild.getBounds();
targetLocation = compositeChildBounds.getLeft();
if (compositeChild instanceof IEntityFigure)
targetLocation.y = compositeChildBounds.y + ((IEntityFigure) compositeChild).getAscent();
compositeChild.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
children[i] = targetLocation;
}
} else {
children = new Point[1];
// calculate target point position
Point targetLocation;
if (contentsFigure instanceof INodeFigure)
targetLocation = ((INodeFigure) contentsFigure).getTargetAnchor(0).getLocation(null);
else {
Rectangle compositeChildBounds = contentsFigure.getBounds();
targetLocation = compositeChildBounds.getLeft();
if (contentsFigure instanceof IEntityFigure)
targetLocation.y = compositeChildBounds.y + ((IEntityFigure) contentsFigure).getAscent();
contentsFigure.translateToAbsolute(targetLocation);
}
translateToRelative(targetLocation);
children[0] = targetLocation;
}
Point start = getSourceAnchor(0).getLocation(null);
translateToRelative(start);
graphics.setForegroundColor(ColorConstants.lightGray);
graphics.setLineDash(new int[] { 1, 1 });
DrawUtils.drawOutline(graphics, start, children);
}
}
use of org.whole.lang.ui.figures.IEntityFigure in project whole by wholeplatform.
the class AbstractConnectedFreeformRootPart method createFigure.
protected IFigure createFigure() {
// Figure figure = new FreeformLayer();
IEntityFigure figure = new EntityFigure() {
{
setLayoutManager(new EntityXYLayout());
setOpaque(false);
}
// FIXME workaround
public int getIndent() {
return getInsets().left;
}
public int getAscent() {
return getPreferredSize().height / 2;
}
public static final int MINIMUM_SIZE = 50;
public Dimension getPreferredSize(int wHint, int hHint) {
Dimension size = super.getPreferredSize(wHint, hHint);
size.width = Math.max(size.width, MINIMUM_SIZE);
size.height = Math.max(size.height, MINIMUM_SIZE);
return size;
}
};
// figure.setLayoutManager(new EntityXYLayout());
// figure.setOpaque(false);
setConnectionRouter(createConnectionRouter(figure));
return figure;
}
use of org.whole.lang.ui.figures.IEntityFigure in project whole by wholeplatform.
the class AbstractContentPanePart method getContentPane.
public IFigure getContentPane(EditPart childEditPart) {
IFigure childFigure = ((GraphicalEditPart) childEditPart).getFigure();
IFigure childParentFigure = childFigure.getParent();
IEntityFigure cpFigure = getContentPaneFigure();
for (int i = 0; i < cpFigure.getContentPanesSize(); i++) if (childParentFigure == cpFigure.getContentPane(i))
return childParentFigure;
return getContentPane();
}
use of org.whole.lang.ui.figures.IEntityFigure in project whole by wholeplatform.
the class RootFragmentPart method createFigure.
protected IFigure createFigure() {
// Figure f = new FreeformLayer() {
IEntityFigure f = new EntityFigure() {
{
setOpaque(false);
}
@Override
public void paint(Graphics graphics) {
graphics.setAdvanced(true);
graphics.setAntialias(SWT.ON);
super.paint(graphics);
}
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
Rectangle r2 = ((IFigure) getChildren().get(0)).getBounds();
translateToParent(r2 = r2.getCopy());
Rectangle clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
graphics.fillRectangle(clipArea);
graphics.setBackgroundColor(FigureConstants.hostLanguageColor);
graphics.fillRectangle(clipArea.intersect(r2));
graphics.setLineWidth(1);
graphics.setLineStyle(Graphics.LINE_SOLID);
graphics.setXORMode(false);
IEntity rootEntity = ((RootFragment) getModelEntity()).getRootEntity().wGetAdaptee(false);
if (rootEntity.wGetParent() instanceof RootFragment) {
clipArea = graphics.getClip(new Rectangle()).expand(1, 1);
int oldAlpha = graphics.getAlpha();
graphics.setAlpha(60);
graphics.setForegroundColor(ColorConstants.darkGray);
graphics.setLineWidth(1);
graphics.drawRectangle(r2.getTranslated(-1, -1).resize(1, 1));
graphics.setForegroundColor(ColorConstants.lightGray);
graphics.setLineWidth(5);
graphics.drawRoundRectangle(r2.getTranslated(-4, -4).resize(7, 7), 10, 10);
graphics.setAlpha(oldAlpha);
} else {
graphics.setForegroundColor(ColorConstants.lightGray);
graphics.drawRectangle(r2.x - 1, r2.y - 1, r2.width + 1, r2.height + 1);
}
}
public void validate() {
super.validate();
repaint();
}
};
f.setLayoutManager(new StackLayout().withMargin(5).withMinorAlignment(Alignment.CENTER));
f.setBackgroundColor(FigureUtilities.lighter(ColorConstants.gray));
f.setOpaque(false);
f.addLayoutListener(LayoutAnimator.getDefault());
return f;
}
Aggregations