Search in sources :

Example 16 with Dimension

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;
}
Also used : NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 17 with Dimension

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);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 18 with Dimension

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));
}
Also used : TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ResizeNodeCommand(org.talend.designer.core.ui.editor.cmd.ResizeNodeCommand) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 19 with Dimension

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);
    }
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 20 with Dimension

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;
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) List(java.util.List) Dimension(org.eclipse.draw2d.geometry.Dimension) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)105 Point (org.eclipse.draw2d.geometry.Point)46 Rectangle (org.eclipse.draw2d.geometry.Rectangle)43 IFigure (org.eclipse.draw2d.IFigure)20 List (java.util.List)15 Insets (org.eclipse.draw2d.geometry.Insets)8 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)6 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 ArrayList (java.util.ArrayList)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3 IElementParameter (org.talend.core.model.process.IElementParameter)3 AbstractJobletContainer (org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer)3 LinkedList (java.util.LinkedList)2 Figure (org.eclipse.draw2d.Figure)2 Label (org.eclipse.draw2d.Label)2 PolylineConnection (org.eclipse.draw2d.PolylineConnection)2 PointList (org.eclipse.draw2d.geometry.PointList)2 GraphicalViewerKeyHandler (org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)2 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)2