Home » Eclipse Projects » GEF » bug in Label.setTextAlignment ?
bug in Label.setTextAlignment ? [message #163950] |
Thu, 13 January 2005 18:33  |
Eclipse User |
|
|
|
Originally posted by: bandrews.nospam_bphnx.com
Hi,
I have the following code in an edit part:
protected IFigure createFigure()
{
Label model = (Label) getModel();
org.eclipse.draw2d.Label label = new
org.eclipse.draw2d.Label(model.getText());
label.setOpaque(true);
label.setBackgroundColor(new
Color(null,model.getBackgroundColor()));
label.setForegroundColor(new
Color(null,model.getForegroundColor()));
label.setFont(model.getFont());
label.setTextAlignment(PositionConstants.LEFT);
return label;
}
I would expect the text to be left justified when I see the Label in the
editor, but it's not. It's always in the center. It's the same with
PositionConstants.RIGHT. Am I missing something here, or is this a bug?
Can someone else please try it? I am using 3.1M2.
many thanks,
B
|
|
|
Re: bug in Label.setTextAlignment ? [message #163998 is a reply to message #163950] |
Sat, 15 January 2005 13:36   |
Eclipse User |
|
|
|
Barry,
I haven't tried this, but it is possible that your Draw2D Label is only as
large as the text it contains (Therefore the text alignment won't make a
difference).
It is likely that the Draw2D Label itself is center aligned in it's parent
figure giving you the impression that the text it contains is center
aligned.
A simple way to check this out is to set the background color of the Label
to be different from the background color of it's parent.
Hope this helps,
Brian.
Barry Andrews wrote:
> Hi,
> I have the following code in an edit part:
> protected IFigure createFigure()
> {
> Label model = (Label) getModel();
> org.eclipse.draw2d.Label label = new
> org.eclipse.draw2d.Label(model.getText());
> label.setOpaque(true);
> label.setBackgroundColor(new
> Color(null,model.getBackgroundColor()));
> label.setForegroundColor(new
> Color(null,model.getForegroundColor()));
> label.setFont(model.getFont());
> label.setTextAlignment(PositionConstants.LEFT);
> return label;
> }
> I would expect the text to be left justified when I see the Label in the
> editor, but it's not. It's always in the center. It's the same with
> PositionConstants.RIGHT. Am I missing something here, or is this a bug?
> Can someone else please try it? I am using 3.1M2.
> many thanks,
> B
|
|
|
Re: bug in Label.setTextAlignment ? [message #164159 is a reply to message #163998] |
Mon, 17 January 2005 13:29   |
Eclipse User |
|
|
|
Originally posted by: bandrews.nospam_bphnx.com
Thanks for the reply. No, the label is much wider than the text. I also
tried changing the background to be different than the parent's color
and it makes no difference.
If I don't get a resolution pretty soon, I will just assume a bug and
log it. I can't imagine that my code is wrong. Aligning text should be
straight forward.
thanks,
Barry
Brian Fernandes wrote:
> Barry,
>
> I haven't tried this, but it is possible that your Draw2D Label is only
> as large as the text it contains (Therefore the text alignment won't
> make a difference).
> It is likely that the Draw2D Label itself is center aligned in it's
> parent figure giving you the impression that the text it contains is
> center aligned.
>
> A simple way to check this out is to set the background color of the
> Label to be different from the background color of it's parent.
>
> Hope this helps,
> Brian.
>
>
>
> Barry Andrews wrote:
>
>> Hi,
>
>
>> I have the following code in an edit part:
>
>
>> protected IFigure createFigure()
>> {
>> Label model = (Label) getModel();
>> org.eclipse.draw2d.Label label = new
>> org.eclipse.draw2d.Label(model.getText());
>> label.setOpaque(true);
>> label.setBackgroundColor(new
>> Color(null,model.getBackgroundColor()));
>> label.setForegroundColor(new
>> Color(null,model.getForegroundColor()));
>> label.setFont(model.getFont());
>
>
>> label.setTextAlignment(PositionConstants.LEFT);
>
>
>> return label;
>> }
>
>
>> I would expect the text to be left justified when I see the Label in
>> the editor, but it's not. It's always in the center. It's the same
>> with PositionConstants.RIGHT. Am I missing something here, or is this
>> a bug? Can someone else please try it? I am using 3.1M2.
>
>
>
>> many thanks,
>
>
>> B
>
>
>
|
|
|
Re: bug in Label.setTextAlignment ? [message #164166 is a reply to message #164159] |
Mon, 17 January 2005 14:36   |
Eclipse User |
|
|
|
Barry,
I only suggested changing the background color as a means of verifying
that your label is indeed wider than it's text, not as a fix for the
problem.
If you haven't already, please look at the javadoc for Label -
setTextAlignment and setLabelAlignment methods. Might find some answers
there.
All the best,
Brian.
D
Barry Andrews wrote:
> Thanks for the reply. No, the label is much wider than the text. I also
> tried changing the background to be different than the parent's color
> and it makes no difference.
> If I don't get a resolution pretty soon, I will just assume a bug and
> log it. I can't imagine that my code is wrong. Aligning text should be
> straight forward.
> thanks,
> Barry
> Brian Fernandes wrote:
>> Barry,
>>
>> I haven't tried this, but it is possible that your Draw2D Label is only
>> as large as the text it contains (Therefore the text alignment won't
>> make a difference).
>> It is likely that the Draw2D Label itself is center aligned in it's
>> parent figure giving you the impression that the text it contains is
>> center aligned.
>>
>> A simple way to check this out is to set the background color of the
>> Label to be different from the background color of it's parent.
>>
>> Hope this helps,
>> Brian.
>>
>>
>>
>> Barry Andrews wrote:
>>
>>> Hi,
>>
>>
>>> I have the following code in an edit part:
>>
>>
>>> protected IFigure createFigure()
>>> {
>>> Label model = (Label) getModel();
>>> org.eclipse.draw2d.Label label = new
>>> org.eclipse.draw2d.Label(model.getText());
>>> label.setOpaque(true);
>>> label.setBackgroundColor(new
>>> Color(null,model.getBackgroundColor()));
>>> label.setForegroundColor(new
>>> Color(null,model.getForegroundColor()));
>>> label.setFont(model.getFont());
>>
>>
>>> label.setTextAlignment(PositionConstants.LEFT);
>>
>>
>>> return label;
>>> }
>>
>>
>>> I would expect the text to be left justified when I see the Label in
>>> the editor, but it's not. It's always in the center. It's the same
>>> with PositionConstants.RIGHT. Am I missing something here, or is this
>>> a bug? Can someone else please try it? I am using 3.1M2.
>>
>>
>>
>>> many thanks,
>>
>>
>>> B
>>
>>
>>
|
|
|
Re: bug in Label.setTextAlignment ? [message #164182 is a reply to message #164166] |
Mon, 17 January 2005 15:02   |
Eclipse User |
|
|
|
Originally posted by: bandrews.nospam_bphnx.com
Ok, if I use setLabelAlignment(), it works. But what does that mean? The
docs say "Sets the Label's alignment to the passed value." Ok, that's
nice, but what does it mean? What does it align to? I am interested in
positioning the text within the label, so I would presume to use the
setTextAlignment() method. This is very confusing!
Barry
Brian Fernandes wrote:
> Barry,
>
> I only suggested changing the background color as a means of verifying
> that your label is indeed wider than it's text, not as a fix for the
> problem.
>
> If you haven't already, please look at the javadoc for Label -
> setTextAlignment and setLabelAlignment methods. Might find some answers
> there.
>
> All the best,
> Brian.
>
>
> D
> Barry Andrews wrote:
>
>> Thanks for the reply. No, the label is much wider than the text. I
>> also tried changing the background to be different than the parent's
>> color and it makes no difference.
>
>
>> If I don't get a resolution pretty soon, I will just assume a bug and
>> log it. I can't imagine that my code is wrong. Aligning text should be
>> straight forward.
>
>
>> thanks,
>
>
>> Barry
>
>
>
>> Brian Fernandes wrote:
>>
>>> Barry,
>>>
>>> I haven't tried this, but it is possible that your Draw2D Label is
>>> only as large as the text it contains (Therefore the text alignment
>>> won't make a difference).
>>> It is likely that the Draw2D Label itself is center aligned in it's
>>> parent figure giving you the impression that the text it contains is
>>> center aligned.
>>>
>>> A simple way to check this out is to set the background color of the
>>> Label to be different from the background color of it's parent.
>>>
>>> Hope this helps,
>>> Brian.
>>>
>>>
>>>
>>> Barry Andrews wrote:
>>>
>>>> Hi,
>>>
>>>
>>>
>>>> I have the following code in an edit part:
>>>
>>>
>>>
>>>> protected IFigure createFigure()
>>>> {
>>>> Label model = (Label) getModel();
>>>> org.eclipse.draw2d.Label label = new
>>>> org.eclipse.draw2d.Label(model.getText());
>>>> label.setOpaque(true);
>>>> label.setBackgroundColor(new
>>>> Color(null,model.getBackgroundColor()));
>>>> label.setForegroundColor(new
>>>> Color(null,model.getForegroundColor()));
>>>> label.setFont(model.getFont());
>>>
>>>
>>>
>>>> label.setTextAlignment(PositionConstants.LEFT);
>>>
>>>
>>>
>>>> return label;
>>>> }
>>>
>>>
>>>
>>>> I would expect the text to be left justified when I see the Label in
>>>> the editor, but it's not. It's always in the center. It's the same
>>>> with PositionConstants.RIGHT. Am I missing something here, or is
>>>> this a bug? Can someone else please try it? I am using 3.1M2.
>>>
>>>
>>>
>>>
>>>> many thanks,
>>>
>>>
>>>
>>>> B
>>>
>>>
>>>
>>>
>
>
|
|
|
Re: bug in Label.setTextAlignment ? [message #164203 is a reply to message #164182] |
Mon, 17 January 2005 18:08   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Label supports both an icon and string simultaneously. The string can be
positioned above, below, left, and right of the icon. Text alignment refers
to the string's alignment with the icon, when the icon is larger than the
string.
-Randy
"Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
news:csh5lj$7he$1@www.eclipse.org...
> Ok, if I use setLabelAlignment(), it works. But what does that mean? The
> docs say "Sets the Label's alignment to the passed value." Ok, that's
> nice, but what does it mean? What does it align to? I am interested in
> positioning the text within the label, so I would presume to use the
> setTextAlignment() method. This is very confusing!
>
> Barry
>
>
>
> Brian Fernandes wrote:
>> Barry,
>>
>> I only suggested changing the background color as a means of verifying
>> that your label is indeed wider than it's text, not as a fix for the
>> problem.
>>
>> If you haven't already, please look at the javadoc for Label -
>> setTextAlignment and setLabelAlignment methods. Might find some answers
>> there.
>>
>> All the best,
>> Brian.
>>
>>
>> D
>> Barry Andrews wrote:
>>
>>> Thanks for the reply. No, the label is much wider than the text. I also
>>> tried changing the background to be different than the parent's color
>>> and it makes no difference.
>>
>>
>>> If I don't get a resolution pretty soon, I will just assume a bug and
>>> log it. I can't imagine that my code is wrong. Aligning text should be
>>> straight forward.
>>
>>
>>> thanks,
>>
>>
>>> Barry
>>
>>
>>
>>> Brian Fernandes wrote:
>>>
>>>> Barry,
>>>>
>>>> I haven't tried this, but it is possible that your Draw2D Label is only
>>>> as large as the text it contains (Therefore the text alignment won't
>>>> make a difference).
>>>> It is likely that the Draw2D Label itself is center aligned in it's
>>>> parent figure giving you the impression that the text it contains is
>>>> center aligned.
>>>>
>>>> A simple way to check this out is to set the background color of the
>>>> Label to be different from the background color of it's parent.
>>>>
>>>> Hope this helps,
>>>> Brian.
>>>>
>>>>
>>>>
>>>> Barry Andrews wrote:
>>>>
>>>>> Hi,
>>>>
>>>>
>>>>
>>>>> I have the following code in an edit part:
>>>>
>>>>
>>>>
>>>>> protected IFigure createFigure()
>>>>> {
>>>>> Label model = (Label) getModel();
>>>>> org.eclipse.draw2d.Label label = new
>>>>> org.eclipse.draw2d.Label(model.getText());
>>>>> label.setOpaque(true);
>>>>> label.setBackgroundColor(new
>>>>> Color(null,model.getBackgroundColor()));
>>>>> label.setForegroundColor(new
>>>>> Color(null,model.getForegroundColor()));
>>>>> label.setFont(model.getFont());
>>>>
>>>>
>>>>
>>>>> label.setTextAlignment(PositionConstants.LEFT);
>>>>
>>>>
>>>>
>>>>> return label;
>>>>> }
>>>>
>>>>
>>>>
>>>>> I would expect the text to be left justified when I see the Label in
>>>>> the editor, but it's not. It's always in the center. It's the same
>>>>> with PositionConstants.RIGHT. Am I missing something here, or is this
>>>>> a bug? Can someone else please try it? I am using 3.1M2.
>>>>
>>>>
>>>>
>>>>
>>>>> many thanks,
>>>>
>>>>
>>>>
>>>>> B
>>>>
>>>>
>>>>
>>>>
>>
|
|
|
Re: bug in Label.setTextAlignment ? [message #164242 is a reply to message #164203] |
Mon, 17 January 2005 21:12   |
Eclipse User |
|
|
|
Originally posted by: bandrews.nospam_bphnx.com
Hi Randy,
I thought that's what setTextPlacement was for?
"Sets the text placement of the label relative to its icon."
Barry
Randy Hudson wrote:
> Label supports both an icon and string simultaneously. The string can be
> positioned above, below, left, and right of the icon. Text alignment refers
> to the string's alignment with the icon, when the icon is larger than the
> string.
>
> -Randy
>
>
> "Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
> news:csh5lj$7he$1@www.eclipse.org...
>
>>Ok, if I use setLabelAlignment(), it works. But what does that mean? The
>>docs say "Sets the Label's alignment to the passed value." Ok, that's
>>nice, but what does it mean? What does it align to? I am interested in
>>positioning the text within the label, so I would presume to use the
>>setTextAlignment() method. This is very confusing!
>>
>>Barry
>>
>>
>>
>>Brian Fernandes wrote:
>>
>>>Barry,
>>>
>>>I only suggested changing the background color as a means of verifying
>>>that your label is indeed wider than it's text, not as a fix for the
>>>problem.
>>>
>>>If you haven't already, please look at the javadoc for Label -
>>>setTextAlignment and setLabelAlignment methods. Might find some answers
>>>there.
>>>
>>>All the best,
>>>Brian.
>>>
>>>
>>>D
>>>Barry Andrews wrote:
>>>
>>>
>>>>Thanks for the reply. No, the label is much wider than the text. I also
>>>>tried changing the background to be different than the parent's color
>>>>and it makes no difference.
>>>
>>>
>>>>If I don't get a resolution pretty soon, I will just assume a bug and
>>>>log it. I can't imagine that my code is wrong. Aligning text should be
>>>>straight forward.
>>>
>>>
>>>>thanks,
>>>
>>>
>>>>Barry
>>>
>>>
>>>
>>>>Brian Fernandes wrote:
>>>>
>>>>
>>>>>Barry,
>>>>>
>>>>>I haven't tried this, but it is possible that your Draw2D Label is only
>>>>>as large as the text it contains (Therefore the text alignment won't
>>>>>make a difference).
>>>>>It is likely that the Draw2D Label itself is center aligned in it's
>>>>>parent figure giving you the impression that the text it contains is
>>>>>center aligned.
>>>>>
>>>>>A simple way to check this out is to set the background color of the
>>>>>Label to be different from the background color of it's parent.
>>>>>
>>>>>Hope this helps,
>>>>>Brian.
>>>>>
>>>>>
>>>>>
>>>>>Barry Andrews wrote:
>>>>>
>>>>>
>>>>>>Hi,
>>>>>
>>>>>
>>>>>
>>>>>>I have the following code in an edit part:
>>>>>
>>>>>
>>>>>
>>>>>>protected IFigure createFigure()
>>>>>> {
>>>>>> Label model = (Label) getModel();
>>>>>> org.eclipse.draw2d.Label label = new
>>>>>>org.eclipse.draw2d.Label(model.getText());
>>>>>> label.setOpaque(true);
>>>>>> label.setBackgroundColor(new
>>>>>>Color(null,model.getBackgroundColor()));
>>>>>> label.setForegroundColor(new
>>>>>>Color(null,model.getForegroundColor()));
>>>>>> label.setFont(model.getFont());
>>>>>
>>>>>
>>>>>
>>>>>> label.setTextAlignment(PositionConstants.LEFT);
>>>>>
>>>>>
>>>>>
>>>>>> return label;
>>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>>I would expect the text to be left justified when I see the Label in
>>>>>>the editor, but it's not. It's always in the center. It's the same
>>>>>>with PositionConstants.RIGHT. Am I missing something here, or is this
>>>>>>a bug? Can someone else please try it? I am using 3.1M2.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>many thanks,
>>>>>
>>>>>
>>>>>
>>>>>>B
>>>>>
>>>>>
>>>>>
>>>>>
>
|
|
|
Re: bug in Label.setTextAlignment ? [message #164402 is a reply to message #164242] |
Tue, 18 January 2005 14:40  |
Eclipse User |
|
|
|
You're right, that's what setTextPlacement() is for. setTextAlignment() and
setIconAlignment() determine how they're aligned based on their placement.
So, say, the text is to the east of the icon, then valid icon and text
alignments are north, center, south (any other alignment will be ignored).
Notice that when you have no icon, you can get the same effect as
setLabelAlignment(EAST) by setting the text placement to south (or north)
and text alignment to left.
Go ahead and log a bug for insufficient/confusing information. We'll update
the JavaDoc.
"Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
news:cshrau$ic3$1@www.eclipse.org...
> Hi Randy,
>
> I thought that's what setTextPlacement was for?
> "Sets the text placement of the label relative to its icon."
>
> Barry
>
>
>
> Randy Hudson wrote:
> > Label supports both an icon and string simultaneously. The string can
be
> > positioned above, below, left, and right of the icon. Text alignment
refers
> > to the string's alignment with the icon, when the icon is larger than
the
> > string.
> >
> > -Randy
> >
> >
> > "Barry Andrews" <bandrews@nospam_bphnx.com> wrote in message
> > news:csh5lj$7he$1@www.eclipse.org...
> >
> >>Ok, if I use setLabelAlignment(), it works. But what does that mean? The
> >>docs say "Sets the Label's alignment to the passed value." Ok, that's
> >>nice, but what does it mean? What does it align to? I am interested in
> >>positioning the text within the label, so I would presume to use the
> >>setTextAlignment() method. This is very confusing!
> >>
> >>Barry
> >>
> >>
> >>
> >>Brian Fernandes wrote:
> >>
> >>>Barry,
> >>>
> >>>I only suggested changing the background color as a means of verifying
> >>>that your label is indeed wider than it's text, not as a fix for the
> >>>problem.
> >>>
> >>>If you haven't already, please look at the javadoc for Label -
> >>>setTextAlignment and setLabelAlignment methods. Might find some answers
> >>>there.
> >>>
> >>>All the best,
> >>>Brian.
> >>>
> >>>
> >>>D
> >>>Barry Andrews wrote:
> >>>
> >>>
> >>>>Thanks for the reply. No, the label is much wider than the text. I
also
> >>>>tried changing the background to be different than the parent's color
> >>>>and it makes no difference.
> >>>
> >>>
> >>>>If I don't get a resolution pretty soon, I will just assume a bug and
> >>>>log it. I can't imagine that my code is wrong. Aligning text should be
> >>>>straight forward.
> >>>
> >>>
> >>>>thanks,
> >>>
> >>>
> >>>>Barry
> >>>
> >>>
> >>>
> >>>>Brian Fernandes wrote:
> >>>>
> >>>>
> >>>>>Barry,
> >>>>>
> >>>>>I haven't tried this, but it is possible that your Draw2D Label is
only
> >>>>>as large as the text it contains (Therefore the text alignment won't
> >>>>>make a difference).
> >>>>>It is likely that the Draw2D Label itself is center aligned in it's
> >>>>>parent figure giving you the impression that the text it contains is
> >>>>>center aligned.
> >>>>>
> >>>>>A simple way to check this out is to set the background color of the
> >>>>>Label to be different from the background color of it's parent.
> >>>>>
> >>>>>Hope this helps,
> >>>>>Brian.
> >>>>>
> >>>>>
> >>>>>
> >>>>>Barry Andrews wrote:
> >>>>>
> >>>>>
> >>>>>>Hi,
> >>>>>
> >>>>>
> >>>>>
> >>>>>>I have the following code in an edit part:
> >>>>>
> >>>>>
> >>>>>
> >>>>>>protected IFigure createFigure()
> >>>>>> {
> >>>>>> Label model = (Label) getModel();
> >>>>>> org.eclipse.draw2d.Label label = new
> >>>>>>org.eclipse.draw2d.Label(model.getText());
> >>>>>> label.setOpaque(true);
> >>>>>> label.setBackgroundColor(new
> >>>>>>Color(null,model.getBackgroundColor()));
> >>>>>> label.setForegroundColor(new
> >>>>>>Color(null,model.getForegroundColor()));
> >>>>>> label.setFont(model.getFont());
> >>>>>
> >>>>>
> >>>>>
> >>>>>> label.setTextAlignment(PositionConstants.LEFT);
> >>>>>
> >>>>>
> >>>>>
> >>>>>> return label;
> >>>>>> }
> >>>>>
> >>>>>
> >>>>>
> >>>>>>I would expect the text to be left justified when I see the Label in
> >>>>>>the editor, but it's not. It's always in the center. It's the same
> >>>>>>with PositionConstants.RIGHT. Am I missing something here, or is
this
> >>>>>>a bug? Can someone else please try it? I am using 3.1M2.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>many thanks,
> >>>>>
> >>>>>
> >>>>>
> >>>>>>B
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >
|
|
|
Goto Forum:
Current Time: Tue May 13 16:08:24 EDT 2025
Powered by FUDForum. Page generated in 8.44879 seconds
|