Search in sources :

Example 91 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ERTableNode method setStartPointByCenter.

public void setStartPointByCenter(int centerX, int centerY) {
    Dimension d = getDefaultPreferredSize();
    this.x = centerX - d.width / 2;
    this.y = centerY - d.height / 2;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 92 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ERMinJoinDirectedGraphLayout method buildLayoutSumLenth.

public int buildLayoutSumLenth(List<ERTableNode> allNode, boolean horizon) {
    if (allNode == null || allNode.isEmpty()) {
        return 0;
    }
    int sum = 0;
    int count = allNode.size();
    ERTableNode firstNode = allNode.get(0);
    ERTableNode endNode = allNode.get(count - 1);
    if (horizon) {
        sum += firstNode.width / 2;
        sum += endNode.width / 2;
        for (int i = 0; i < count - 1; i++) {
            Dimension tmpD = buildDefaultCenterOffset(allNode.get(i), allNode.get(i + 1), Ray.RIGHT);
            sum += Math.abs(tmpD.width);
        }
    } else {
        sum += firstNode.height / 2;
        sum += endNode.height / 2;
        for (int i = 0; i < count - 1; i++) {
            Dimension tmpD = buildDefaultCenterOffset(allNode.get(i), allNode.get(i + 1), Ray.DOWN);
            sum += Math.abs(tmpD.height);
        }
    }
    return sum;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 93 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ERMinJoinDirectedGraphLayout method getHighestNode.

private ERTableNode getHighestNode(List<ERTableNode> nodes) {
    ERTableNode result = null;
    int highest = 0;
    if (nodes.size() == 1) {
        return nodes.get(0);
    }
    for (ERTableNode node : nodes) {
        Dimension d = node.getDefaultPreferredSize();
        if (d.height > highest) {
            highest = d.height;
            result = node;
        }
    }
    return result;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 94 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project cubrid-manager by CUBRID.

the class ERMinJoinDirectedGraphLayout method buildRelationNodeXY.

private void buildRelationNodeXY(ERTableNode basicNode, ERTableNode otherNode, Ray ray) {
    Dimension offsetD = buildDefaultCenterOffset(basicNode, otherNode, ray);
    buildRelationNodeXY(basicNode, otherNode, ray, offsetD);
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 95 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project dbeaver by serge-rider.

the class EntityAddCommand method execute.

@Override
public void execute() {
    Point curLocation = location == null ? null : new Point(location);
    for (ERDEntity entity : entities) {
        diagramPart.getDiagram().addTable(entity, true);
        if (curLocation != null) {
            // Put new entities in specified location
            for (Object diagramChild : diagramPart.getChildren()) {
                if (diagramChild instanceof EntityPart) {
                    EntityPart entityPart = (EntityPart) diagramChild;
                    if (entityPart.getTable() == entity) {
                        final Rectangle newBounds = new Rectangle();
                        final Dimension size = entityPart.getFigure().getPreferredSize();
                        newBounds.x = curLocation.x;
                        newBounds.y = curLocation.y;
                        newBounds.width = size.width;
                        newBounds.height = size.height;
                        entityPart.modifyBounds(newBounds);
                        curLocation.x += size.width + 20;
                        break;
                    }
                }
            }
        }
    }
}
Also used : ERDEntity(org.jkiss.dbeaver.ext.erd.model.ERDEntity) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) EntityPart(org.jkiss.dbeaver.ext.erd.part.EntityPart)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)180 Rectangle (org.eclipse.draw2d.geometry.Rectangle)80 Point (org.eclipse.draw2d.geometry.Point)70 IFigure (org.eclipse.draw2d.IFigure)31 List (java.util.List)16 Insets (org.eclipse.draw2d.geometry.Insets)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)8 PointList (org.eclipse.draw2d.geometry.PointList)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)6 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)5 ArrayList (java.util.ArrayList)4 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 Font (org.eclipse.swt.graphics.Font)4 Point (org.eclipse.swt.graphics.Point)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)3 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)3 Label (org.eclipse.draw2d.Label)3 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3