use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class NodeAnchor method getLocationForMultipleConnections.
public Point getLocationForMultipleConnections(int connectionId) {
if ((sourceLocation.y >= targetLocation.y) && ((sourceLocation.y + sourceRect.height) <= (targetLocation.y + targetRect.height))) {
targetRect = new Rectangle(new Point(targetLocation.x, sourceLocation.y), new Dimension(targetRect.width, sourceRect.height));
} else if ((sourceLocation.x >= targetLocation.x) && ((sourceLocation.x + sourceRect.width) <= (targetLocation.x + targetRect.width))) {
targetRect = new Rectangle(new Point(sourceLocation.x, targetLocation.y), new Dimension(sourceRect.width, sourceRect.height));
}
// will calculate the numerator and denominator for the function to place the points.
// example: 1/2; 3/4; 1/4; 5/8; 3/8; 7/8; 1/8; 9/16; 7/16; 11/16; 5/16; 13/16; 3/16...
int num = 1;
int numPair = 1;
int numImpair = 1;
int denom = 2;
for (int i = 1; i < connectionId + 1; i++) {
if ((i % 2) == 0) {
// pair
if ((numPair + 2) > denom) {
denom = denom * 2;
numPair = (denom / 2) + 1;
numImpair = numPair;
} else {
numPair += 2;
}
num = numPair;
} else {
// impair
numImpair -= 2;
if (numImpair > 0) {
num = numImpair;
}
}
}
LineSeg lineSource, lineTarget;
if ((sourceLocation.x < targetRect.getCenter().x) && (targetRect.getCenter().x < (sourceLocation.x + sourceRect.width))) {
lineSource = new LineSeg(sourceRect.getLeft(), sourceRect.getRight());
lineTarget = new LineSeg(targetRect.getLeft(), targetRect.getRight());
} else {
lineSource = new LineSeg(sourceRect.getTop(), sourceRect.getBottom());
lineTarget = new LineSeg(targetRect.getTop(), targetRect.getBottom());
}
Double length = (lineSource.length() * num / denom);
Point pointSource = new Point();
lineSource.pointOn(length.longValue(), KeyPoint.ORIGIN, pointSource);
length = (lineTarget.length() * num / denom);
Point pointTarget = new Point();
lineTarget.pointOn(length.longValue(), KeyPoint.ORIGIN, pointTarget);
if ((sourceLocation.y < pointTarget.y) && (pointTarget.y < (sourceLocation.y + sourceRect.height))) {
// contains
pointSource.y = pointTarget.y;
}
if ((sourceLocation.x < pointTarget.x) && (pointTarget.x < (sourceLocation.x + sourceRect.width))) {
// contains
pointSource.x = pointTarget.x;
}
return calculateLocationFromRef(pointSource, pointTarget);
}
use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class NodeContainerFigure method initializeNodeContainer.
public void initializeNodeContainer(Rectangle rectangle) {
this.disposeColors();
rectFig.setLocation(new Point(rectangle.x, rectangle.y));
rectFig.setSize(new Dimension(rectangle.width, rectangle.height));
if (isShowCompareMark()) {
rectFig.setVisible(true);
rectFig.setForegroundColor(new Color(Display.getDefault(), new RGB(204, 153, 255)));
} else {
rectFig.setForegroundColor(new Color(Display.getDefault(), new RGB(255, 102, 102)));
}
markFigure.setSize(errorMarkImage.getImageData().width, errorMarkImage.getImageData().height);
}
use of org.eclipse.draw2d.geometry.Dimension 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.Dimension 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.Dimension 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);
}
Aggregations