[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Re: Q: Rotated labels, layout and reflow
From:       Tom Eugelink <tbee () tbee ! org>
Date:       2018-12-19 9:14:12
Message-ID: 8d648ce2-7bea-0911-8074-8a1b70d02e40 () tbee ! org
[Download RAW message or body]

Hey John,

Is VerticalLabel implementation good enough to add to any of the open source \
projects?

Tom


On 19-12-2018 09:55, John Hendrikx wrote:
> Update.
> 
> I did an attempt to add this functionally to Label itself, by editing \
> LabeledSkinBase, and with a few minor modifications (mainly swapping width/height \
> variables in a few places), I managed to get this to work. 
> Creating my own control wasn't really possible as the LabeledSkinBase is using text \
> measurement methods that aren't public API so far, and which I would also need for \
> a vertical label, so these changes had to be done directly in LabeledSkinBase. 
> However, I found an acceptable work-around as well, extending upon the idea of how \
> Group works.   Wrapping a Label into a Pane, swapping all its compute*Width/Height \
> methods to call the opposite version, and making sure ContentBias is set to \
> Vertical, and you can get a working label that reflows correctly while being \
> rendered vertically. 
> I posted a sample on StackOverflow here: \
> https://stackoverflow.com/questions/16921495/javafx-rotate-label-issue/53847417#53847417
>  
> --John
> 
> 
> On 15/12/2018 12:17, John-Val Rose wrote:
> > Yes, you are absolutely right John and again I'm sorry that I did not initially \
> > see the relevance of your question for this list. 
> > I do now and I like your ideas :-)
> > 
> > > On 15 Dec 2018, at 22:06, John Hendrikx <hjohn@xs4all.nl> wrote:
> > > 
> > > 
> > > I asked here because, although not a bug, it may be a good feature to support \
> > > -- and I was looking for confirmation that this really isn't currently \
> > > possible.   It's not a bug because a rotation transform is expected to not \
> > > change the layout bounds.   Making use of Group fixes the layout bounds but \
> > > makes it impossible to do proper dynamic layouts with labels that have been \
> > > rotated 90 degrees. 
> > > Questions similar like this one, without good resolutions, show up on forums \
> > > and stackoverflow, and, looking at the bug database, I think even some of the \
> > > graph components part of JavaFX that support rotated labels have similar layout \
> > > problems when texts needs to be cut-off or reflowed in such labels. 
> > > I even looked at MigLayout already, and noticed a similar issue reported there \
> > > where rotated labels are not handled properly, probably because the layout \
> > > bounds don't take the rotation into account, which no doubt MigLayout relies on \
> > > to do its thing. 
> > > Now, I would love to contribute a fix for this (I contributed some small things \
> > > before), however I think this might be a tough issue to resolve. The way I see \
> > > it, this cannot be solved without Label taking the rotation into account itself \
> > > and providing proper layout bounds -- this is needed because Label decides if \
> > > text reflow needs to occur depending on where it is placed, and this \
> > > information is lost when it is put in a Group. 
> > > So I think Label(ed) would need a new Rotate property, which only supports 0, \
> > > 90, 180 and 270 degrees, or perhaps an extension to the text direction property \
> > > (left-right, right-left, top-down, down-top), but I think that it serves a \
> > > different purpose that is independent from rotation. 
> > > With this extra information, Label can then do the proper layout calculations \
> > > with potential reflow of text and provide correct layout bounds.   The actual \
> > > text rendering would also need to be rotated somehow, and I'm not quite sure \
> > > how that would be accomplished yet for Labels. 
> > > All in all, it sounds like quite some effort that would need a good design, \
> > > especially since Label already has a short-cut property to add a Rotate \
> > > transform that cannot be re-used for this, so a new property would have to make \
> > > the difference very clear. 
> > > --John
> > > 
> > > > On 15/12/2018 09:18, Tom Eugelink wrote:
> > > > It's a bit grey. If this goes towards a bug in the layout, it could be
> > > > considered OpenJFX development. It could also go towards a patch,
> > > > because instead of using Canvas I would suggest (John) to look at the
> > > > HBox and see if you can figure out why it is not doing what you want.
> > > > And if that is too complex; write a layout that does this, and
> > > > contribute it to OpenJFX, ControlsFX or JFXtras. (I believe OpenJFX also
> > > > is the sum of all the extending libraries, not making the suck-it-all-in
> > > > mistake Java made.) The layout logic should be similar to when doing it
> > > > in Canvas, only reusable.
> > > > 
> > > > Also I have found that when rotating is involved, a lot of layouts do
> > > > not what you expect them to do. Have you given MigLayout a try? It
> > > > sometimes has surprising results (both positive and negative) ;-)
> > > > 
> > > > 
> > > > 
> > > > 
> > > > > On 15-12-2018 03:14, John-Val Rose wrote:
> > > > > My feedback would to ask this kind of question on a more appropriate
> > > > > list or forum.
> > > > > 
> > > > > I believe this list is exclusively to discuss issues related to the
> > > > > development of OpenJFX itself.
> > > > > 
> > > > > Graciously,
> > > > > 
> > > > > John-Val
> > > > > 
> > > > > > On 15 Dec 2018, at 12:50, John Hendrikx <hjohn@xs4all.nl> wrote:
> > > > > > 
> > > > > > 
> > > > > > (Sent this twice, first message got sent prematurely)
> > > > > > 
> > > > > > Hi list,
> > > > > > 
> > > > > > I get the impression that rotation of Labels needs to be something
> > > > > > that is directly supported by Label instead of handling this with a
> > > > > > Rotate transform (setRotate).
> > > > > > 
> > > > > > I want to achieve something quite trivial if no rotation was
> > > > > > involved, a layout like this, an HBox with 3 labels in it:
> > > > > > 
> > > > > > +-HBox------------------------------------------------------------+
> > > > > > > > Long text that can reflow to multiple |                       |
> > > > > > > Short Text | lines if needed...                                       | \
> > > > > > > Short Text |
> > > > > > > > > > 
> > > > > > +-----------------------------------------------------------------+
> > > > > > 
> > > > > > The center label would be given grow Priority.ALWAYS.
> > > > > > 
> > > > > > Now... the rotated version just goes wrong in so many ways.
> > > > > > 
> > > > > > First, I need to use Groups in order to get the layout bounds
> > > > > > reasonable... however, these are unaware of how much space is
> > > > > > available and will kill the reflow in the center Label.
> > > > > > 
> > > > > > If I put a Group around the whole HBox, the same issue occurs as the
> > > > > > Group blocks any awareness of how big the area is where the three
> > > > > > labels are going to appear, effectively rendering the center label as
> > > > > > one long line.
> > > > > > 
> > > > > > What I'm actually trying to achieve is a layout that looks like this:
> > > > > > 
> > > > > > +----+-------------------+
> > > > > > > T |                                     |
> > > > > > > e |                                     |
> > > > > > > x |                                     |
> > > > > > > t |                                     |
> > > > > > +----+                                     |
> > > > > > > > > 
> > > > > > > T |                                     |
> > > > > > > e |             Image             |
> > > > > > > x |                                     |
> > > > > > > t |                                     |
> > > > > > > > > 
> > > > > > +----+                                     |
> > > > > > > T |                                     |
> > > > > > > e |                                     |
> > > > > > > x |                                     |
> > > > > > > t |                                     |
> > > > > > +----+-------------------+
> > > > > > 
> > > > > > Except of course the left area should be the rotated HBox.
> > > > > > 
> > > > > > Is this really not possible at the moment, without using a Canvas or
> > > > > > something and a lot of layout calculations (to get reflow working)?
> > > > > > 
> > > > > > Any feedback appreciated :)
> > > > > > 
> > > > > > --John
> > > > 
> > > > 
> > 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic