Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1244

Re: Automatically resize

From "bcd" <bcd@THRWHITE.remove-dii-this>
Subject Re: Automatically resize
Message-ID <etothg$v4n$1@orkan.itea.ntnu.no> (permalink)
Newsgroups comp.lang.java.gui
References <1174393441.687014.66540@n59g2000hsh.googlegroups.com>
Date 2011-04-27 15:32 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
In article <1174393441.687014.66540@n59g2000hsh.googlegroups.com>,
 <larkmore@aol.com> wrote:
>Thanks Andrew, but I kind of hoping there would be something a little
>simpler.  I've already looked at the FontMetrics as described in my
>first post.  If I use that, I would have to:
>
>1) Figure out which string is the widest and tallest of all possible
>strings.  I'm betting it's likely 88:88:88 but to be safe, I'd have to
>check all of them for a given font.  Some weird font might make
>11:11:11 really wide.

If you draw the time as one single string (e.g. "12:34:56") as opposed
to drawing each single digit (and JLabel used in the straight-forward
manner would do the former) then you may also risk (weird) fonts
having compound glyphs (or whatever the technical term is) of pairs of
digits that are wider than twice the width of any one of the digits
involved.

E.g., the string "17" may draw wider than "11" _and_ wider than "77".

(Perhaps this is impossible - I don't know too much about font design
- but I wouldn't bet on it.)

To support this general case, you would have to measure the size of
all possible times from 00:00:00 to 23:59:59.


The alternative is to draw each digit separately. You then only have
to measure the size of each of the digits and you can position them as
you see fit to give the impression of them all staying in the same
place as the clock ticks along (which would also avoid any problems
you might otherwise get with proportional width fonts).

Cheers
	Bent D
-- 
Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd
                                    powered by emacs

---
 * 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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Automatically resize font "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: Automatically resize "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: Automatically resize "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
      Re: Automatically resize "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
        Re: Automatically resize "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
          Re: Automatically resize "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
      Re: Automatically resize "bcd" <bcd@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
        Re: Automatically resize "John W. Kennedy" <john.w..kennedy@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000

csiph-web