Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Drawing Borders Issues
Drawing Borders Issues [message #185270] Thu, 23 June 2005 21:40 Go to next message
Fabio is currently offline FabioFriend
Messages: 13
Registered: July 2009
Junior Member
Hi.

I'm trying to make new figures for my editor based on the ClassFigure on
the eDiagram example. The new figure should look like this:
http://img.photobucket.com/albums/v495/_sl0t_/classfigure.gi f


First I tought that creating a new Border for the figure would solve it,
so I made a new class extending from AbstractBorder and created a new
border with the this new shape, but changing the border position doesn't
change how the inside figure backgound is filled.
Then I tried creating a polygon inside the border that would be placed at
the top of the figure. This way I could draw and fill the polygon with the
same color as the inside figure.
For this, I wrote this piece of code:

public void paint(IFigure figure, Graphics g, Insets in) {
Rectangle r = figure.getBounds().getCropped(in);

g.setBackgroundColor( ColorConstants.red );
PointList pl = new PointList();
pl.addPoint( r.getTopLeft() );
pl.addPoint( r.getTopLeft().x + 10, r.getTopLeft().y + 10 );
pl.addPoint( r.getTopRight().x, r.getTopRight().y + 10 );
pl.addPoint( r.getTopRight() );
g.fillPolygon( pl );

...
}

But then I end up with this figure:
http://img.photobucket.com/albums/v495/_sl0t_/classfigure2.g if

Was that supposed to happen? Why?
Any suggestions to help me make the intended figure?


Thanks in advance.
Fábio Sobral.
Re: Drawing Borders Issues [message #185586 is a reply to message #185270] Mon, 27 June 2005 16:25 Go to previous messageGo to next message
Andreas Holtz is currently offline Andreas HoltzFriend
Messages: 53
Registered: July 2009
Member
Fábio schrieb am 23.06.2005 23:40:
> Hi.
> ...
> Was that supposed to happen?

Yes!

> Why?

Because you said GEF to paint it like this! :-)

> Any suggestions to help me make the intended figure?

try

pl.addPoint( r.getTopLeft().x, r.getTopLeft().y + 10 );
pl.addPoint( r.getTopLeft().x + 10, r.getTopLeft().y );
pl.addPoint( r.getTopRight() );
pl.addPoint( r.getTopRight().x, r.getTopRight().y + 10 );
g.fillPolygon( pl );

I hope I did not miscalculated it, too... :D

Andreas

> Thanks in advance.
> Fábio Sobral.
Re: Drawing Borders Issues [message #185601 is a reply to message #185586] Mon, 27 June 2005 18:24 Go to previous messageGo to next message
Fabio is currently offline FabioFriend
Messages: 13
Registered: July 2009
Junior Member
God, I feel so stupid. I even asked someone else to check if I didn't make
any mistake before asking here. Next time I'll have more people to check.
:P Thanks!

Unfortunately this didn't solve my problem yet. I have to draw classes
with "unusual" shapes. I want to keep the draw2d Label as my figure
because all classes have a name, but the Label doesn't allow me to change
it's shape, so I tought that drawing a border outside of it and filling it
with the same color as the Label's background color it should look the way
I want. But look what I got:
http://img.photobucket.com/albums/v495/_sl0t_/classfigure3.g if

The little triangle on the top right was also colored with the Label's
background color, but I want it to have the same color as the canvas.
Is it possible to do this way or will I have to change my figure?


Thanks again.
Fábio Sobral.
Re: Drawing Borders Issues [message #185609 is a reply to message #185601] Mon, 27 June 2005 18:56 Go to previous messageGo to next message
Fabio is currently offline FabioFriend
Messages: 13
Registered: July 2009
Junior Member
I forgot to say that right now I'm solving this problem by drawing
polygons with white background in the areas that should have the same
color as the canvas. Altought it solves my problem, I don't really like
it. This way I'll have to change all figures border if I need to change
the canvas background (well, I won't probably ever need this but...) and I
feel that I'm wasting resources by making it draw extra polygons.


Fábio Sobral.
Re: Drawing Borders Issues [message #185640 is a reply to message #185609] Tue, 28 June 2005 08:53 Go to previous message
Andreas Holtz is currently offline Andreas HoltzFriend
Messages: 53
Registered: July 2009
Member
Fábio schrieb am 27.06.2005 20:56:
> I forgot to say that right now I'm solving this problem by drawing
> polygons with white background in the areas that should have the same
> color as the canvas.
> Fábio Sobral.

What about playing with the setOpaque()-method?
My idea:

create a Figure (classFigure) which is set to setOpaque(false) (default).
set a Layout for that figure (stackLayout would be perfect).
create your "unsual" figure (its a polygon or it extends a polygon). add
a layoutManager (perhaps ToolbarLayout(false)), a label and anything
you need.
setOpaque(true) to the unsualFigure and add it to your classFigure.

if you add figures to your unusualFigure, try playing with the
MarginBorder, so the subFigures won't paint on lines of the unusualFigure.

This way i created a figure, based on a RoundedRectangle.

good luck

Andreas
Previous Topic:How to programatically launch Preference Dialog
Next Topic:application flow
Goto Forum:
  


Current Time: Mon Dec 30 17:16:04 GMT 2024

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

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

Back to the top