Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Figure
Figure [message #160161] Thu, 02 December 2004 18:49
Eclipse UserFriend
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());
}
Previous Topic:inline/block
Next Topic:Align objects in Panel Figure
Goto Forum:
  


Current Time: Fri Apr 26 19:03:17 GMT 2024

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

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

Back to the top