Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » When to assign TextFlow font?
When to assign TextFlow font? [message #220409] Mon, 31 July 2006 12:41 Go to next message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

I have a Figure which extends RectangleFigure and contains a TextFlow.
The TextFlow is added to its parent in the figure's constructor.

I tried to set the Font for the TextFlow at that time, but it seems that
the parent figure's font is not yet initialized (null).

When is the proper time to assign a new Font to the TextFlow? I have
tried paintFigure(Graphics) and layout() but neither of these have an
effect.

Thanks,
Ben
Re: When to assign TextFlow font? [message #220479 is a reply to message #220409] Mon, 31 July 2006 19:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

You don't have to set its font: it will inherit one. If you're getting an
NPE for the font that means the TextFlow is in a broken figure hierarchy.
That is, someone's inquiring for its font before it (or one of its
ancestors) has been parented properly. BTW, I assume you're using a
FlowPage and don't have the TextFlow directly parented by a RectangleFigure.

"Ben Vitale" <ben.vitale@precipia.com> wrote in message
news:eaktob$i4e$1@utils.eclipse.org...
>I have a Figure which extends RectangleFigure and contains a TextFlow. The
>TextFlow is added to its parent in the figure's constructor.
>
> I tried to set the Font for the TextFlow at that time, but it seems that
> the parent figure's font is not yet initialized (null).
>
> When is the proper time to assign a new Font to the TextFlow? I have
> tried paintFigure(Graphics) and layout() but neither of these have an
> effect.
>
> Thanks,
> Ben
>
Re: When to assign TextFlow font? [message #220596 is a reply to message #220479] Wed, 02 August 2006 16:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

I want to assign a *different* font size than the default. I believe
this requires getting the current Font and its FontData, and updating
its height.

What I have is below. Should I do the font operations in the constructor?

public class ScenarioNodeFigure
extends RectangleFigure

public ScenarioNodeFigure()
{
setBorder(new MarginBorder(1));

Image image = new Image(...)
ImageFigure imageFigure = new ImageFigure(image);
add(imageFigure);

FlowPage flowPage = new FlowPage();
TextFlow textFlow = new TextFlow();
textFlow.setLayoutManager(new ParagraphTextLayout(textFlow,
ParagraphTextLayout.WORD_WRAP_SOFT));
textFlow.setOpaque(false);
flowPage.add(textFlow);

setLayoutManager(new StackLayout());
add(flowPage);
}

Pratik Shah wrote:
> You don't have to set its font: it will inherit one. If you're getting an
> NPE for the font that means the TextFlow is in a broken figure hierarchy.
> That is, someone's inquiring for its font before it (or one of its
> ancestors) has been parented properly. BTW, I assume you're using a
> FlowPage and don't have the TextFlow directly parented by a RectangleFigure.
>
> "Ben Vitale" <ben.vitale@precipia.com> wrote in message
> news:eaktob$i4e$1@utils.eclipse.org...
>> I have a Figure which extends RectangleFigure and contains a TextFlow. The
>> TextFlow is added to its parent in the figure's constructor.
>>
>> I tried to set the Font for the TextFlow at that time, but it seems that
>> the parent figure's font is not yet initialized (null).
>>
>> When is the proper time to assign a new Font to the TextFlow? I have
>> tried paintFigure(Graphics) and layout() but neither of these have an
>> effect.
>>
>> Thanks,
>> Ben
>>
>
>
Re: When to assign TextFlow font? [message #220629 is a reply to message #220596] Wed, 02 August 2006 17:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

You can't do the font operations in the constructor, because when the
figure's being constructed, it doesn't have a parent yet. So, it doesn't
have an inherited font.

"Ben Vitale" <ben.vitale@precipia.com> wrote in message
news:eaqim6$gr1$1@utils.eclipse.org...
>I want to assign a *different* font size than the default. I believe this
>requires getting the current Font and its FontData, and updating its
>height.
>
> What I have is below. Should I do the font operations in the constructor?
>
> public class ScenarioNodeFigure
> extends RectangleFigure
>
> public ScenarioNodeFigure()
> {
> setBorder(new MarginBorder(1));
> Image image = new Image(...)
> ImageFigure imageFigure = new ImageFigure(image);
> add(imageFigure);
>
> FlowPage flowPage = new FlowPage();
> TextFlow textFlow = new TextFlow();
> textFlow.setLayoutManager(new ParagraphTextLayout(textFlow,
> ParagraphTextLayout.WORD_WRAP_SOFT));
> textFlow.setOpaque(false);
> flowPage.add(textFlow);
>
> setLayoutManager(new StackLayout());
> add(flowPage);
> }
>
> Pratik Shah wrote:
>> You don't have to set its font: it will inherit one. If you're getting
>> an NPE for the font that means the TextFlow is in a broken figure
>> hierarchy. That is, someone's inquiring for its font before it (or one of
>> its ancestors) has been parented properly. BTW, I assume you're using a
>> FlowPage and don't have the TextFlow directly parented by a
>> RectangleFigure.
>>
>> "Ben Vitale" <ben.vitale@precipia.com> wrote in message
>> news:eaktob$i4e$1@utils.eclipse.org...
>>> I have a Figure which extends RectangleFigure and contains a TextFlow.
>>> The TextFlow is added to its parent in the figure's constructor.
>>>
>>> I tried to set the Font for the TextFlow at that time, but it seems that
>>> the parent figure's font is not yet initialized (null).
>>>
>>> When is the proper time to assign a new Font to the TextFlow? I have
>>> tried paintFigure(Graphics) and layout() but neither of these have an
>>> effect.
>>>
>>> Thanks,
>>> Ben
>>>
>>
Re: When to assign TextFlow font? [message #220674 is a reply to message #220479] Thu, 03 August 2006 12:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: senthil.periasamy.flextronicssoftware.com

Hi
Are you from india. Please let me know if you have any contact
email id or contact number i am very novice to GMF EMF and GEF and i am
currently started to learn about the different framework

regards
senthil
Re: When to assign TextFlow font? [message #220862 is a reply to message #220629] Mon, 07 August 2006 11:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

Do you have a recommendation on when I *can* do font operations? That
was my original question. I have already tried in layout() and
paintFigure().

Thanks,
Ben

Pratik Shah wrote:
> You can't do the font operations in the constructor, because when the
> figure's being constructed, it doesn't have a parent yet. So, it doesn't
> have an inherited font.
>
> "Ben Vitale" <ben.vitale@precipia.com> wrote in message
> news:eaqim6$gr1$1@utils.eclipse.org...
>> I want to assign a *different* font size than the default. I believe this
>> requires getting the current Font and its FontData, and updating its
>> height.
>>
>> What I have is below. Should I do the font operations in the constructor?
>>
>> public class ScenarioNodeFigure
>> extends RectangleFigure
>>
>> public ScenarioNodeFigure()
>> {
>> setBorder(new MarginBorder(1));
>> Image image = new Image(...)
>> ImageFigure imageFigure = new ImageFigure(image);
>> add(imageFigure);
>>
>> FlowPage flowPage = new FlowPage();
>> TextFlow textFlow = new TextFlow();
>> textFlow.setLayoutManager(new ParagraphTextLayout(textFlow,
>> ParagraphTextLayout.WORD_WRAP_SOFT));
>> textFlow.setOpaque(false);
>> flowPage.add(textFlow);
>>
>> setLayoutManager(new StackLayout());
>> add(flowPage);
>> }
>>
>> Pratik Shah wrote:
>>> You don't have to set its font: it will inherit one. If you're getting
>>> an NPE for the font that means the TextFlow is in a broken figure
>>> hierarchy. That is, someone's inquiring for its font before it (or one of
>>> its ancestors) has been parented properly. BTW, I assume you're using a
>>> FlowPage and don't have the TextFlow directly parented by a
>>> RectangleFigure.
>>>
>>> "Ben Vitale" <ben.vitale@precipia.com> wrote in message
>>> news:eaktob$i4e$1@utils.eclipse.org...
>>>> I have a Figure which extends RectangleFigure and contains a TextFlow.
>>>> The TextFlow is added to its parent in the figure's constructor.
>>>>
>>>> I tried to set the Font for the TextFlow at that time, but it seems that
>>>> the parent figure's font is not yet initialized (null).
>>>>
>>>> When is the proper time to assign a new Font to the TextFlow? I have
>>>> tried paintFigure(Graphics) and layout() but neither of these have an
>>>> effect.
>>>>
>>>> Thanks,
>>>> Ben
>>>>
>
Re: When to assign TextFlow font? [message #220995 is a reply to message #220862] Tue, 08 August 2006 21:42 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

What you are suggesting is along the lines of style support. I know of a
client that has added this to their application, but it is not easy to do
efficiently. We have deprecated many fields that would eventually move into
a style object, but I don't know of any plans to implement style support
soon.

Otherwise, the editpart should manage the font, or you could hook into
validate() if you really get desperate.

"Ben Vitale" <ben.vitale@precipia.com> wrote in message
news:eb794t$e5f$1@utils.eclipse.org...
> Do you have a recommendation on when I *can* do font operations? That was
> my original question. I have already tried in layout() and paintFigure().
>
> Thanks,
> Ben
>
Previous Topic:editPart hierarchy vs figure hierarchy
Next Topic:Curves
Goto Forum:
  


Current Time: Mon Jan 13 14:55:37 GMT 2025

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

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

Back to the top