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