Search in sources :

Example 76 with Rectangle

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

the class DatabaseBusinessItemShapeFigure method drawFigure.

private void drawFigure(Rectangle r, Graphics graphics) {
    int ellipseHeight = (int) (r.height * 0.25);
    Rectangle ellipse = new Rectangle(r.x, r.y, r.width, ellipseHeight);
    Rectangle middle = new Rectangle(r.x, r.y + (ellipseHeight / 2), r.width, r.height - ellipseHeight);
    Rectangle lowerArc = new Rectangle(r.x, r.y + r.height - ellipseHeight, r.width, ellipseHeight);
    graphics.fillOval(ellipse);
    graphics.fillRectangle(middle);
    graphics.fillArc(lowerArc, 180, 180);
    graphics.drawOval(ellipse.x, ellipse.y, ellipse.width, ellipse.height);
    graphics.drawLine(middle.x, middle.y, middle.x, middle.y + middle.height);
    graphics.drawLine(middle.x + middle.width, middle.y, middle.x + middle.width, middle.y + middle.height);
    graphics.drawArc(lowerArc, 180, 180);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 77 with Rectangle

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

the class DataBusinessItemShapeFigure method paintFigure.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
     */
@Override
protected void paintFigure(Graphics graphics) {
    Rectangle r = getInnerBounds();
    if (getDrawFrame()) {
        setDefaultSize(60, 60);
        setBorder(border);
        drawFigure(getSmallBounds(), graphics);
    } else {
        if (getBorder() != null) {
            setBorder(null);
        }
        drawFigure(getInnerBounds(), graphics);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 78 with Rectangle

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

the class SVGImageExporter method export.

public static void export(GraphicalViewer viewer, OutputStream outputStream, List businessItems) {
    /*
         * 1. First get the figure whose visuals we want to save as image. So we would like to save the rooteditpart
         * which actually hosts all the printable layers.
         * 
         * NOTE: ScalableRootEditPart manages layers and is registered graphicalviewer's editpartregistry with the key
         * LayerManager.ID ... well that is because ScalableRootEditPart manages all layers that are hosted on a
         * FigureCanvas. Many layers exist for doing different things
         */
    SimpleRootEditPart rootEditPart = (SimpleRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID);
    // rootEditPart.
    IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
    // getFigure();
    Rectangle bounds = rootFigure.getBounds();
    GraphicsSVG graphics = GraphicsSVG.getInstance(bounds.getTranslated(bounds.getLocation().negate()));
    TalendSVGIDGenerator generator = new TalendSVGIDGenerator(businessItems);
    graphics.getSVGGraphics2D().getGeneratorContext().setIDGenerator(generator);
    graphics.translate(bounds.getLocation().negate());
    rootFigure.paint(graphics);
    try {
        graphics.getSVGGraphics2D().stream(new BufferedWriter(new OutputStreamWriter(outputStream)));
    } catch (SVGGraphics2DIOException e) {
        ExceptionHandler.process(e);
    }
}
Also used : SimpleRootEditPart(org.eclipse.gef.editparts.SimpleRootEditPart) SVGGraphics2DIOException(org.apache.batik.svggen.SVGGraphics2DIOException) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicsSVG(org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg.export.GraphicsSVG) OutputStreamWriter(java.io.OutputStreamWriter) LayerManager(org.eclipse.gef.editparts.LayerManager) IFigure(org.eclipse.draw2d.IFigure) BufferedWriter(java.io.BufferedWriter)

Example 79 with Rectangle

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

the class ListBusinessItemShapeFigure method paintFigure.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
     */
@Override
protected void paintFigure(Graphics graphics) {
    Rectangle r = getInnerBounds();
    if (getDrawFrame()) {
        setDefaultSize(60, 60);
        setBorder(border);
        drawFigure(getSmallBounds(), graphics);
    } else {
        if (getBorder() != null) {
            setBorder(null);
        }
        drawFigure(getInnerBounds(), graphics);
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 80 with Rectangle

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

the class BusinessExtNodeLabelHostLayoutEditPolicy method getConstraintFor.

/**
     * @generated
     */
protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
    int dx = ((Integer) ViewUtil.getStructuralFeatureValue((View) child.getModel(), NotationPackage.eINSTANCE.getLocation_X())).intValue();
    int dy = ((Integer) ViewUtil.getStructuralFeatureValue((View) child.getModel(), NotationPackage.eINSTANCE.getLocation_Y())).intValue();
    Rectangle r = new Rectangle(dx, dy, 0, 0);
    child.getFigure().translateToAbsolute(r);
    r.translate(request.getMoveDelta());
    child.getFigure().translateToRelative(r);
    return r;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) View(org.eclipse.gmf.runtime.notation.View)

Aggregations

Rectangle (org.eclipse.draw2d.geometry.Rectangle)347 Point (org.eclipse.draw2d.geometry.Point)107 Dimension (org.eclipse.draw2d.geometry.Dimension)80 IFigure (org.eclipse.draw2d.IFigure)43 List (java.util.List)24 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)18 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)17 PointList (org.eclipse.draw2d.geometry.PointList)16 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)15 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)14 ArrayList (java.util.ArrayList)11 Iterator (java.util.Iterator)11 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)11 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)10 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)10 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)8 Viewport (org.eclipse.draw2d.Viewport)8 Node (org.talend.designer.core.ui.editor.nodes.Node)8 Image (org.eclipse.swt.graphics.Image)7