Drawing Borders Issues [message #185270] |
Thu, 23 June 2005 17:40  |
Eclipse User |
|
|
|
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 #185640 is a reply to message #185609] |
Tue, 28 June 2005 04:53  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04236 seconds