Figure [message #160161] |
Thu, 02 December 2004 18:49 |
Eclipse User |
|
|
|
Originally posted by: svenkat.asu.edu
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());
}
|
|
|
Powered by
FUDForum. Page generated in 0.02566 seconds