Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Help in Draw in GEF
Help in Draw in GEF [message #938288] Tue, 09 October 2012 18:43
Luis Carlos Moreira da Costa is currently offline Luis Carlos Moreira da CostaFriend
Messages: 39
Registered: July 2009
Location: Brazil
Member

Dear friend

Please!
I'm using the GEF to draw a "USER" when did he ran outside and within GEF is not working, could you help me with this?


Note: I'll be continuing after the image but're a bit difficult if you can help me, thank you very much for your help!
Follow the image file in "PNG", as it should be ...


import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Path;
import org.eclipse.ui.PlatformUI;

public class UserFigure extends RectangleFigure {

public UserFigure(final int foldSize) {
}

/**
* Draw User
*/
protected void dopaint(final Graphics graphics, final boolean isOutline) {
graphics.setForegroundColor(ColorConstants.black);
graphics.setLineWidth(1);
Rectangle r = getBounds();
final int x = (r.x + lineWidth / 2);
final int y = (r.y + lineWidth / 2);
final int w = (r.width - Math.max(1, lineWidth));
final int h = (r.height - Math.max(1, lineWidth));

final Rectangle temp = getClientArea();
r = new Rectangle(temp.x + 10, temp.y + 10, temp.width - 20, temp.height - 20);

drawShirt(graphics, r);
drawHead(graphics, r);
}

private void drawHead(final Graphics g, final Rectangle rect) {
g.drawOval((rect.x + rect.width / 3), (rect.x + rect.height * 1 / 5), (rect.width / 3), (rect.height / 3));

}

private void drawShirt(final Graphics g, final Rectangle rect) {

final Path path = new Path(PlatformUI.getWorkbench().getDisplay());

path.moveTo(10, (rect.y + rect.height * 2 / 3));
path.lineTo(10, (rect.y + rect.height));
path.lineTo((rect.x + rect.width), (rect.y + rect.height));
path.lineTo((rect.x + rect.width), (rect.y + rect.height * 2 / 3));
path.addArc((rect.x + rect.width / 3), (rect.y + (rect.height * 1 / 2)), (rect.width * 2 / 3), (rect.height * 1 / 3), 0, 90);
path.addArc((rect.x + rect.width / 3), (rect.y + (rect.height * 1 / 3)), (rect.width * 1 / 3), (rect.height * 1 / 3), 0, -180);
path.addArc(10, (rect.y + (rect.height * 1 / 2)), (rect.width * 2 / 3), (rect.height * 1 / 3), 90, 90);

g.fillRectangle(rect);
g.drawPath(path);
path.dispose();

g.setClip(path);
g.fillRectangle(rect);
g.setClip((Rectangle) null);
g.drawPath(path);
path.dispose();

g.drawLine((rect.x + rect.width / 5), (rect.x + rect.height), (rect.x + rect.width / 5), (rect.x + rect.height * 3 / 4));
g.drawLine((rect.x + rect.width * 4 / 5), (rect.x + rect.height), (rect.x + rect.width * 4 / 5), (rect.x + rect.height * 3 / 4));
}

/**
* @see Shape#fillShape(Graphics)
*/
protected void fillShape(Graphics graphics) {
dopaint(graphics, false);
}
/**
* @see Shape#outlineShape(Graphics)
*/
protected void outlineShape(Graphics graphics) {
dopaint(graphics, true);
}
}
  • Attachment: User.png
    (Size: 0.79KB, Downloaded 335 times)


Luís Carlos Moreira da Costa
Eclipse RAP, RCP, eRCP, GEF, EMF, GMF, OSGI, Spring-DM and Pentaho Developer
Regional Communities/Brazil
http://wiki.eclipse.org/Regional_Communities/Brazil
Previous Topic:D'n'D from one gef editor to another one
Next Topic:SnapToGrid on connection bendpoints
Goto Forum:
  


Current Time: Tue Apr 16 04:44:12 GMT 2024

Powered by FUDForum. Page generated in 0.10802 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top