Skip to main content

About the JXLabel

3 replies [Last post]
Joined: 2006-11-30

I was making some tests about it and... Well, I just identified another problem, now about the alignments...

Well, when I first did the old code I had to return different values of the alignments, depending if it's painting or not. Because the alignment turns with the text. That was another reason that I just let four options for the rotation. Because, doing this, it's easier to align the text. But, when the user could set any rotation, it gets a little more complicated.

The thing is... Well, imagine a rectangle inside another one. When you rotate the inside one, the alignment will never be like it's supposed to be, because the alignment turns with that rectangle...

So... I think that the sizes has to be reduced to the minimum and the alignment has to be controlled by the x and y of the rotation... I mean:

g2d.translate(x, y);

It will need a lot of calculations (sin, cos, etc)... So, I think that there're a lot of work to do. :^)

So, I'm going to be on vacation for the next month, but my computer comes with me and I'm going to post here every time that I have something new. ;^)

Message was edited by: mario_cesar

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-05-26

What you want to do there (ideally) is to change the Renderer that is responsible for laying the characters so its boundary is not a rectangle, but whatever shape you currently have. The View interface already supports boundary to be Shape, but implementation itself supports Rectangle only. By changing this piece you no longer need to calculate rotated Rectangle inside of the label bounds but can lay text all over it.

Joined: 2003-06-12

Some of the code I contributed might serve as a basis for such text layouts. It can flow text within arbitrary shapes, columns and with knockouts for overlapping shapes and rotation. The code is in the incubator at and there is some background description at: for some background information.

Joined: 2006-11-30

Hmmm... I see..

Well, I don't exactly know how to do that, but I'm going to search about that.

But, anyway... I was thinking that it would be possibly only if we print the text and the icon on a rotated BufferedImage, instead of rotate the hole JLabel... But I think that your idea is a better way to do that...