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);
}
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations