use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class DummyNodeAnchor method getDirectionPosition.
private Point getDirectionPosition(Point figCenter, Point reference) {
Dimension nodeSize = this.source.getSize();
EConnectionCategory category = null;
EConnectionType lineStyle = null;
if (connection != null) {
lineStyle = connection.getLineStyle();
category = lineStyle.getCategory();
} else {
lineStyle = ConnectionManager.getNewConnectionType();
category = lineStyle.getCategory();
}
Point result = new Point(figCenter);
if (category == EConnectionCategory.MAIN && lineStyle != EConnectionType.FLOW_REF) {
if (!isTargetAnchor) {
result.x = figCenter.x + nodeSize.width / 2;
} else {
result.x = figCenter.x - nodeSize.width / 2;
}
return result;
} else if (category == EConnectionCategory.OTHER && (lineStyle == EConnectionType.FLOW_REF || lineStyle == EConnectionType.TABLE_REF)) {
if (target != null) {
int sourceY = this.source.getPosY();
int targetY = this.target.getPosY();
Rectangle sourceBounds = new Rectangle(this.source.getLocation(), this.source.getSize());
Rectangle targetBounds = new Rectangle(this.target.getLocation(), this.target.getSize());
if (!isTargetAnchor) {
if (target.equals(source)) {
Point tempPoint = new Point(reference.x - nodeSize.width / 2, reference.y - nodeSize.height / 2);
targetBounds = new Rectangle(tempPoint, this.target.getSize());
targetY = reference.y - nodeSize.height / 2;
}
if (sourceY <= targetY) {
if ((targetBounds.getTopRight().y == sourceBounds.getBottomLeft().y)) {
result.y = figCenter.y - nodeSize.height / 2;
} else {
result.y = figCenter.y + nodeSize.height / 2;
}
} else {
if (targetBounds.getBottomLeft().y == sourceBounds.getTopRight().y) {
result.y = figCenter.y + nodeSize.height / 2;
} else {
result.y = figCenter.y - nodeSize.height / 2;
}
}
return result;
}
//
if (sourceY < targetY) {
result.y = figCenter.y - nodeSize.height / 2;
} else {
result.y = figCenter.y + nodeSize.height / 2;
}
return result;
}
}
return null;
}
use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class LabelCenter method getFinalDisplayText.
public String getFinalDisplayText() {
Dimension textSize = calculateTextSize(getText());
Rectangle area = getClientArea();
Insets i = getInsets();
if (textSize.width >= area.width - i.left - i.right - OFFSET * 2) {
return ELLIPSIS;
}
return text;
}
use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class NodeContainer method prepareStatus.
private Rectangle prepareStatus(Point nodeLocation, Dimension nodeSize) {
Rectangle statusRectangle = null;
Rectangle breakpointRectangle, warningRectangle, infoRectangle, parallelLocationRectangle, windowLocationRectangle, validationRuleRectangle, collapseRectangle;
int status = node.getStatus();
if ((status & Process.BREAKPOINT_STATUS) != 0) {
breakpointLocation.x = nodeLocation.x - breakpointSize.width;
breakpointLocation.y = nodeLocation.y - breakpointSize.height;
breakpointRectangle = new Rectangle(breakpointLocation, breakpointSize);
statusRectangle = breakpointRectangle;
}
if ((status & Process.ERROR_STATUS) != 0) {
errorLocation.x = nodeLocation.x + nodeSize.width;
errorLocation.y = nodeLocation.y - errorSize.height;
errorRectangle = new Rectangle(errorLocation, errorSize);
if (statusRectangle == null) {
statusRectangle = errorRectangle;
} else {
statusRectangle.union(errorRectangle);
}
}
if ((status & Process.WARNING_STATUS) != 0) {
warningLocation.x = nodeLocation.x + nodeSize.width;
warningLocation.y = nodeLocation.y - warningSize.height;
warningRectangle = new Rectangle(warningLocation, warningSize);
if (statusRectangle == null) {
statusRectangle = warningRectangle;
} else {
statusRectangle.union(warningRectangle);
}
}
if (this instanceof AbstractJobletContainer) {
Dimension collapseSize = new Dimension(20, 20);
collapseLocation.x = nodeLocation.x - 20;
collapseLocation.y = nodeLocation.y - collapseSize.height;
collapseRectangle = new Rectangle(collapseLocation, collapseSize);
if (statusRectangle == null) {
Point extendPoint = new Point();
extendPoint.x = nodeLocation.x + nodeSize.width;
extendPoint.y = nodeLocation.y - warningSize.height;
Rectangle extendRectangle = new Rectangle(extendPoint, warningSize);
statusRectangle = extendRectangle;
}
statusRectangle.union(collapseRectangle);
}
if ((status & Process.INFO_STATUS) != 0) {
infoLocation.x = nodeLocation.x + nodeSize.width;
infoLocation.y = nodeLocation.y - infoSize.height;
infoRectangle = new Rectangle(infoLocation, infoSize);
if (statusRectangle == null) {
statusRectangle = infoRectangle;
} else {
statusRectangle.union(infoRectangle);
}
}
if ((status & Process.VALIDATION_RULE_STATUS) != 0) {
validationRuleLocation.x = nodeLocation.x + nodeSize.width / 2 + nodeSize.width / 4;
validationRuleLocation.y = nodeLocation.y - validationRuleSize.height / 2;
validationRuleRectangle = new Rectangle(validationRuleLocation, validationRuleSize);
if (statusRectangle == null) {
statusRectangle = validationRuleRectangle;
} else {
statusRectangle.union(validationRuleRectangle);
}
}
if (node.isErrorFlag()) {
markLocation.x = nodeLocation.x - nodeSize.width / 2;
markLocation.y = nodeLocation.y;
errorMarkLocation.x = nodeLocation.x - (errorMarkSize.width - nodeSize.width) / 2;
errorMarkLocation.y = markLocation.y - errorMarkSize.height;
errorMarkRectangle = new Rectangle(errorMarkLocation, errorMarkSize);
if (statusRectangle == null) {
statusRectangle = errorMarkRectangle;
} else {
statusRectangle.union(errorMarkRectangle);
}
}
boolean parallelize = false;
IElementParameter enableParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE.getName());
if (enableParallelizeParameter != null) {
parallelize = (Boolean) enableParallelizeParameter.getValue();
}
if (parallelize) {
parallelLocation.x = nodeLocation.x - parallelSize.width;
parallelLocation.y = nodeLocation.y - parallelSize.height;
parallelLocationRectangle = new Rectangle(parallelLocation, parallelSize);
if (statusRectangle == null) {
statusRectangle = parallelLocationRectangle;
} else {
statusRectangle.union(parallelLocationRectangle);
}
}
IElementParameter window = node.getElementParameter(EParameterName.WINDOW_DURATION.getName());
String windowDuration = null;
if (window != null) {
windowDuration = (String) window.getValue();
}
if (windowDuration != null) {
windowLocation.x = nodeLocation.x - ((nodeLocation.x + (windowSize.width / 2)) - (nodeLocation.x + (nodeSize.width / 2)));
windowLocation.y = nodeLocation.y - windowSize.height;
windowLocationRectangle = new Rectangle(windowLocation, windowSize);
if (statusRectangle == null) {
statusRectangle = windowLocationRectangle;
} else {
statusRectangle.union(windowLocationRectangle);
}
}
return statusRectangle;
}
use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class NodeContainer method getNodeContainerRectangle.
public Rectangle getNodeContainerRectangle() {
Point nodeLocation;
nodeLocation = node.getLocation();
Dimension nodeSize;
Dimension labelSize;
Dimension errorNodeSize;
nodeSize = node.getSize();
Rectangle nodeRectangle = new Rectangle(nodeLocation, nodeSize);
Rectangle statusRectangle = prepareStatus(nodeLocation, nodeSize);
Point labelLocation = nodeLabel.getLocation().getCopy();
Point offset = nodeLabel.getOffset();
Point textOffset = new Point();
labelSize = nodeLabel.getLabelSize();
textOffset.y = nodeSize.height;
textOffset.x = (nodeSize.width - labelSize.width) / 2;
nodeLabel.setTextOffset(textOffset);
labelLocation.translate(offset);
labelLocation.translate(textOffset);
Rectangle labelRectangle = new Rectangle(labelLocation, labelSize);
errorNodeSize = nodeError.getErrorSize();
Point progressLocation = nodeProgressBar.getLocation().getCopy();
Rectangle progressNodeRectangle = new Rectangle(progressLocation, new Dimension(80, 80));
Rectangle finalRect;
finalRect = nodeRectangle.getUnion(labelRectangle).getUnion(statusRectangle);
if (node.isErrorFlag()) {
finalRect.height += errorNodeSize.height;
finalRect.height += errorMarkSize.height;
}
if (node.isFileScaleComponent()) {
// finalRect.height += progressNodeSize.height;//
finalRect = finalRect.getUnion(progressNodeRectangle);
}
return finalRect;
}
use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class NodeContainer method prepareCleanStatus.
private Rectangle prepareCleanStatus(Point nodeLocation, Dimension nodeSize) {
Rectangle statusRectangle = null;
Rectangle breakpointRectangle, warningRectangle, infoRectangle, validationRuleRectangle, collapseRectangle;
int status = node.getStatus();
if ((status & Process.BREAKPOINT_STATUS) != 0) {
breakpointLocation.x = nodeLocation.x - breakpointSize.width;
breakpointLocation.y = nodeLocation.y - breakpointSize.height;
breakpointRectangle = new Rectangle(breakpointLocation, breakpointSize);
statusRectangle = breakpointRectangle;
}
if ((status & Process.ERROR_STATUS) != 0) {
errorLocation.x = nodeLocation.x + nodeSize.width;
errorLocation.y = nodeLocation.y - errorSize.height;
errorRectangle = new Rectangle(errorLocation, errorSize);
if (statusRectangle == null) {
statusRectangle = errorRectangle;
} else {
statusRectangle.union(errorRectangle);
}
}
if ((status & Process.WARNING_STATUS) != 0) {
warningLocation.x = nodeLocation.x + nodeSize.width;
warningLocation.y = nodeLocation.y - warningSize.height;
warningRectangle = new Rectangle(warningLocation, warningSize);
if (statusRectangle == null) {
statusRectangle = warningRectangle;
} else {
statusRectangle.union(warningRectangle);
}
}
if (this instanceof AbstractJobletContainer) {
Dimension collapseSize = new Dimension(20, 20);
collapseLocation.x = nodeLocation.x - 20;
collapseLocation.y = nodeLocation.y - collapseSize.height;
collapseRectangle = new Rectangle(collapseLocation, collapseSize);
if (statusRectangle == null) {
Point extendPoint = new Point();
extendPoint.x = nodeLocation.x + nodeSize.width;
extendPoint.y = nodeLocation.y - warningSize.height;
Rectangle extendRectangle = new Rectangle(extendPoint, warningSize);
statusRectangle = extendRectangle;
}
statusRectangle.union(collapseRectangle);
}
if ((status & Process.INFO_STATUS) != 0) {
infoLocation.x = nodeLocation.x + nodeSize.width;
infoLocation.y = nodeLocation.y - infoSize.height;
infoRectangle = new Rectangle(infoLocation, infoSize);
if (statusRectangle == null) {
statusRectangle = infoRectangle;
} else {
statusRectangle.union(infoRectangle);
}
}
if ((status & Process.VALIDATION_RULE_STATUS) != 0) {
validationRuleLocation.x = nodeLocation.x + nodeSize.width / 2 + nodeSize.width / 4;
validationRuleLocation.y = nodeLocation.y - validationRuleSize.height / 2;
validationRuleRectangle = new Rectangle(validationRuleLocation, validationRuleSize);
if (statusRectangle == null) {
statusRectangle = validationRuleRectangle;
} else {
statusRectangle.union(validationRuleRectangle);
}
}
if (node.isErrorFlag()) {
markLocation.x = nodeLocation.x - nodeSize.width / 2;
markLocation.y = nodeLocation.y;
errorMarkLocation.x = nodeLocation.x - (errorMarkSize.width - nodeSize.width) / 2;
errorMarkLocation.y = markLocation.y - errorMarkSize.height;
errorMarkRectangle = new Rectangle(errorMarkLocation, errorMarkSize);
if (statusRectangle == null) {
statusRectangle = errorMarkRectangle;
} else {
statusRectangle.union(errorMarkRectangle);
}
}
return statusRectangle;
}
Aggregations