AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple GUI application attempted.

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
flesh_eating_dragon
Guest





PostPosted: Fri Jul 23, 2004 12:13 pm    Post subject: Simple GUI application attempted. Reply with quote



Some assistance in the development of a simple GUI application would
be appreciated.

Not long ago I completed a computer science degree, and right now I
want to get a bit more experience and confidence by trying to write
applications that are just a bit beyond what I had to write at
university. However, in the early stages of designing the application
that I have in mind, I have hit a brick wall. I can't write it the way
that I thought at first would work, because of the ColorModel classes
having no 'set' methods, so I'd like to know what _will_ work.

Please imagine the following scenario (this is not a description of
the application, but it is a simpler illustration of the same
problem). Suppose you are writing a graphical application that
simulates a digit on a traditional LCD display, as for example on
a handheld calculator. This should be achievable using a Raster that
encodes something akin to the following:

011110
200003
200003
044440
500006
500006
077770

and a changeable ColorModel, in which 0 always represents the
BACKGROUND colour and the other indexes 1 to 7 represent colours that
we will call ON and OFF. For example, if the digit to be displayed is
"4", then indexes 2, 3, 4 and 6 will be set to represent colour ON
whilst indexes 1, 5 and 7 will be set to represent colour OFF.
Similarly, if the digit to be displayed is "3", then indexes 1, 3, 4,
5 and 7 will represent ON and indexes 2 and 6 will represent OFF.

It would be nice if the ColorModel classes had 'set' methods, because
then you could make the relevant class (let's call it
DigitDisplayImage) a subclass of Image, and the rest would be elegant
and easy. But it doesn't, although I feel there _should_ be a similar
solution. Then you could write setIndex(int, Color) methods in the
DigitDisplayImage class, after which the following code example would
work to display the digit "4".

digitDisplay.setIndex(1, OFF);
digitDisplay.setIndex(2, ON);
digitDisplay.setIndex(3, ON);
digitDisplay.setIndex(4, ON);
digitDisplay.setIndex(5, OFF);
digitDisplay.setIndex(6, ON);
digitDisplay.setIndex(7, OFF);

This would be lovely.

In the absence of ColorModel classes with 'set' methods, how, in
practise, should I go about achieving a similar functionality? (In the
real application, the corresponding object needs a lot more than eight
index values and will be called upon to display far more than just
digits between 0 and 9, but I think it is better to discuss the
problem with reference to this simplified example.)

Thanks,

Adrian.
Back to top
Roedy Green
Guest





PostPosted: Fri Jul 23, 2004 6:11 pm    Post subject: Re: Simple GUI application attempted. Reply with quote



On 23 Jul 2004 05:13:05 -0700, [email]dragon (AT) netyp (DOT) com.au[/email]
(flesh_eating_dragon) wrote or quoted :

Quote:
digitDisplay.setIndex(1, OFF);
digitDisplay.setIndex(2, ON);
digitDisplay.setIndex(3, ON);
digitDisplay.setIndex(4, ON);
digitDisplay.setIndex(5, OFF);
digitDisplay.setIndex(6, ON);
digitDisplay.setIndex(7, OFF);

Surely you can change the index colour map as a whole? You could then
have premade maps for each of the digits, then blast that map in.
Do you pass just a reference to the map in? Perhaps it is kosher to
change the map on the fly AFTER you have given it to the colour model.

However, under the covers someone is going to have to convert that
indexed map to the actual bit map. It would probably be more
efficient just to have premade images of the digits in full colour.

In practice, you might design or find a font with the LCD digits.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Back to top
flesh_eating_dragon
Guest





PostPosted: Sat Jul 24, 2004 1:43 am    Post subject: Re: Simple GUI application attempted. Reply with quote



Roedy Green wrote:

Quote:
Surely you can change the index colour map as a whole? You could then
have premade maps for each of the digits, then blast that map in.
[...]
However, under the covers someone is going to have to convert that
indexed map to the actual bit map. It would probably be more
efficient just to have premade images of the digits in full colour.

Yes, that approach would probably work. Mind you, in reality the
number of premade images will be closer to fifty than to ten.

Adrian.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.