[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.gef] Re: draw2d Newbie question
|
Do tempRect.resize(-1,-1) before you use its bottom-left and bottom-right
points.
"Glenn Boysko" <gboysko@xxxxxxx> wrote in message
news:f13a2496e9e2977c35f0f88732dc62b0$1@xxxxxxxxxxxxxxxxxx
> Hello:
>
> I'm very new to GEF and Draw2d. I'm adding a simple (1 unit wide) border
> to a Label. Here's what the border class looks like:
>
> class MyBorder extends AbstractBorder {
> public Insets getInsets(IFigure figure) {
> return new Insets(1, 0, 0, 0);
> }
> public void paint(IFigure figure, Graphics graphics, Insets insets) {
> graphics.drawLine(getPaintRectangle(figure, insets).getTopLeft(),
> tempRect.getTopRight());
> }
> }
>
> This works fine. However, if I put the same border on the bottom, as in:
>
> class MyBorder extends AbstractBorder {
> public Insets getInsets(IFigure figure) {
> return new Insets(0, 0, 1, 0);
> }
> public void paint(IFigure figure, Graphics graphics, Insets insets) {
> graphics.drawLine(getPaintRectangle(figure,
> insets).getBottomLeft(),
> tempRect.getBottomRight());
> }
> }
>
> Then it is not shown.
>
> If I look at the code in Figure, I see that Figure.paintBorder passes in
> NO_INSETS into the paint method instead of what is returned by getInsets.
> Is this as expected?
>
> Shouldn't paint be invoked with the Insets that is associated with the
> Figure?
>
> It would seem that the border is drawn, but appears below the Label
> causing it to be occluded. Should I be able to draw a bottom border on a
> label using the code below?
>
> Thanks,
> Glenn
>