Search in sources :

Example 31 with Dimension

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

Example 32 with Dimension

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);
}
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 33 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 34 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 35 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)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)180 Rectangle (org.eclipse.draw2d.geometry.Rectangle)80 Point (org.eclipse.draw2d.geometry.Point)70 IFigure (org.eclipse.draw2d.IFigure)31 List (java.util.List)16 Insets (org.eclipse.draw2d.geometry.Insets)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)8 PointList (org.eclipse.draw2d.geometry.PointList)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)6 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)5 ArrayList (java.util.ArrayList)4 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 Font (org.eclipse.swt.graphics.Font)4 Point (org.eclipse.swt.graphics.Point)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)3 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)3 Label (org.eclipse.draw2d.Label)3 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3