[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.gef] Figure

I am having a tough time trying to create a shape using Graphics. The shapes I want to create can be found here:

http://www.public.asu.edu/~svenkat/downloads/or.GIF
http://www.public.asu.edu/~svenkat/downloads/and.GIF

The code I currently have is from the Logic example to create the sticky note figure. I was wondering if someone could help me modify the code in order to get the 2 shapes mentioned above. I'd greatly appreciate it.

Thanks!

Swami.

-------------------------------------------------

protected void paintFigure(Graphics graphics) {
	//setBackgroundColor(color_);
	setForegroundColor(color_);
	
	Rectangle rect = getBounds().getCopy();

	graphics.translate(getLocation());

// fill the note
PointList outline = new PointList();

outline.addPoint(0, 0);
outline.addPoint(rect.width - cornerSize, 0);
outline.addPoint(rect.width - 1, 0 /*cornerSize*/);
outline.addPoint(rect.width - 1, rect.height - 1);
outline.addPoint(0, rect.height - 1);

graphics.fillPolygon(outline);
// draw the inner outline
PointList innerLine = new PointList();

innerLine.addPoint(rect.width - innerSize - 1, 0);
innerLine.addPoint(rect.width - innerSize - 1, innerSize);
innerLine.addPoint(rect.width - 1, innerSize);
innerLine.addPoint(rect.width - innerSize - 1, 0);
innerLine.addPoint(0, 0);
innerLine.addPoint(0, rect.height - 1);
innerLine.addPoint(rect.width - 1, rect.height - 1);
innerLine.addPoint(rect.width - 1, innerSize);

graphics.drawPolygon(innerLine);

graphics.translate(getLocation().getNegated());
}