Home » Eclipse Projects » GEF » draw2d Newbie question
draw2d Newbie question [message #199740] |
Tue, 18 October 2005 22:31 |
Eclipse User |
|
|
|
Originally posted by: gboysko.cox.net
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
|
|
|
Re: draw2d Newbie question [message #199834 is a reply to message #199740] |
Wed, 19 October 2005 15:28 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Bounds of a figure are inclusive on the top and left sides, and exclusive on
the bottom and right. They are the same as the behavior of fillRect(...).
So subtract 1.
"Glenn Boysko" <gboysko@cox.net> wrote in message
news:f13a2496e9e2977c35f0f88732dc62b0$1@www.eclipse.org...
> 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
>
|
|
|
Re: draw2d Newbie question [message #199841 is a reply to message #199740] |
Wed, 19 October 2005 15:30 |
Eclipse User |
|
|
|
Originally posted by: none.unknown.com
Do tempRect.resize(-1,-1) before you use its bottom-left and bottom-right
points.
"Glenn Boysko" <gboysko@cox.net> wrote in message
news:f13a2496e9e2977c35f0f88732dc62b0$1@www.eclipse.org...
> 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
>
|
|
|
Re: draw2d Newbie question [message #199849 is a reply to message #199834] |
Wed, 19 October 2005 16:15 |
Eclipse User |
|
|
|
Originally posted by: gboysko.cox.net
Randy:
Thanks for your response. What is the rationale for a Figure not
passing the Insets that is associated with it in the paintBorder method?
Thanks,
Glenn
Randy Hudson wrote:
> Bounds of a figure are inclusive on the top and left sides, and exclusive on
> the bottom and right. They are the same as the behavior of fillRect(...).
>
> So subtract 1.
>
>
> "Glenn Boysko" <gboysko@cox.net> wrote in message
> news:f13a2496e9e2977c35f0f88732dc62b0$1@www.eclipse.org...
>
>>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
>>
>
>
>
|
|
|
Re: draw2d Newbie question [message #199898 is a reply to message #199849] |
Wed, 19 October 2005 21:22 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
A border is passed non-zero insets in the case of composing multiple
borders, each one painting inside the previous one.
"Glenn Boysko" <gboysko@cox.net> wrote in message
news:43567119.8050702@cox.net...
> Randy:
>
> Thanks for your response. What is the rationale for a Figure not passing
> the Insets that is associated with it in the paintBorder method?
>
> Thanks,
> Glenn
>
|
|
|
Goto Forum:
Current Time: Sun Dec 08 03:20:41 GMT 2024
Powered by FUDForum. Page generated in 0.03465 seconds
|