Search in sources :

Example 1 with RoundedRectangle

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

the class JobletContainerFigure method paint.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics)
     */
@Override
public void paint(Graphics graphics) {
    graphics.setAlpha(255);
    if (errorFigure.isVisible()) {
        errorFigure.setLocation(jobletContainer.getErrorLocation());
    }
    if (warningFigure.isVisible()) {
        warningFigure.setLocation(jobletContainer.getWarningLocation());
    }
    if (infoFigure.isVisible()) {
        infoFigure.setLocation(jobletContainer.getInfoLocation());
    }
    if (markFigure.isVisible()) {
        markFigure.setLocation(jobletContainer.getErrorMarkLocation());
    }
    Iterator it = getChildren().iterator();
    if (!jobletContainer.getNode().isJoblet()) {
        while (it.hasNext()) {
            Figure fig = (Figure) it.next();
            if (mrFigures.isEmpty() && (fig instanceof GreenRectangle || fig instanceof RoundedRectangle)) {
                it.remove();
                continue;
            }
        }
    }
    if (this.jobletContainer.getNode().isJoblet()) {
        refreshForJoblet();
    }
    initializejobletContainer(getBounds());
    super.paint(graphics);
}
Also used : Iterator(java.util.Iterator) IFigure(org.eclipse.draw2d.IFigure) ImageFigure(org.eclipse.draw2d.ImageFigure) RectangleFigure(org.eclipse.draw2d.RectangleFigure) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure) Figure(org.eclipse.draw2d.Figure) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle)

Example 2 with RoundedRectangle

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

the class SubjobContainerFigure method initFigure.

/**
     * DOC rdubois Comment method "initFigure".
     */
protected void initFigure() {
    outlineFigure = new RoundedRectangle();
    rectFig = new RoundedRectangle();
    titleFigure = new SimpleHtmlFigure();
    titleFigure.setOpaque(true);
    collapseFigure = new SubjobCollapseFigure();
    collapseFigure.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            IProcess2 process = subjobContainer.getProcess();
            if (!process.isReadOnly()) {
                PropertyChangeCommand ppc = new PropertyChangeCommand(subjobContainer, EParameterName.COLLAPSED.getName(), !subjobContainer.isCollapsed());
                boolean executed = false;
                if (process instanceof IGEFProcess) {
                    IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
                    if (designerCoreUIService != null) {
                        executed = designerCoreUIService.executeCommand((IGEFProcess) process, ppc);
                    }
                }
                if (!executed) {
                    ppc.execute();
                }
                reSelection();
            }
        }
    });
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ActionListener(org.eclipse.draw2d.ActionListener) ActionEvent(org.eclipse.draw2d.ActionEvent) IProcess2(org.talend.core.model.process.IProcess2) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Example 3 with RoundedRectangle

use of org.eclipse.draw2d.RoundedRectangle in project archi by archimatetool.

the class RoundedRectangleAnchor method getLocation.

/**
 * Calculates the position with ChopboxAnchor#getLocation() and if the
 * anchor is not at the rounded corners, the result is returned. If the
 * anchor point should be at a corner, the rectangle for the ellipse is
 * determined and ellipseAnchorGetLocation returns the two intersection
 * points between the line from calculated anchor point and the center of
 * the rounded rectangle.
 *
 * @return The anchor location
 */
@Override
public Point getLocation(final Point ref) {
    Dimension corner = new Dimension(0, 0);
    if (getOwner() instanceof IRoundedRectangleFigure) {
        corner = ((IRoundedRectangleFigure) getOwner()).getArc();
    } else if (getOwner() instanceof RoundedRectangle) {
        corner = ((RoundedRectangle) getOwner()).getCornerDimensions();
    } else if (getOwner() instanceof AbstractDiagramModelObjectFigure) {
        IFigureDelegate figureDelegate = ((AbstractDiagramModelObjectFigure) getOwner()).getFigureDelegate();
        if (figureDelegate instanceof IRoundedRectangleFigure) {
            corner = ((IRoundedRectangleFigure) figureDelegate).getArc();
        }
    }
    corner = corner.scale(FigureUtils.getFigureScale(getOwner()));
    final Point location = super.getLocation(ref);
    final Rectangle r = Rectangle.SINGLETON;
    r.setBounds(getOwner().getBounds());
    r.translate(-1, -1);
    r.resize(1, 1);
    getOwner().translateToAbsolute(r);
    final int yTop = r.y + corner.height / 2;
    final int yBottom = r.y + r.height - corner.height / 2;
    final int xLeft = r.x + corner.width / 2;
    final int xRight = r.x + r.width - corner.width / 2;
    int pos = 0;
    if (location.x < xLeft) {
        pos = LEFT;
    } else if (location.x > xRight) {
        pos = RIGHT;
    } else {
        pos = MIDDLE;
    }
    if (location.y < yTop) {
        pos |= TOP;
    } else if (location.y > yBottom) {
        pos |= BOTTOM;
    } else {
        pos += CENTER;
    }
    switch(pos) {
        case TOP | MIDDLE:
        case CENTER | LEFT:
        case CENTER | RIGHT:
        case BOTTOM | MIDDLE:
            return new Point(location.x, location.y);
        case TOP | LEFT:
            return ellipseAnchorGetLocation(location, new Rectangle(r.x, r.y, corner.width, corner.height), // getOwner().getBounds().getCenter() // Jaiguru fix
            r.getCenter())[0];
        case TOP | RIGHT:
            return ellipseAnchorGetLocation(location, new Rectangle(r.x + r.width - corner.width, r.y, corner.width, corner.height), // getOwner().getBounds().getCenter() // Jaiguru fix
            r.getCenter())[1];
        case CENTER | MIDDLE:
            // default for reference inside Figure
            return new Point(r.x, r.y + r.height / 2);
        case BOTTOM | LEFT:
            return ellipseAnchorGetLocation(location, new Rectangle(r.x, r.y + r.height - corner.height, corner.width, corner.height), // getOwner().getBounds().getCenter() // Jaiguru fix
            r.getCenter())[0];
        case BOTTOM | RIGHT:
            return ellipseAnchorGetLocation(location, new Rectangle(r.x + r.width - corner.width, r.y + r.height - corner.height, corner.width, corner.height), // getOwner().getBounds().getCenter() // Jaiguru fix
            r.getCenter())[1];
        default:
            throw new IllegalStateException(// $NON-NLS-1$
            "Calculation of RoundedRectangleAnchor missed. Rect: " + r + " Point: " + // $NON-NLS-1$
            location);
    }
}
Also used : AbstractDiagramModelObjectFigure(com.archimatetool.editor.diagram.figures.AbstractDiagramModelObjectFigure) IFigureDelegate(com.archimatetool.editor.diagram.figures.IFigureDelegate) IRoundedRectangleFigure(com.archimatetool.editor.diagram.figures.IRoundedRectangleFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle)

Example 4 with RoundedRectangle

use of org.eclipse.draw2d.RoundedRectangle in project liferay-ide by liferay.

the class PortletColumnEditPart method createFigureForModel.

protected Figure createFigureForModel() {
    if (getModel() instanceof PortletColumnElement) {
        RoundedRectangle rect = new ColumnFigure();
        rect.setCornerDimensions(new Dimension(10, 10));
        return rect;
    } else {
        throw new IllegalArgumentException();
    }
}
Also used : PortletColumnElement(com.liferay.ide.layouttpl.core.model.PortletColumnElement) ColumnFigure(com.liferay.ide.layouttpl.ui.draw2d.ColumnFigure) Dimension(org.eclipse.draw2d.geometry.Dimension) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle)

Example 5 with RoundedRectangle

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

the class SparkStreamingSubjobContainerFigure method initFigure.

@Override
protected void initFigure() {
    super.initFigure();
    timeoutFigureRect = new RoundedRectangle();
    timeoutFigureText = new SimpleHtmlFigure();
    timeoutFigureText.setOpaque(false);
    statsFigureRect = new RoundedRectangle();
    statsFigureText = new SimpleHtmlFigure();
    statsFigureText.setOpaque(false);
    //$NON-NLS-1$ 
    String text = "<b>Batch started</b>: <br>";
    //$NON-NLS-1$
    text += "<b>Batch completed</b>: <br><br><br>";
    //$NON-NLS-1$ 
    text += "<b>Last scheduling delay</b>: <br>";
    //$NON-NLS-1$ 
    text += "<b>Last processing delay</b>: <br>";
    //$NON-NLS-1$ 
    text += "<b>Last total delay</b>: <br>";
    statsFigureText.setText(text);
}
Also used : RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Aggregations

RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)7 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3 Figure (org.eclipse.draw2d.Figure)2 IFigure (org.eclipse.draw2d.IFigure)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 AbstractDiagramModelObjectFigure (com.archimatetool.editor.diagram.figures.AbstractDiagramModelObjectFigure)1 IFigureDelegate (com.archimatetool.editor.diagram.figures.IFigureDelegate)1 IRoundedRectangleFigure (com.archimatetool.editor.diagram.figures.IRoundedRectangleFigure)1 PortletColumnElement (com.liferay.ide.layouttpl.core.model.PortletColumnElement)1 ColumnFigure (com.liferay.ide.layouttpl.ui.draw2d.ColumnFigure)1 Iterator (java.util.Iterator)1 ActionEvent (org.eclipse.draw2d.ActionEvent)1 ActionListener (org.eclipse.draw2d.ActionListener)1 FreeformLayout (org.eclipse.draw2d.FreeformLayout)1 ImageFigure (org.eclipse.draw2d.ImageFigure)1 Polyline (org.eclipse.draw2d.Polyline)1 RectangleFigure (org.eclipse.draw2d.RectangleFigure)1 Point (org.eclipse.draw2d.geometry.Point)1 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)1