Search in sources :

Example 6 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class TerminalBusinessItemShapeFigure method drawFigure.

private void drawFigure(Rectangle r, Graphics graphics) {
    Dimension corner = new Dimension((int) (r.width * 0.15), (int) (r.height * 0.15));
    graphics.fillRoundRectangle(r, corner.width, corner.height);
    graphics.drawRoundRectangle(r, corner.width, corner.height);
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 7 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class AbstractTalendEditor method configureGraphicalViewer.

@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    /** * Manage the view in the Outline ** */
    ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
    viewer.setSelectionManager(new TalendSelectionManager());
    TalendScalableFreeformRootEditPart root = new TalendScalableFreeformRootEditPart(getEditorInput());
    List<String> zoomLevels = new ArrayList<String>();
    zoomLevels.add(ZoomManager.FIT_ALL);
    zoomLevels.add(ZoomManager.FIT_WIDTH);
    zoomLevels.add(ZoomManager.FIT_HEIGHT);
    root.getZoomManager().setZoomLevelContributions(zoomLevels);
    // root.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
    IAction zoomIn = new ZoomInAction(root.getZoomManager());
    IAction zoomOut = new ZoomOutAction(root.getZoomManager());
    getActionRegistry().registerAction(zoomIn);
    getActionRegistry().registerAction(zoomOut);
    IHandlerService service = (IHandlerService) getEditorSite().getService(IHandlerService.class);
    service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
    service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));
    IAction directEditAction = new DirectEditAction(this);
    getActionRegistry().registerAction(directEditAction);
    getSelectionActions().add(directEditAction.getId());
    IAction copyAction = new GEFCopyAction(this);
    getActionRegistry().registerAction(copyAction);
    getSelectionActions().add(copyAction.getId());
    // setAction(copyAction.getId(), copyAction);
    IAction pasteAction = new GEFPasteAction(this);
    getActionRegistry().registerAction(pasteAction);
    getSelectionActions().add(pasteAction.getId());
    // setAction(pasteAction.getId(), pasteAction);
    IAction deleteAction = new GEFDeleteAction(this);
    getActionRegistry().registerAction(deleteAction);
    getSelectionActions().add(deleteAction.getId());
    // setAction(deleteAction.getId(), deleteAction);
    IAction undoAction = new GEFUndoAction(this);
    getActionRegistry().registerAction(undoAction);
    getSelectionActions().add(undoAction.getId());
    IAction redoAction = new GEFRedoAction(this);
    getActionRegistry().registerAction(redoAction);
    getSelectionActions().add(redoAction.getId());
    IAction setRefAction = new ConnectionSetAsMainRef(this);
    getActionRegistry().registerAction(setRefAction);
    getSelectionActions().add(setRefAction.getId());
    IAction modifyMergeAction = new ModifyMergeOrderAction(this);
    getActionRegistry().registerAction(modifyMergeAction);
    getSelectionActions().add(modifyMergeAction.getId());
    IAction modifyOutputOrderAction = new ModifyOutputOrderAction(this);
    getActionRegistry().registerAction(modifyOutputOrderAction);
    getSelectionActions().add(modifyOutputOrderAction.getId());
    List<IAction> calcOrderActions = ModifyConnectionOrderAction.getOrderActions(this);
    for (IAction orderAction : calcOrderActions) {
        getActionRegistry().registerAction(orderAction);
        getSelectionActions().add(orderAction.getId());
    }
    viewer.setRootEditPart(root);
    PartFactory partFactory = new PartFactory();
    // set the factory to use for creating EditParts for elements in the model
    getGraphicalViewer().setEditPartFactory(partFactory);
    getGraphicalViewer().setKeyHandler(new NodePartKeyHander(getGraphicalViewer()).setParent(getCommonKeyHandler()));
    // GraphicalViewer graViewer = getGraphicalViewer();
    // graViewer.setKeyHandler(new GraphicalViewerKeyHandler(graViewer));
    initializeActivationCodeTrigger();
    /** * Management of the context menu ** */
    ContextMenuProvider cmProvider = new TalendEditorContextMenuProvider(this, viewer, getActionRegistry());
    viewer.setContextMenu(cmProvider);
    /** * Management of the Zoom ** */
    /*
         * ZoomManager manager = (ZoomManager) getGraphicalViewer().getProperty(ZoomManager.class.toString()); if
         * (manager != null) { manager.setZoom(getProcess().getZoom()); }
         */
    // Scroll-wheel Zoom
    getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    /** * Snap To Grid ** */
    // Grid properties
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(AbstractTalendEditor.GRID_SIZE, AbstractTalendEditor.GRID_SIZE));
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(true));
    // We keep grid visibility and enablement in sync
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(true));
    IAction showGrid = new ToggleGridAction(getGraphicalViewer());
    getActionRegistry().registerAction(showGrid);
    /** * Snap To Geometry ** */
    getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(false));
    IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
    getActionRegistry().registerAction(snapAction);
    configurationSubJob(viewer);
}
Also used : ModifyMergeOrderAction(org.talend.designer.core.ui.action.ModifyMergeOrderAction) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) GEFCopyAction(org.talend.designer.core.ui.action.GEFCopyAction) GEFPasteAction(org.talend.designer.core.ui.action.GEFPasteAction) GEFDeleteAction(org.talend.designer.core.ui.action.GEFDeleteAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ProcessTreePartFactory(org.talend.designer.core.ui.editor.outline.ProcessTreePartFactory) ArrayList(java.util.ArrayList) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) NodePartKeyHander(org.talend.designer.core.ui.NodePartKeyHander) ModifyOutputOrderAction(org.talend.designer.core.ui.action.ModifyOutputOrderAction) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) IAction(org.eclipse.jface.action.IAction) ConnectionSetAsMainRef(org.talend.designer.core.ui.action.ConnectionSetAsMainRef) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) GEFUndoAction(org.talend.designer.core.ui.action.GEFUndoAction) Dimension(org.eclipse.draw2d.geometry.Dimension) IHandlerService(org.eclipse.ui.handlers.IHandlerService) GEFRedoAction(org.talend.designer.core.ui.action.GEFRedoAction) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 8 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class JobletUtil method getExpandRectangle.

public Rectangle getExpandRectangle(Rectangle nodeRec) {
    Point location = nodeRec.getLocation();
    Dimension size = nodeRec.getSize();
    int width = location.x + size.width;
    int height = location.y + size.height;
    Rectangle rec = new Rectangle(0, 0, width, height);
    return rec;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 9 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class NodeLabelEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    Node node = ((NodeLabel) getModel()).getNode();
    // Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
    String text = ((NodeLabel) getModel()).getLabelText();
    SimpleHtmlFigure htmlFig = (SimpleHtmlFigure) this.getFigure();
    htmlFig.setText(text);
    Point loc = node.getLocation().getCopy();
    Point offset = ((NodeLabel) getModel()).getOffset();
    Point textOffset = new Point();
    Dimension size = htmlFig.getPreferredSize();
    textOffset.y = node.getSize().height;
    textOffset.x = (node.getSize().width - size.width) / 2;
    ((NodeLabel) getModel()).setTextOffset(textOffset);
    loc.translate(textOffset.x + offset.x, textOffset.y + offset.y);
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 10 with Dimension

use of org.eclipse.draw2d.geometry.Dimension in project tdi-studio-se by Talend.

the class NodeAnchor method getDirectionPosition.

private Point getDirectionPosition(IConnection connection, Point figCenter, boolean isSource) {
    if (!DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.EDITOR_LINESTYLE)) {
        return null;
    }
    Dimension nodeSize = null;
    if (isSource) {
        nodeSize = this.source.getSize();
    } else {
        nodeSize = this.target.getSize();
    }
    EConnectionCategory category = null;
    EConnectionType lineStyle = null;
    if (connection != null) {
        lineStyle = connection.getLineStyle();
        category = lineStyle.getCategory();
    } else {
        lineStyle = ConnectionManager.getNewConnectionType();
        category = lineStyle.getCategory();
    }
    Point result = new Point(figCenter);
    if (category == EConnectionCategory.MAIN && lineStyle != EConnectionType.FLOW_REF) {
        if (isSource) {
            result.x = figCenter.x + nodeSize.width / 2;
        } else {
            result.x = figCenter.x - nodeSize.width / 2;
        }
        return result;
    } else if (category == EConnectionCategory.OTHER && (lineStyle == EConnectionType.FLOW_REF || lineStyle == EConnectionType.TABLE_REF)) {
        Rectangle sourceBounds = new Rectangle(this.source.getLocation(), this.source.getSize());
        Rectangle targetBounds = new Rectangle(this.target.getLocation(), this.target.getSize());
        if (isSource) {
            int sourceY = this.source.getPosY();
            int targetY = this.target.getPosY();
            if (sourceY <= targetY) {
                if ((targetBounds.getTopRight().y == sourceBounds.getBottomLeft().y)) {
                    result.y = figCenter.y - nodeSize.height / 2;
                } else {
                    result.y = figCenter.y + nodeSize.height / 2;
                }
            } else {
                if (targetBounds.getBottomLeft().y == sourceBounds.getTopRight().y) {
                    result.y = figCenter.y + nodeSize.height / 2;
                } else {
                    result.y = figCenter.y - nodeSize.height / 2;
                }
            }
            return result;
        }
        int sourceY = this.source.getPosY();
        int targetY = this.target.getPosY();
        if (sourceY < targetY) {
            result.y = figCenter.y - nodeSize.height / 2;
        } else {
            result.y = figCenter.y + nodeSize.height / 2;
        }
        return result;
    }
    return null;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) EConnectionCategory(org.talend.core.model.process.EConnectionCategory) Dimension(org.eclipse.draw2d.geometry.Dimension) KeyPoint(org.talend.commons.ui.gmf.draw2d.LineSeg.KeyPoint) Point(org.eclipse.draw2d.geometry.Point) EConnectionType(org.talend.core.model.process.EConnectionType)

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