Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: Is the API of JavaFX pixel-based? Date: Tue, 03 Feb 2015 10:59:40 -0500 Organization: A noiseless patient Spider Lines: 51 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 3 Feb 2015 16:02:54 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="c50a9e5d554cfaba13eda1c71e805135"; logging-data="27090"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ku4raIbIIv4mpPY3EhuJa54VG/ZwEB1o=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0 In-Reply-To: Cancel-Lock: sha1:iijlRhhgRSea8W2aKLTXfU5tpFw= Xref: csiph.com comp.lang.java.programmer:31031 On 02/03/2015 10:16 AM, Stefan Ram wrote: > Jeff Higgins writes: >> Can you point to the specific tutorial you mention? > > I refer to code like: > > Scene s = new Scene( r, 360, 120, Color.rgb( 0, 0, 0, 0 )); > > . It is not obvious how the author arrived at those > values »360« and »120«. > > The Scene contains some text fields stacked one above > the other. What I would prefer instead would be a call > like: > > Scene s = new Scene( r, Color.rgb( 0, 0, 0, 0 )); > > The textfields would have a default font that is > readable (but not excessively high as in a heading). > Symbolic constants are Ok, like »PARAGRAPH_FONT«, > »HEADING_FONT«. > > The pixel height of that default font depends on the > run-time environment and does not have to be known > to the programmer. Then, the height of the textfield > would be adjusted to the height of this font, while > the width is given by the programmer in »m«s (»10« > means, wide as 10 »m« letters in that font). > > The width and height of all the containers and, > ultimatively of the scene, is calculated bottom-up > from those values. They are not known to the > programmer, because they are calculated as late > as run time. > > In programming, we were taught early to avoid > »magic constants« in source code (such as »360« > above). More so, in my opinion, we should especially > avoid »magic pixel values« in source code. A good program > will not set a fixed pixel height for a font, but > adjust to the font height that is natural (readable) > on a device and will only be known as late as at run time. > This is all achievable with JavaFX as with any GUI APIs that I'm familiar with. It may not be "out of the box" behavior. Can you point to a GUI API with such default behavior? My Kindle displays HTML pretty nicely, as does my browser, but I don't know what the source code looks like.