• Post Reply Bookmark Topic Watch Topic
  • New Topic

Quick way of drawing LED style text?

 
Al Hollis
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AS above really. Is there a quick way of converting letters to look like LED style ticker system. At the moment i just use a JLabel which i update using setText. It would give my fruit machine application more realism (excuse pun). Had a look on google but i couldnt find any thing really helpful so thought i would ask here.

Thanks in advance

Alan
 
Campbell Ritchie
Marshal
Posts: 52589
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try looking for a font on your computer; I tried and don't have one.
You can try the java.awt.GraphicsEnvironment.getAvailableFontFamilyNames() method
which returns a String[] array. Try printing text on your screen in every font available.
Shouldn't take more than 10 minutes to run. But I don't think you will find anything.

You want a font where 8 looks like this, I presume:-

_
|_|
|_|.

Go and find a basic hardware book and see whether it has the boolean formulas for an LED display in. It will come out something
like this:-
  • 1: Number the different parts of the display; there are 7 of them.

  • A
    BCD
    EFG.
  • 2: Get each digit and get boolean values eg is0, is1, is2 . . . is 9.

  • Also for the segments "boolean segA, segB, segC, etc;".
  • 3: You need a formula for each of the segments:-

  • In the book it will read A = (in0 + in2 + in5 + in6 + in7 + in8 + in9).
    In Java that comes out more like:
    segA = is0 || is2 || is5 || is6 || is7 || is8 || is9;
    segB = is0 || is4 || is5 || is6 || is8 || is9;
    etc etc etc.
  • 4: Back to Java. Draw the individual lines.

  • if(segA) g.drawLine(50, 10, 100, 10);
    if(segB) g.drawLine(45, 15, 40, 60);
    etc etc etc.
  • 5: If you want several digits, produce an LEDPanel extends JPanel class for each of them.
  • 6: Check carefully what mistakes I have made in writing out the segments.

  • Hope this is of some use to you.

    CR
    [ May 13, 2006: Message edited by: Campbell Ritchie ]
     
    Al Hollis
    Ranch Hand
    Posts: 60
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you very much.. I shall look into it tomorow after sleep
     
    Michael Dunn
    Ranch Hand
    Posts: 4632
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    borrowed from 74philip at sun's forums

     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!