Search in sources :

Example 56 with Rectangle

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

the class SubjobContainer method refreshNodesLocation.

public void refreshNodesLocation(boolean jobletCollapsed, AbstractJobletContainer nc, int rightChangewidth, int downChangeheight, int leftChangewidth, int upChangeheight) {
    JobletUtil util = new JobletUtil();
    Node node = nc.getNode();
    Rectangle jobletRec = new Rectangle(node.getLocation(), node.getSize());
    boolean isJobletSubjob = nc.getSubjobContainer() == this;
    for (NodeContainer container : nodeContainers) {
        if (container.getNode().getUniqueName().equals(nc.getNode().getUniqueName())) {
            continue;
        }
        Point nodePoint = container.getNode().getLocation().getCopy();
        Rectangle jRec = util.getExpandRectangle(jobletRec);
        // Rectangle jNodeConRec = util.getExpandRectangle(nodeConRec);
        // Rectangle pointrec = util.getExpandRectangle(container.getNodeContainerRectangle());
        jRec.width = jRec.width + rightChangewidth + leftChangewidth;
        jRec.height = jRec.height + downChangeheight + upChangeheight;
        // jNodeConRec.height = jNodeConRec.height + changeheight;
        if (!jobletCollapsed) {
            if (!nc.isUpdate()) {
                Point origPoint = new Point(nodePoint.x, nodePoint.y);
                pointMap.put(container.getNode().getUniqueName(), origPoint);
                if (isJobletSubjob) {
                    if (nodePoint.x > jobletRec.x) {
                        nodePoint.x = nodePoint.x + rightChangewidth;
                    }
                    if (nodePoint.y > jobletRec.y) {
                        nodePoint.y = nodePoint.y + downChangeheight;
                    }
                    if (nodePoint.x < jobletRec.x) {
                        nodePoint.x = nodePoint.x - leftChangewidth;
                    }
                    if (nodePoint.y < jobletRec.y) {
                        nodePoint.y = nodePoint.y - upChangeheight;
                    }
                } else {
                    Rectangle jobletSubRec = nc.getSubjobContainer().getSubjobContainerRectangle();
                    Rectangle currentRec = this.getSubjobContainerRectangle();
                    if (nodePoint.x > jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
                        nodePoint.x = nodePoint.x + rightChangewidth;
                    }
                    if (nodePoint.y > jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
                        nodePoint.y = nodePoint.y + downChangeheight;
                    }
                    if (nodePoint.x < jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
                        nodePoint.x = nodePoint.x - leftChangewidth;
                    }
                    if (nodePoint.y < jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
                        nodePoint.y = nodePoint.y - upChangeheight;
                    }
                }
            }
        } else {
            nodePoint = pointMap.get(container.getNode().getUniqueName());
        // if (nodePoint.x > nodeRec.x && nodePoint.x > rightChangewidth) {
        // nodePoint.x = nodePoint.x - rightChangewidth;
        // }
        // if (nodePoint.x < nodeRec.x) {
        // nodePoint.x = nodePoint.x + leftChangewidth;
        // }
        // if (nodePoint.y > nodeRec.y && nodePoint.y > downChangeheight) {
        // if ((nodePoint.y - downChangeheight) > (nodeRec.y + 64)) {
        // nodePoint.y = nodePoint.y - downChangeheight;
        // } else {
        // nodePoint.y = nodeRec.y + 64;
        // }
        //
        // }
        }
        container.getNode().setLocation(nodePoint);
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) JobletUtil(org.talend.designer.core.ui.editor.jobletcontainer.JobletUtil)

Example 57 with Rectangle

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

the class SubjobContainerPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
public void refreshVisuals() {
    Boolean isDisplaySubjobs = ((SubjobContainer) this.getModel()).isDisplayed();
    if (getParent() == null || !isDisplaySubjobs) {
        return;
    }
    Rectangle rectangle = ((SubjobContainer) this.getModel()).getSubjobContainerRectangle();
    if (rectangle == null) {
        return;
    }
    ((SubjobContainerFigure) getFigure()).initializeSubjobContainer(rectangle);
    // added for bug 4005
    if (getFigure().getParent() != null) {
        ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
    }
}
Also used : SparkStreamingSubjobContainerFigure(org.talend.designer.core.ui.editor.subjobcontainer.sparkstreaming.SparkStreamingSubjobContainerFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 58 with Rectangle

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

the class SubjobContainerResizableEditPolicy method createFigure.

protected IFigure createFigure(GraphicalEditPart part, IFigure parent) {
    IFigure child = getCustomFeedbackFigure(part.getModel());
    if (parent != null) {
        parent.add(child);
    }
    Rectangle childBounds = part.getFigure().getBounds().getCopy();
    IFigure walker = part.getFigure().getParent();
    while (walker != ((GraphicalEditPart) part.getParent()).getFigure()) {
        walker.translateToParent(childBounds);
        walker = walker.getParent();
    }
    child.setBounds(childBounds);
    Iterator i = part.getChildren().iterator();
    while (i.hasNext()) {
        createFigure((GraphicalEditPart) i.next(), child);
    }
    return child;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Iterator(java.util.Iterator) IFigure(org.eclipse.draw2d.IFigure)

Example 59 with Rectangle

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

the class SubjobContainerLayoutEditPolicy method getCreateCommand.

// ------------------------------------------------------------------------
// Abstract methods from LayoutEditPolicy
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
     */
protected Command getCreateCommand(final CreateRequest request) {
    if (((SubjobContainer) getHost().getModel()).isReadOnly()) {
        return null;
    }
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    Process linkedProcess = (Process) ((SubjobContainer) getHost().getModel()).getProcess();
    Command command = null;
    if (Note.class.equals(request.getNewObjectType())) {
        command = new CreateNoteCommand(linkedProcess, (Note) request.getNewObject(), constraint.getLocation());
    } else if (request.getNewObject() instanceof Node) {
        Node node = (Node) request.getNewObject();
        NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
        command = new CreateNodeContainerCommand(linkedProcess, nodeContainer, constraint.getLocation());
    }
    return command;
}
Also used : CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) MoveNodeLabelCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand) MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) MoveNoteCommand(org.talend.designer.core.ui.editor.cmd.MoveNoteCommand) Command(org.eclipse.gef.commands.Command) Note(org.talend.designer.core.ui.editor.notes.Note) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Process(org.talend.designer.core.ui.editor.process.Process) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 60 with Rectangle

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

the class JobletUtil method getExpandRectangle.

public Rectangle getExpandRectangle(Rectangle nodeRec) {
    Point location = nodeRec.getLocation();
    Dimension size = nodeRec.getSize();
    int width = location.x + size.width;
    int height = location.y + size.height;
    Rectangle rec = new Rectangle(0, 0, width, height);
    return rec;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) 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