use of org.eclipse.draw2d.geometry.Dimension 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.Dimension 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.Dimension in project tdi-studio-se by Talend.
the class NodeResizableEditPolicy method getResizeCommand.
@Override
protected Command getResizeCommand(ChangeBoundsRequest request) {
Object parent = getHost().getParent().getModel();
if (!(parent instanceof NodeContainer)) {
return null;
}
Node node = (Node) getHost().getModel();
if (node.isReadOnly()) {
return null;
}
TalendScalableFreeformRootEditPart rootEditPart = (TalendScalableFreeformRootEditPart) getHost().getRoot();
double scale = 1 / rootEditPart.getZoomManager().getZoom();
return new ResizeNodeCommand(node, new Dimension(node.getSize().width + request.getSizeDelta().getScaled(scale).width, node.getSize().height + request.getSizeDelta().getScaled(scale).height));
}
use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class Note method autoAdjustFigureSize.
/**
* It is used for auto-adjust the size of fingure to adapt the text modification.
*
* @param text
*/
private void autoAdjustFigureSize(String text) {
int length = text.length() - this.text.length();
int adjustLength = TalendEditor.GRID_SIZE / 4;
if (length < 0) {
adjustLength = -TalendEditor.GRID_SIZE / 4;
}
if (length != 0 && text.length() != 0) {
this.size.width = this.size.width + length * 3 + adjustLength;
} else {
this.size = new Dimension(TalendEditor.GRID_SIZE * 3, TalendEditor.GRID_SIZE * 2);
}
}
use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.
the class SearchZoneToolBarLayout method layout.
@Override
public void layout(IFigure parent) {
List children = parent.getChildren();
int numChildren = children.size();
Rectangle clientArea = parent.getClientArea();
int x = clientArea.x + spacing;
int y = clientArea.y;
Dimension[] prefSizes = new Dimension[numChildren];
Dimension[] minSizes = new Dimension[numChildren];
int wHint = -1;
int hHint = -1;
if (isHorizontal()) {
hHint = parent.getClientArea(Rectangle.SINGLETON).height;
} else {
wHint = parent.getClientArea(Rectangle.SINGLETON).width;
}
IFigure child;
int totalHeight = 0;
int totalMinHeight = 0;
int maxHeight = 0;
for (int i = 0; i < numChildren; i++) {
child = (IFigure) children.get(i);
prefSizes[i] = getChildPreferredSize(child, wHint, hHint);
minSizes[i] = getChildMinimumSize(child, wHint, hHint);
totalHeight += prefSizes[i].height;
totalMinHeight += minSizes[i].height;
maxHeight = Math.max(maxHeight, prefSizes[i].height);
}
totalHeight += (numChildren - 1) * spacing;
totalMinHeight += (numChildren - 1) * spacing;
y = y + (clientArea.height - maxHeight) / 2;
for (int i = 0; i < numChildren; i++) {
int prefHeight = prefSizes[i].height;
int minHeight = minSizes[i].height;
int prefWidth = prefSizes[i].width;
if (i == 1) {
prefWidth = 200;
}
Rectangle newBounds = new Rectangle(x, y, prefWidth, prefHeight);
child = (IFigure) children.get(i);
child.setBounds(newBounds);
x = x + newBounds.width + spacing;
}
}
Aggregations