Search in sources :

Example 66 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle 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 67 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle 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 68 with Rectangle

use of org.eclipse.draw2d.geometry.Rectangle 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)

Example 69 with Rectangle

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

the class DummyNodeAnchor method getSourceAnchorLocation.

public Point getSourceAnchorLocation(Point reference) {
    Point sourceCenter = new Rectangle(source.getLocation(), source.getSize()).getCenter();
    Point sourcePoint = getDirectionPosition(sourceCenter, reference);
    if (!isTargetAnchor && sourcePoint == null) {
        return super.getLocation(reference);
    }
    if (sourcePoint != null) {
        if (!isTargetAnchor) {
            return sourcePoint;
        }
    }
    if (target != null) {
        Point targetCenter = new Rectangle(target.getLocation(), target.getSize()).getCenter();
        Point targetPoint = getDirectionPosition(targetCenter, reference);
        if (isTargetAnchor && targetPoint == null) {
            return super.getLocation(reference);
        }
        if (targetPoint != null) {
            if (isTargetAnchor) {
                return targetPoint;
            }
        }
    }
    return super.getLocation(reference);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 70 with Rectangle

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

the class ReplaceMultiFlowBytReplicateMigrationTask method checkMaxOutputAndUpdate.

/**
     * DOC nrousseau Comment method "checkMaxOutputAndUpdate".
     * 
     * @param processItem
     * @param processType
     * @param component
     */
@SuppressWarnings("unchecked")
private boolean checkMaxOutputAndUpdate(Item processItem, ProcessType processType, IComponent component, NodeType nodeTypeSource) throws PersistenceException {
    boolean modified = false;
    String nodeSourceUniqueName = ComponentUtilities.getNodeUniqueName(nodeTypeSource);
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    List<INodeConnector> nodeConnectors = (List<INodeConnector>) component.createConnectors(null);
    for (INodeConnector nodeConnector : nodeConnectors) {
        if (nodeConnector.getBaseSchema().equals("FLOW") && nodeConnector.getMaxLinkOutput() == 1) {
            //$NON-NLS-1$
            List<ConnectionType> connections = getConnectionsToMove(processType, nodeConnector, nodeSourceUniqueName);
            if (connections != null) {
                List<Rectangle> targetPos = getTargetsRectangle(connections);
                Rectangle startPos = getNodeRectangle(processType, nodeSourceUniqueName);
                Integer tReplicateYPos = 0;
                Integer tReplicateXPos = Integer.MAX_VALUE;
                for (Rectangle rect : targetPos) {
                    if (rect.x < tReplicateXPos) {
                        tReplicateXPos = rect.x;
                    }
                    tReplicateYPos += rect.y;
                }
                tReplicateXPos = (tReplicateXPos + startPos.x) / 2;
                tReplicateYPos = tReplicateYPos / targetPos.size();
                int tempVar = tReplicateXPos / GRID_SIZE;
                tReplicateXPos = tempVar * GRID_SIZE;
                tempVar = tReplicateYPos / GRID_SIZE;
                tReplicateYPos = tempVar * GRID_SIZE;
                Point tReplicatePos = findLocationForNode(processType, new Point(tReplicateXPos, tReplicateYPos));
                addtReplicateComponent(processType, tReplicatePos, nodeTypeSource, nodeSourceUniqueName, nodeConnector, connections);
                modified = true;
            }
        }
    }
    if (modified) {
        factory.save(processItem);
    }
    return modified;
}
Also used : ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) INodeConnector(org.talend.core.model.process.INodeConnector) Point(org.eclipse.draw2d.geometry.Point) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Rectangle (org.eclipse.draw2d.geometry.Rectangle)347 Point (org.eclipse.draw2d.geometry.Point)107 Dimension (org.eclipse.draw2d.geometry.Dimension)80 IFigure (org.eclipse.draw2d.IFigure)43 List (java.util.List)24 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)18 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)17 PointList (org.eclipse.draw2d.geometry.PointList)16 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)15 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)14 ArrayList (java.util.ArrayList)11 Iterator (java.util.Iterator)11 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)11 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)10 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)10 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)8 Viewport (org.eclipse.draw2d.Viewport)8 Node (org.talend.designer.core.ui.editor.nodes.Node)8 Image (org.eclipse.swt.graphics.Image)7