Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Vertical Text (Again)
Vertical Text (Again) [message #217075] Wed, 31 May 2006 22:02 Go to next message
Josh Reed is currently offline Josh ReedFriend
Messages: 38
Registered: July 2009
Member
I was wondering if ImageUtilities.createRotatedImageOfString() works on
Mac OSX (specifically the new Intel Macs). I'm trying to achieve some
vertical text with the following code:

public void validate() {
Dimension dim = FigureUtilities.getTextExtents(
text, JFaceResources.getDefaultFont());
dim.transpose();
setPreferredSize(dim);
}

protected void paintFigure(final Graphics graphics) {
Image foo = ImageUtilities.createRotatedImageOfString(
text, JFaceResources.getDefaultFont(),
ColorConstants.black, ColorConstants.blue);
graphics.drawImage(foo, bounds.getTopLeft());
foo.dispose();
}

When I run the code, the figure takes up the appropriate amount of space
(when I put a really long string in, I get a really tall figure, when I
put a short string in, a short figure). However, I get no text and no
background fill. I don't have a Windows box, so I can't really test if
it is a Mac-only thing.

Since this doesn't work, can someone suggest an alternate approach?

Thanks,
Josh
Re: Vertical Text (Again) [message #217281 is a reply to message #217075] Fri, 02 June 2006 13:26 Go to previous messageGo to next message
Steven R. Shaw is currently offline Steven R. ShawFriend
Messages: 128
Registered: July 2009
Senior Member
Can you log a bugzilla and it can get investigated?

Alternatively, you can try to set a rotation value in your paint routine
using the Graphics#rotate method.

i.e.

protected void paintFigure(final Graphics graphics) {
graphics.push();

graphics.setFont(JFaceResources.getDefaultFont());
graphics.rotate(90.0);
graphics.drawText(text);

graphics.pop();
}

-Steve

"Joshua Reed" <jareed@iastate.edu> wrote in message
news:e5l3pj$g0l$1@utils.eclipse.org...
> I was wondering if ImageUtilities.createRotatedImageOfString() works on
> Mac OSX (specifically the new Intel Macs). I'm trying to achieve some
> vertical text with the following code:
>
> public void validate() {
> Dimension dim = FigureUtilities.getTextExtents(
> text, JFaceResources.getDefaultFont());
> dim.transpose();
> setPreferredSize(dim);
> }
>
> protected void paintFigure(final Graphics graphics) {
> Image foo = ImageUtilities.createRotatedImageOfString(
> text, JFaceResources.getDefaultFont(),
> ColorConstants.black, ColorConstants.blue);
> graphics.drawImage(foo, bounds.getTopLeft());
> foo.dispose();
> }
>
> When I run the code, the figure takes up the appropriate amount of space
> (when I put a really long string in, I get a really tall figure, when I
> put a short string in, a short figure). However, I get no text and no
> background fill. I don't have a Windows box, so I can't really test if
> it is a Mac-only thing.
>
> Since this doesn't work, can someone suggest an alternate approach?
>
> Thanks,
> Josh
Re: Vertical Text (Again) [message #217306 is a reply to message #217281] Fri, 02 June 2006 14:53 Go to previous messageGo to next message
Josh Reed is currently offline Josh ReedFriend
Messages: 38
Registered: July 2009
Member
Thanks for the reply Steven.

Turns out I hadn't put a StackLayout on the containing figure so while
container's size was reflecting the size of the rotated label, the
actual label figure wasn't getting laid out. So when I was doing a

graphics.drawText("Some Rotated Text", bounds.getTopLeft())

nothing showed up because I was drawing somewhere off in wonkyland. I
discovered this quite by accident when I was working up a code snippet
to submit as a bug. It's all working once I set the layout manager or do a

graphics.drawText("Some Rotated Text",
getParent().getClientArea().getTopLeft())

I can't get he snippet you sent to work on Mac OSX for rotation values
other than 0.0f (and I've got my layout manager set this time :) ). I
can file a bug report with an example if it would be helpful.

Thanks,
Josh Reed


Steven Shaw wrote:
> Can you log a bugzilla and it can get investigated?
>
> Alternatively, you can try to set a rotation value in your paint routine
> using the Graphics#rotate method.
>
> i.e.
>
> protected void paintFigure(final Graphics graphics) {
> graphics.push();
>
> graphics.setFont(JFaceResources.getDefaultFont());
> graphics.rotate(90.0);
> graphics.drawText(text);
>
> graphics.pop();
> }
>
> -Steve
>
> "Joshua Reed" <jareed@iastate.edu> wrote in message
> news:e5l3pj$g0l$1@utils.eclipse.org...
>> I was wondering if ImageUtilities.createRotatedImageOfString() works on
>> Mac OSX (specifically the new Intel Macs). I'm trying to achieve some
>> vertical text with the following code:
>>
>> public void validate() {
>> Dimension dim = FigureUtilities.getTextExtents(
>> text, JFaceResources.getDefaultFont());
>> dim.transpose();
>> setPreferredSize(dim);
>> }
>>
>> protected void paintFigure(final Graphics graphics) {
>> Image foo = ImageUtilities.createRotatedImageOfString(
>> text, JFaceResources.getDefaultFont(),
>> ColorConstants.black, ColorConstants.blue);
>> graphics.drawImage(foo, bounds.getTopLeft());
>> foo.dispose();
>> }
>>
>> When I run the code, the figure takes up the appropriate amount of space
>> (when I put a really long string in, I get a really tall figure, when I
>> put a short string in, a short figure). However, I get no text and no
>> background fill. I don't have a Windows box, so I can't really test if
>> it is a Mac-only thing.
>>
>> Since this doesn't work, can someone suggest an alternate approach?
>>
>> Thanks,
>> Josh
>
>
Re: Vertical Text (Again) [message #217314 is a reply to message #217306] Fri, 02 June 2006 16:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Just, the GEF palette is using the same method you are calling. So, if the
palette is working, there is no bug.

"Joshua Reed" <jareed@iastate.edu> wrote in message
news:e5pjdk$1ob$1@utils.eclipse.org...
> Thanks for the reply Steven.
>
> Turns out I hadn't put a StackLayout on the containing figure so while
> container's size was reflecting the size of the rotated label, the actual
> label figure wasn't getting laid out. So when I was doing a
>
> graphics.drawText("Some Rotated Text", bounds.getTopLeft())
>
> nothing showed up because I was drawing somewhere off in wonkyland. I
> discovered this quite by accident when I was working up a code snippet to
> submit as a bug. It's all working once I set the layout manager or do a
>
> graphics.drawText("Some Rotated Text",
> getParent().getClientArea().getTopLeft())
>
> I can't get he snippet you sent to work on Mac OSX for rotation values
> other than 0.0f (and I've got my layout manager set this time :) ). I can
> file a bug report with an example if it would be helpful.
>
> Thanks,
> Josh Reed
>
>
> Steven Shaw wrote:
>> Can you log a bugzilla and it can get investigated?
>>
>> Alternatively, you can try to set a rotation value in your paint routine
>> using the Graphics#rotate method.
>>
>> i.e.
>>
>> protected void paintFigure(final Graphics graphics) {
>> graphics.push();
>>
>> graphics.setFont(JFaceResources.getDefaultFont());
>> graphics.rotate(90.0);
>> graphics.drawText(text);
>>
>> graphics.pop();
>> }
>>
>> -Steve
>>
>> "Joshua Reed" <jareed@iastate.edu> wrote in message
>> news:e5l3pj$g0l$1@utils.eclipse.org...
>>> I was wondering if ImageUtilities.createRotatedImageOfString() works on
>>> Mac OSX (specifically the new Intel Macs). I'm trying to achieve some
>>> vertical text with the following code:
>>>
>>> public void validate() {
>>> Dimension dim = FigureUtilities.getTextExtents(
>>> text, JFaceResources.getDefaultFont());
>>> dim.transpose();
>>> setPreferredSize(dim);
>>> }
>>>
>>> protected void paintFigure(final Graphics graphics) {
>>> Image foo = ImageUtilities.createRotatedImageOfString(
>>> text, JFaceResources.getDefaultFont(),
>>> ColorConstants.black, ColorConstants.blue);
>>> graphics.drawImage(foo, bounds.getTopLeft());
>>> foo.dispose();
>>> }
>>>
>>> When I run the code, the figure takes up the appropriate amount of space
>>> (when I put a really long string in, I get a really tall figure, when I
>>> put a short string in, a short figure). However, I get no text and no
>>> background fill. I don't have a Windows box, so I can't really test if
>>> it is a Mac-only thing.
>>>
>>> Since this doesn't work, can someone suggest an alternate approach?
>>>
>>> Thanks,
>>> Josh
>>
Re: Vertical Text (Again) [message #217329 is a reply to message #217314] Fri, 02 June 2006 18:14 Go to previous message
Josh Reed is currently offline Josh ReedFriend
Messages: 38
Registered: July 2009
Member
Which one?

The ImageUtilities.createRotatedImageOfString() or the Graphics.rotate()
one?

Thanks,
Josh

Randy Hudson wrote:
> Just, the GEF palette is using the same method you are calling. So, if the
> palette is working, there is no bug.
>
> "Joshua Reed" <jareed@iastate.edu> wrote in message
> news:e5pjdk$1ob$1@utils.eclipse.org...
>> Thanks for the reply Steven.
>>
>> Turns out I hadn't put a StackLayout on the containing figure so while
>> container's size was reflecting the size of the rotated label, the actual
>> label figure wasn't getting laid out. So when I was doing a
>>
>> graphics.drawText("Some Rotated Text", bounds.getTopLeft())
>>
>> nothing showed up because I was drawing somewhere off in wonkyland. I
>> discovered this quite by accident when I was working up a code snippet to
>> submit as a bug. It's all working once I set the layout manager or do a
>>
>> graphics.drawText("Some Rotated Text",
>> getParent().getClientArea().getTopLeft())
>>
>> I can't get he snippet you sent to work on Mac OSX for rotation values
>> other than 0.0f (and I've got my layout manager set this time :) ). I can
>> file a bug report with an example if it would be helpful.
>>
>> Thanks,
>> Josh Reed
>>
>>
>> Steven Shaw wrote:
>>> Can you log a bugzilla and it can get investigated?
>>>
>>> Alternatively, you can try to set a rotation value in your paint routine
>>> using the Graphics#rotate method.
>>>
>>> i.e.
>>>
>>> protected void paintFigure(final Graphics graphics) {
>>> graphics.push();
>>>
>>> graphics.setFont(JFaceResources.getDefaultFont());
>>> graphics.rotate(90.0);
>>> graphics.drawText(text);
>>>
>>> graphics.pop();
>>> }
>>>
>>> -Steve
>>>
>>> "Joshua Reed" <jareed@iastate.edu> wrote in message
>>> news:e5l3pj$g0l$1@utils.eclipse.org...
>>>> I was wondering if ImageUtilities.createRotatedImageOfString() works on
>>>> Mac OSX (specifically the new Intel Macs). I'm trying to achieve some
>>>> vertical text with the following code:
>>>>
>>>> public void validate() {
>>>> Dimension dim = FigureUtilities.getTextExtents(
>>>> text, JFaceResources.getDefaultFont());
>>>> dim.transpose();
>>>> setPreferredSize(dim);
>>>> }
>>>>
>>>> protected void paintFigure(final Graphics graphics) {
>>>> Image foo = ImageUtilities.createRotatedImageOfString(
>>>> text, JFaceResources.getDefaultFont(),
>>>> ColorConstants.black, ColorConstants.blue);
>>>> graphics.drawImage(foo, bounds.getTopLeft());
>>>> foo.dispose();
>>>> }
>>>>
>>>> When I run the code, the figure takes up the appropriate amount of space
>>>> (when I put a really long string in, I get a really tall figure, when I
>>>> put a short string in, a short figure). However, I get no text and no
>>>> background fill. I don't have a Windows box, so I can't really test if
>>>> it is a Mac-only thing.
>>>>
>>>> Since this doesn't work, can someone suggest an alternate approach?
>>>>
>>>> Thanks,
>>>> Josh
>
Previous Topic:DirectEditAction.calculateEnabled selection is always empty.
Next Topic:How to disable an GEF editor
Goto Forum:
  


Current Time: Fri Apr 19 03:22:03 GMT 2024

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

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

Back to the top