Search in sources :

Example 11 with Dimension

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

the class NodeAnchor method getLocationForMultipleConnections.

public Point getLocationForMultipleConnections(int connectionId) {
    if ((sourceLocation.y >= targetLocation.y) && ((sourceLocation.y + sourceRect.height) <= (targetLocation.y + targetRect.height))) {
        targetRect = new Rectangle(new Point(targetLocation.x, sourceLocation.y), new Dimension(targetRect.width, sourceRect.height));
    } else if ((sourceLocation.x >= targetLocation.x) && ((sourceLocation.x + sourceRect.width) <= (targetLocation.x + targetRect.width))) {
        targetRect = new Rectangle(new Point(sourceLocation.x, targetLocation.y), new Dimension(sourceRect.width, sourceRect.height));
    }
    // will calculate the numerator and denominator for the function to place the points.
    // example: 1/2; 3/4; 1/4; 5/8; 3/8; 7/8; 1/8; 9/16; 7/16; 11/16; 5/16; 13/16; 3/16...
    int num = 1;
    int numPair = 1;
    int numImpair = 1;
    int denom = 2;
    for (int i = 1; i < connectionId + 1; i++) {
        if ((i % 2) == 0) {
            // pair
            if ((numPair + 2) > denom) {
                denom = denom * 2;
                numPair = (denom / 2) + 1;
                numImpair = numPair;
            } else {
                numPair += 2;
            }
            num = numPair;
        } else {
            // impair
            numImpair -= 2;
            if (numImpair > 0) {
                num = numImpair;
            }
        }
    }
    LineSeg lineSource, lineTarget;
    if ((sourceLocation.x < targetRect.getCenter().x) && (targetRect.getCenter().x < (sourceLocation.x + sourceRect.width))) {
        lineSource = new LineSeg(sourceRect.getLeft(), sourceRect.getRight());
        lineTarget = new LineSeg(targetRect.getLeft(), targetRect.getRight());
    } else {
        lineSource = new LineSeg(sourceRect.getTop(), sourceRect.getBottom());
        lineTarget = new LineSeg(targetRect.getTop(), targetRect.getBottom());
    }
    Double length = (lineSource.length() * num / denom);
    Point pointSource = new Point();
    lineSource.pointOn(length.longValue(), KeyPoint.ORIGIN, pointSource);
    length = (lineTarget.length() * num / denom);
    Point pointTarget = new Point();
    lineTarget.pointOn(length.longValue(), KeyPoint.ORIGIN, pointTarget);
    if ((sourceLocation.y < pointTarget.y) && (pointTarget.y < (sourceLocation.y + sourceRect.height))) {
        // contains
        pointSource.y = pointTarget.y;
    }
    if ((sourceLocation.x < pointTarget.x) && (pointTarget.x < (sourceLocation.x + sourceRect.width))) {
        // contains
        pointSource.x = pointTarget.x;
    }
    return calculateLocationFromRef(pointSource, pointTarget);
}
Also used : LineSeg(org.talend.commons.ui.gmf.draw2d.LineSeg) Rectangle(org.eclipse.draw2d.geometry.Rectangle) KeyPoint(org.talend.commons.ui.gmf.draw2d.LineSeg.KeyPoint) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) KeyPoint(org.talend.commons.ui.gmf.draw2d.LineSeg.KeyPoint) Point(org.eclipse.draw2d.geometry.Point)

Example 12 with Dimension

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

the class NodeContainerFigure method initializeNodeContainer.

public void initializeNodeContainer(Rectangle rectangle) {
    this.disposeColors();
    rectFig.setLocation(new Point(rectangle.x, rectangle.y));
    rectFig.setSize(new Dimension(rectangle.width, rectangle.height));
    if (isShowCompareMark()) {
        rectFig.setVisible(true);
        rectFig.setForegroundColor(new Color(Display.getDefault(), new RGB(204, 153, 255)));
    } else {
        rectFig.setForegroundColor(new Color(Display.getDefault(), new RGB(255, 102, 102)));
    }
    markFigure.setSize(errorMarkImage.getImageData().width, errorMarkImage.getImageData().height);
}
Also used : Color(org.eclipse.swt.graphics.Color) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) RGB(org.eclipse.swt.graphics.RGB)

Example 13 with Dimension

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

the class LabelCenter method setImage.

/**
     * Sets the Image that this ImageFigure displays.
     * <p>
     * IMPORTANT: Note that it is the client's responsibility to dispose the given image.
     * 
     * @param image The Image to be displayed. It can be <code>null</code>.
     */
public void setImage(Image image) {
    if (img == image)
        return;
    img = image;
    if (img != null)
        size = new Rectangle(image.getBounds()).getSize();
    else
        size = new Dimension();
    revalidate();
    repaint();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 14 with Dimension

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

the class NodeContainer method getNodeMarkRectangle.

public Rectangle getNodeMarkRectangle() {
    Point nodeLocation;
    nodeLocation = node.getLocation();
    Dimension nodeSize;
    Dimension labelSize;
    Dimension errorNodeSize;
    Dimension progressNodeSize;
    nodeSize = node.getSize();
    Rectangle nodeRectangle = new Rectangle(nodeLocation, nodeSize);
    Rectangle statusRectangle = prepareCleanStatus(nodeLocation, nodeSize);
    labelSize = nodeLabel.getLabelSize();
    errorNodeSize = nodeError.getErrorSize();
    progressNodeSize = nodeProgressBar.getProgressSize();
    Rectangle finalRect;
    finalRect = nodeRectangle.getUnion(statusRectangle);
    finalRect.height += labelSize.height / 2;
    if (node.isErrorFlag()) {
        finalRect.height += errorNodeSize.height;
    }
    if (node.isFileScaleComponent()) {
        finalRect.height += progressNodeSize.height;
    }
    return finalRect;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 15 with Dimension

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

the class NodeErrorEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
    NodeLabel nodeLabel = node.getNodeLabel();
    NodeErrorFigure errorFig = (NodeErrorFigure) this.getFigure();
    Point loc = node.getLocation().getCopy();
    Dimension size = errorFig.getSize();
    loc.x = loc.x + (node.getSize().width - size.width) / 2;
    loc.y = loc.y + node.getSize().height + (nodeLabel.getLabelSize().height);
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

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