use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.
the class ReplaceMultiFlowBytReplicateMigrationTask method findLocationForNode.
/**
* DOC nrousseau Comment method "findLocationForNode".
*
* @param processType
* @param point
* @return
*/
private Point findLocationForNode(ProcessType processType, Point point) {
Rectangle newRect = new Rectangle(point, new Dimension(GRID_SIZE, GRID_SIZE));
Point newLocation = new Point(point);
for (Object oNodeType : processType.getNode()) {
NodeType node = (NodeType) oNodeType;
String uniqueName = ComponentUtilities.getNodeUniqueName(node);
Rectangle currentRect = getNodeRectangle(processType, uniqueName);
if (currentRect.intersects(newRect)) {
newLocation.x += GRID_SIZE;
newLocation.y += GRID_SIZE;
return findLocationForNode(processType, point);
}
}
return newLocation;
}
use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.
the class TalendGridLayer method paintGrid.
protected void paintGrid(Graphics g, IFigure f, org.eclipse.draw2d.geometry.Point origin, int distanceX, int distanceY) {
FreeformFigure ff = (FreeformFigure) this.getParent();
Rectangle clientArea = getClientArea();
Rectangle bounds = ff.getFreeformExtent().getCopy();
bounds.union(clientArea.x, clientArea.y, clientArea.width * AnimatableZoomManager.currentZoom, clientArea.height * AnimatableZoomManager.currentZoom);
ff.setFreeformBounds(bounds);
Rectangle original = g.getClip(Rectangle.SINGLETON);
Rectangle clip = new Rectangle(original.x - original.x % distanceX, original.y - original.y % distanceY, original.width + Math.abs(original.x % distanceX), original.height + Math.abs(original.y % distanceY));
if (distanceX > 0 && distanceY > 0) {
if (origin.x >= clip.x) {
while (origin.x - distanceX >= clip.x) {
origin.x -= distanceX;
}
} else {
while (origin.x < clip.x) {
origin.x += distanceX;
}
}
if (origin.y >= clip.y) {
while (origin.y - distanceY >= clip.y) {
origin.y -= distanceY;
}
} else {
while (origin.y < clip.y) {
origin.y += distanceY;
}
}
for (int i = origin.x; i < clip.x + clip.width; i += distanceX) {
for (int j = origin.y; j < clip.y + clip.height; j += distanceY) {
// g.drawPoint(i, j);
int re = Math.abs(i - j);
if (re / distanceY % 2 == 0) {
g.drawImage(ImageProvider.getImage(EImage.CHESS_GRAY), i, j);
}
}
}
}
}
use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.
the class NodePart method refreshVisuals.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
*/
@Override
@SuppressWarnings("unchecked")
protected void refreshVisuals() {
Node node = (Node) this.getModel();
Point loc = node.getLocation();
Rectangle rectangle = new Rectangle(loc, node.getSize());
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
use of org.eclipse.draw2d.geometry.Rectangle in project tdi-studio-se by Talend.
the class NodeProgressBarPart 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();
NodeProgressBarFigure progressFig = (NodeProgressBarFigure) this.getFigure();
Point loc = node.getLocation().getCopy();
NodeError nodeError = node.getNodeError();
Dimension size = progressFig.getSize();
loc.x = loc.x + (node.getSize().width - size.width) / 2 + size.width / 7;
loc.y = loc.y + node.getSize().height + nodeLabel.getLabelSize().height + nodeError.getErrorSize().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 NoteCellEditorLocator method relocate.
public void relocate(CellEditor celleditor) {
Text text = (Text) celleditor.getControl();
Rectangle rect = noteFigure.getClientArea();
noteFigure.translateToAbsolute(rect);
org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(BORDER, BORDER, -2 * BORDER, -2 * BORDER);
rect.translate(trim.x, trim.y);
rect.width += trim.width;
rect.height += trim.height;
text.setBounds(rect.x, rect.y, rect.width, rect.height);
}
Aggregations