Search in sources :

Example 96 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class DummyNodeAnchor method getDirectionPosition.

private Point getDirectionPosition(Point figCenter, Point reference) {
    Dimension nodeSize = this.source.getSize();
    EConnectionCategory category = null;
    EConnectionType lineStyle = null;
    if (connection != null) {
        lineStyle = connection.getLineStyle();
        category = lineStyle.getCategory();
    } else {
        lineStyle = ConnectionManager.getNewConnectionType();
        category = lineStyle.getCategory();
    }
    Point result = new Point(figCenter);
    if (category == EConnectionCategory.MAIN && lineStyle != EConnectionType.FLOW_REF) {
        if (!isTargetAnchor) {
            result.x = figCenter.x + nodeSize.width / 2;
        } else {
            result.x = figCenter.x - nodeSize.width / 2;
        }
        return result;
    } else if (category == EConnectionCategory.OTHER && (lineStyle == EConnectionType.FLOW_REF || lineStyle == EConnectionType.TABLE_REF)) {
        if (target != null) {
            int sourceY = this.source.getPosY();
            int targetY = this.target.getPosY();
            Rectangle sourceBounds = new Rectangle(this.source.getLocation(), this.source.getSize());
            Rectangle targetBounds = new Rectangle(this.target.getLocation(), this.target.getSize());
            if (!isTargetAnchor) {
                if (target.equals(source)) {
                    Point tempPoint = new Point(reference.x - nodeSize.width / 2, reference.y - nodeSize.height / 2);
                    targetBounds = new Rectangle(tempPoint, this.target.getSize());
                    targetY = reference.y - nodeSize.height / 2;
                }
                if (sourceY <= targetY) {
                    if ((targetBounds.getTopRight().y == sourceBounds.getBottomLeft().y)) {
                        result.y = figCenter.y - nodeSize.height / 2;
                    } else {
                        result.y = figCenter.y + nodeSize.height / 2;
                    }
                } else {
                    if (targetBounds.getBottomLeft().y == sourceBounds.getTopRight().y) {
                        result.y = figCenter.y + nodeSize.height / 2;
                    } else {
                        result.y = figCenter.y - nodeSize.height / 2;
                    }
                }
                return result;
            }
            //
            if (sourceY < targetY) {
                result.y = figCenter.y - nodeSize.height / 2;
            } else {
                result.y = figCenter.y + nodeSize.height / 2;
            }
            return result;
        }
    }
    return null;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) EConnectionCategory(org.talend.core.model.process.EConnectionCategory) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 97 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class LabelCenter method getFinalDisplayText.

public String getFinalDisplayText() {
    Dimension textSize = calculateTextSize(getText());
    Rectangle area = getClientArea();
    Insets i = getInsets();
    if (textSize.width >= area.width - i.left - i.right - OFFSET * 2) {
        return ELLIPSIS;
    }
    return text;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 98 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class NodeContainer method prepareStatus.

private Rectangle prepareStatus(Point nodeLocation, Dimension nodeSize) {
    Rectangle statusRectangle = null;
    Rectangle breakpointRectangle, warningRectangle, infoRectangle, parallelLocationRectangle, windowLocationRectangle, validationRuleRectangle, collapseRectangle;
    int status = node.getStatus();
    if ((status & Process.BREAKPOINT_STATUS) != 0) {
        breakpointLocation.x = nodeLocation.x - breakpointSize.width;
        breakpointLocation.y = nodeLocation.y - breakpointSize.height;
        breakpointRectangle = new Rectangle(breakpointLocation, breakpointSize);
        statusRectangle = breakpointRectangle;
    }
    if ((status & Process.ERROR_STATUS) != 0) {
        errorLocation.x = nodeLocation.x + nodeSize.width;
        errorLocation.y = nodeLocation.y - errorSize.height;
        errorRectangle = new Rectangle(errorLocation, errorSize);
        if (statusRectangle == null) {
            statusRectangle = errorRectangle;
        } else {
            statusRectangle.union(errorRectangle);
        }
    }
    if ((status & Process.WARNING_STATUS) != 0) {
        warningLocation.x = nodeLocation.x + nodeSize.width;
        warningLocation.y = nodeLocation.y - warningSize.height;
        warningRectangle = new Rectangle(warningLocation, warningSize);
        if (statusRectangle == null) {
            statusRectangle = warningRectangle;
        } else {
            statusRectangle.union(warningRectangle);
        }
    }
    if (this instanceof AbstractJobletContainer) {
        Dimension collapseSize = new Dimension(20, 20);
        collapseLocation.x = nodeLocation.x - 20;
        collapseLocation.y = nodeLocation.y - collapseSize.height;
        collapseRectangle = new Rectangle(collapseLocation, collapseSize);
        if (statusRectangle == null) {
            Point extendPoint = new Point();
            extendPoint.x = nodeLocation.x + nodeSize.width;
            extendPoint.y = nodeLocation.y - warningSize.height;
            Rectangle extendRectangle = new Rectangle(extendPoint, warningSize);
            statusRectangle = extendRectangle;
        }
        statusRectangle.union(collapseRectangle);
    }
    if ((status & Process.INFO_STATUS) != 0) {
        infoLocation.x = nodeLocation.x + nodeSize.width;
        infoLocation.y = nodeLocation.y - infoSize.height;
        infoRectangle = new Rectangle(infoLocation, infoSize);
        if (statusRectangle == null) {
            statusRectangle = infoRectangle;
        } else {
            statusRectangle.union(infoRectangle);
        }
    }
    if ((status & Process.VALIDATION_RULE_STATUS) != 0) {
        validationRuleLocation.x = nodeLocation.x + nodeSize.width / 2 + nodeSize.width / 4;
        validationRuleLocation.y = nodeLocation.y - validationRuleSize.height / 2;
        validationRuleRectangle = new Rectangle(validationRuleLocation, validationRuleSize);
        if (statusRectangle == null) {
            statusRectangle = validationRuleRectangle;
        } else {
            statusRectangle.union(validationRuleRectangle);
        }
    }
    if (node.isErrorFlag()) {
        markLocation.x = nodeLocation.x - nodeSize.width / 2;
        markLocation.y = nodeLocation.y;
        errorMarkLocation.x = nodeLocation.x - (errorMarkSize.width - nodeSize.width) / 2;
        errorMarkLocation.y = markLocation.y - errorMarkSize.height;
        errorMarkRectangle = new Rectangle(errorMarkLocation, errorMarkSize);
        if (statusRectangle == null) {
            statusRectangle = errorMarkRectangle;
        } else {
            statusRectangle.union(errorMarkRectangle);
        }
    }
    boolean parallelize = false;
    IElementParameter enableParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE.getName());
    if (enableParallelizeParameter != null) {
        parallelize = (Boolean) enableParallelizeParameter.getValue();
    }
    if (parallelize) {
        parallelLocation.x = nodeLocation.x - parallelSize.width;
        parallelLocation.y = nodeLocation.y - parallelSize.height;
        parallelLocationRectangle = new Rectangle(parallelLocation, parallelSize);
        if (statusRectangle == null) {
            statusRectangle = parallelLocationRectangle;
        } else {
            statusRectangle.union(parallelLocationRectangle);
        }
    }
    IElementParameter window = node.getElementParameter(EParameterName.WINDOW_DURATION.getName());
    String windowDuration = null;
    if (window != null) {
        windowDuration = (String) window.getValue();
    }
    if (windowDuration != null) {
        windowLocation.x = nodeLocation.x - ((nodeLocation.x + (windowSize.width / 2)) - (nodeLocation.x + (nodeSize.width / 2)));
        windowLocation.y = nodeLocation.y - windowSize.height;
        windowLocationRectangle = new Rectangle(windowLocation, windowSize);
        if (statusRectangle == null) {
            statusRectangle = windowLocationRectangle;
        } else {
            statusRectangle.union(windowLocationRectangle);
        }
    }
    return statusRectangle;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) IElementParameter(org.talend.core.model.process.IElementParameter) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 99 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class NodeContainer method getNodeContainerRectangle.

public Rectangle getNodeContainerRectangle() {
    Point nodeLocation;
    nodeLocation = node.getLocation();
    Dimension nodeSize;
    Dimension labelSize;
    Dimension errorNodeSize;
    nodeSize = node.getSize();
    Rectangle nodeRectangle = new Rectangle(nodeLocation, nodeSize);
    Rectangle statusRectangle = prepareStatus(nodeLocation, nodeSize);
    Point labelLocation = nodeLabel.getLocation().getCopy();
    Point offset = nodeLabel.getOffset();
    Point textOffset = new Point();
    labelSize = nodeLabel.getLabelSize();
    textOffset.y = nodeSize.height;
    textOffset.x = (nodeSize.width - labelSize.width) / 2;
    nodeLabel.setTextOffset(textOffset);
    labelLocation.translate(offset);
    labelLocation.translate(textOffset);
    Rectangle labelRectangle = new Rectangle(labelLocation, labelSize);
    errorNodeSize = nodeError.getErrorSize();
    Point progressLocation = nodeProgressBar.getLocation().getCopy();
    Rectangle progressNodeRectangle = new Rectangle(progressLocation, new Dimension(80, 80));
    Rectangle finalRect;
    finalRect = nodeRectangle.getUnion(labelRectangle).getUnion(statusRectangle);
    if (node.isErrorFlag()) {
        finalRect.height += errorNodeSize.height;
        finalRect.height += errorMarkSize.height;
    }
    if (node.isFileScaleComponent()) {
        // finalRect.height += progressNodeSize.height;//
        finalRect = finalRect.getUnion(progressNodeRectangle);
    }
    return finalRect;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 100 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class NodeContainer method prepareCleanStatus.

private Rectangle prepareCleanStatus(Point nodeLocation, Dimension nodeSize) {
    Rectangle statusRectangle = null;
    Rectangle breakpointRectangle, warningRectangle, infoRectangle, validationRuleRectangle, collapseRectangle;
    int status = node.getStatus();
    if ((status & Process.BREAKPOINT_STATUS) != 0) {
        breakpointLocation.x = nodeLocation.x - breakpointSize.width;
        breakpointLocation.y = nodeLocation.y - breakpointSize.height;
        breakpointRectangle = new Rectangle(breakpointLocation, breakpointSize);
        statusRectangle = breakpointRectangle;
    }
    if ((status & Process.ERROR_STATUS) != 0) {
        errorLocation.x = nodeLocation.x + nodeSize.width;
        errorLocation.y = nodeLocation.y - errorSize.height;
        errorRectangle = new Rectangle(errorLocation, errorSize);
        if (statusRectangle == null) {
            statusRectangle = errorRectangle;
        } else {
            statusRectangle.union(errorRectangle);
        }
    }
    if ((status & Process.WARNING_STATUS) != 0) {
        warningLocation.x = nodeLocation.x + nodeSize.width;
        warningLocation.y = nodeLocation.y - warningSize.height;
        warningRectangle = new Rectangle(warningLocation, warningSize);
        if (statusRectangle == null) {
            statusRectangle = warningRectangle;
        } else {
            statusRectangle.union(warningRectangle);
        }
    }
    if (this instanceof AbstractJobletContainer) {
        Dimension collapseSize = new Dimension(20, 20);
        collapseLocation.x = nodeLocation.x - 20;
        collapseLocation.y = nodeLocation.y - collapseSize.height;
        collapseRectangle = new Rectangle(collapseLocation, collapseSize);
        if (statusRectangle == null) {
            Point extendPoint = new Point();
            extendPoint.x = nodeLocation.x + nodeSize.width;
            extendPoint.y = nodeLocation.y - warningSize.height;
            Rectangle extendRectangle = new Rectangle(extendPoint, warningSize);
            statusRectangle = extendRectangle;
        }
        statusRectangle.union(collapseRectangle);
    }
    if ((status & Process.INFO_STATUS) != 0) {
        infoLocation.x = nodeLocation.x + nodeSize.width;
        infoLocation.y = nodeLocation.y - infoSize.height;
        infoRectangle = new Rectangle(infoLocation, infoSize);
        if (statusRectangle == null) {
            statusRectangle = infoRectangle;
        } else {
            statusRectangle.union(infoRectangle);
        }
    }
    if ((status & Process.VALIDATION_RULE_STATUS) != 0) {
        validationRuleLocation.x = nodeLocation.x + nodeSize.width / 2 + nodeSize.width / 4;
        validationRuleLocation.y = nodeLocation.y - validationRuleSize.height / 2;
        validationRuleRectangle = new Rectangle(validationRuleLocation, validationRuleSize);
        if (statusRectangle == null) {
            statusRectangle = validationRuleRectangle;
        } else {
            statusRectangle.union(validationRuleRectangle);
        }
    }
    if (node.isErrorFlag()) {
        markLocation.x = nodeLocation.x - nodeSize.width / 2;
        markLocation.y = nodeLocation.y;
        errorMarkLocation.x = nodeLocation.x - (errorMarkSize.width - nodeSize.width) / 2;
        errorMarkLocation.y = markLocation.y - errorMarkSize.height;
        errorMarkRectangle = new Rectangle(errorMarkLocation, errorMarkSize);
        if (statusRectangle == null) {
            statusRectangle = errorMarkRectangle;
        } else {
            statusRectangle.union(errorMarkRectangle);
        }
    }
    return statusRectangle;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)105 Point (org.eclipse.draw2d.geometry.Point)46 Rectangle (org.eclipse.draw2d.geometry.Rectangle)43 IFigure (org.eclipse.draw2d.IFigure)20 List (java.util.List)15 Insets (org.eclipse.draw2d.geometry.Insets)8 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)6 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 ArrayList (java.util.ArrayList)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3 IElementParameter (org.talend.core.model.process.IElementParameter)3 AbstractJobletContainer (org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer)3 LinkedList (java.util.LinkedList)2 Figure (org.eclipse.draw2d.Figure)2 Label (org.eclipse.draw2d.Label)2 PolylineConnection (org.eclipse.draw2d.PolylineConnection)2 PointList (org.eclipse.draw2d.geometry.PointList)2 GraphicalViewerKeyHandler (org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)2 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)2