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);
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations