Home » Eclipse Projects » GEF » Help in Draw in GEF
| Help in Draw in GEF [message #938288] |
Tue, 09 October 2012 14:43 |
|
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 85 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
|
|
|
Goto Forum:
Current Time: Fri May 24 17:26:02 EDT 2013
Powered by FUDForum. Page generated in 0.01660 seconds
|