Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Wide Labels below small figures
Wide Labels below small figures [message #235636] Wed, 13 June 2007 18:54 Go to next message
Eclipse UserFriend
Originally posted by: mlevison.gmail.com

Sometimes the user wants to give a name to an object that is wider than
the figure it sits below. How do I accommodate this?

The standard solution to labels below figures is a composite figure
using a Flow/Toolbar layout to position the children
( http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg1 8144.html).

Like Alex I see two problems with this solution?
1) The label is clipped to the bounds of the parent
2) For purposes of attachment etc the bounds grow to include the label.

Instead I would like a piece of text that sits below my figure but
doesn't change its bounds. In addition when the figure is moved the
piece of text should move to.

Is this possible? How?

Cheers
Mark Levison
Re: Wide Labels below small figures [message #235738 is a reply to message #235636] Thu, 14 June 2007 21:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mlevison.gmail.com

Mark Levison wrote:
> Sometimes the user wants to give a name to an object that is wider than
> the figure it sits below. How do I accommodate this?
>
> The standard solution to labels below figures is a composite figure
> using a Flow/Toolbar layout to position the children
> ( http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg1 8144.html).
>
> Like Alex I see two problems with this solution?
> 1) The label is clipped to the bounds of the parent
> 2) For purposes of attachment etc the bounds grow to include the label.
>
> Instead I would like a piece of text that sits below my figure but
> doesn't change its bounds. In addition when the figure is moved the
> piece of text should move to.
>
> Is this possible? How?

BTW the Interface HandleBounds and getHandleBounds seem designed with
this problem in mind. I haven't coded it yet so I'm not certain that is
the solution - but we have a good chance here.
Re: Wide Labels below small figures [message #235745 is a reply to message #235738] Fri, 15 June 2007 05:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: johan.piculell.ericsson.com

Mark Levison wrote:

> Mark Levison wrote:
>> Sometimes the user wants to give a name to an object that is wider than
>> the figure it sits below. How do I accommodate this?
>>
>> The standard solution to labels below figures is a composite figure
>> using a Flow/Toolbar layout to position the children
>> ( http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg1 8144.html).
>>
>> Like Alex I see two problems with this solution?
>> 1) The label is clipped to the bounds of the parent
>> 2) For purposes of attachment etc the bounds grow to include the label.
>>
>> Instead I would like a piece of text that sits below my figure but
>> doesn't change its bounds. In addition when the figure is moved the
>> piece of text should move to.
>>
>> Is this possible? How?

> BTW the Interface HandleBounds and getHandleBounds seem designed with
> this problem in mind. I haven't coded it yet so I'm not certain that is
> the solution - but we have a good chance here.

I'm very interested in this topic as well Mark, please keep us posted on
your progress. If I can close some other issues I might start to look at
this myself as well.

/Johan
Re: Wide Labels below small figures [message #235986 is a reply to message #235745] Wed, 20 June 2007 01:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mlevison.gmail.com

My solution
1) Wrap the original figure in a wrapping figure that also includes the
label. The wrapping figure grows to be as large as required by the label.
2) Implement the interface HandleBounds on the wrapping figure and get
it to report the size of the original figure.

To get connections to appear in the right place:
Override the Anchor that you're using and in the getBox() return the
same bounds that you did for HandleBounds (see HandleBoundsAnchor).

Sample code - N.B. This code has been sanitized to avoid reveal
corporate details. Its not guaranteed to compile.

public class LabelWrapperFigure extends Figure implements HandleBounds
public LabelWrapperFigure(IFigure wrappedFigure) {
layout = new ToolbarLayout();
layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
layout.setStretchMinorAxis(false);
layout.setSpacing(2);
layout.setVertical(true);
// why didn't flowLayout work??
// FlowLayout layout = new FlowLayout();
// layout.setHorizontal(false);
// layout.setMajorSpacing(2);
// layout.setMajorSpacing(0);
// layout.setMinorAlignment(FlowLayout.ALIGN_CENTER);
// layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);


setLayoutManager(layout);
setOpaque(true);

add(wrappedFigure);

Label label = new Label();
label.setText(" some text ");
label.setTextPlacement(PositionConstants.SOUTH);
add(label);
}

public Rectangle getHandleBounds() {
// Get size from your figure somehow
return wrappedFigure.getBounds();
}
}

public class HandleBoundsAnchor extends ChopboxAnchor {
private final HandleBounds handleBounds;

public HandleBoundsAnchor(IFigure figure) {
super(figure);
// TODO consider requiring a derivation of ModelElementFigure
if (false == (figure instanceof HandleBounds)) {
// This won't compile we've got custom exception code
throw new IllegalArgException();
}

handleBounds = (HandleBounds) figure;
}

protected Rectangle getBox() {
return handleBounds.getHandleBounds();
}
}
Re: Wide Labels below small figures [message #236028 is a reply to message #235986] Wed, 20 June 2007 10:30 Go to previous message
Eclipse UserFriend
Originally posted by: johan.piculell.ericsson.com

Sweet, works just fine. Thanks for sharing Mark!

/Johan
Previous Topic:How to create a new
Next Topic:change Icon in Label
Goto Forum:
  


Current Time: Fri Aug 12 15:33:50 GMT 2022

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

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

Back to the top