Search in sources :

Example 51 with Rectangle

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

the class ConnectionFigure method containsPoint.

@Override
public boolean containsPoint(int x, int y) {
    Rectangle tempBounds = new Rectangle();
    int tolerance = (int) Math.max(getLineWidthFloat() / 2.0f, 3 + getLineWidth() / 2);
    tempBounds.setBounds(getBounds());
    tempBounds.expand(tolerance, tolerance);
    if (!tempBounds.contains(x, y))
        return false;
    return shapeContainsPoint(x, y) || childrenContainsPoint(x, y);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 52 with Rectangle

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

the class NodesPasteCommand method findLocationForNodeInProcess.

@SuppressWarnings("unchecked")
private Point findLocationForNodeInProcess(final Point location, Dimension size, NodePart copiedNodePart) {
    Rectangle copiedRect = new Rectangle(location, size);
    Point newLocation = new Point(location);
    for (IGraphicalNode node : (List<IGraphicalNode>) process.getGraphicalNodes()) {
        Rectangle currentRect = new Rectangle(node.getLocation(), node.getSize());
        if (currentRect.intersects(copiedRect)) {
            newLocation.x += size.width;
            newLocation.y += size.height;
            return findLocationForNodeInProcess(newLocation, size, copiedNodePart);
        }
    }
    return newLocation;
}
Also used : IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point)

Example 53 with Rectangle

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

the class NodesMoveCommond method findLocationForNodeInProcess.

@SuppressWarnings("unchecked")
private Point findLocationForNodeInProcess(final Point location, Dimension size) {
    Rectangle copiedRect = new Rectangle(location, size);
    Point newLocation = new Point(location);
    for (IGraphicalNode node : (List<IGraphicalNode>) process.getGraphicalNodes()) {
        Rectangle currentRect = new Rectangle((Point) node.getLocation(), (Dimension) node.getSize());
        if (currentRect.intersects(copiedRect)) {
            newLocation.x += size.width;
            newLocation.y += size.height;
            return findLocationForNodeInProcess(newLocation, size);
        }
    }
    return newLocation;
}
Also used : IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point)

Example 54 with Rectangle

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

the class NodesPasteCommand method findLocationForNodeInContainerList.

private Point findLocationForNodeInContainerList(final Point location, Dimension size, int index, int firstIndex, NodePart copiedNodePart) {
    Rectangle copiedRect = new Rectangle(location, size);
    Point newLocation = new Point(location);
    if (getCursorLocation() == null) {
        for (NodeContainer nodeContainer : nodeContainerList) {
            IGraphicalNode node = nodeContainer.getNode();
            Rectangle currentRect = new Rectangle(node.getLocation(), node.getSize());
            if (currentRect.intersects(copiedRect)) {
                newLocation.x += size.width;
                newLocation.y += size.height;
                // newLocation = computeTheDistance(index, firstIndex, newLocation);
                Point tmpPoint = findLocationForNodeInProcess(newLocation, size, copiedNodePart);
                return findLocationForNodeInContainerList(tmpPoint, size, index, firstIndex, copiedNodePart);
            }
        }
        return newLocation;
    }
    if (!nodePart.equals(copiedNodePart)) {
        newLocation = computeTheDistance(index, firstIndex, newLocation);
    }
    return newLocation;
}
Also used : IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point)

Example 55 with Rectangle

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

the class NodesMoveCommond method findLocationForNodeInContainerList.

private Point findLocationForNodeInContainerList(final Point location, Dimension size, int index, int firstIndex, Node copiedNode) {
    Rectangle copiedRect = new Rectangle(location, size);
    Point newLocation = new Point(location);
    if (getCursorLocation() == null) {
        for (NodeContainer nodeContainer : nodeContainerList) {
            IGraphicalNode node = nodeContainer.getNode();
            Rectangle currentRect = new Rectangle((Point) node.getLocation(), (Dimension) node.getSize());
            if (currentRect.intersects(copiedRect)) {
                newLocation.x += size.width;
                newLocation.y += size.height;
                // newLocation = computeTheDistance(index, firstIndex, newLocation);
                Point tmpPoint = findLocationForNodeInProcess(newLocation, size);
                return findLocationForNodeInContainerList(tmpPoint, size, index, firstIndex, copiedNode);
            }
        }
        return newLocation;
    }
    if (!node.equals(copiedNode)) {
        newLocation = computeTheDistance(index, firstIndex, newLocation);
    }
    return newLocation;
}
Also used : IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point)

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