Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3888
| From | "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: fontrendercontext wit |
| Message-ID | <nospam-855423.15315104082008@aioe.org> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <48971a6d$1@news.uni-rostock.de> |
| Date | 2011-04-27 15:47 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui In article <48971a6d$1@news.uni-rostock.de>, Stefan Rybacki <noemail@noemail.foobar> wrote: > Hi, > > I'm trying to write my own tooltip UI. Hence I have to implement a > getPreferredSize method. I use the LineBreakMeasurer and TextLayout > and its getBounds method. > But to create a TextLayout or LineBreakMeasurer I need a > FontRenderContext which is usually obtained from the graphics > context. Which unfortunatelly is not yet available at the time > getPreferredSize is called. > So is there another way to get the tooltips graphics context or at > least its FontRenderContext? Just make a new one FontRenderContext frc = new FontRenderContext(null, false, false); which uses the identity transform. Then get the logical size with Font#getStringBounds(String, FontRenderContext); Later at draw time, use it to construct a new TextLayout layout = new TextLayout(String, Font, FontRenderContext); MOve and fill the boundary with a nice, pale tool tip color, set the foreground to something with a high contrast, and call layout.draw(Graphics2D, Float, Float); -- John B. Matthews trashgod at gmail dot com home dot woh dot rr dot com slash jbmatthews --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread
Re: fontrendercontext wit "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
csiph-web