You Are Here:

Community: Developer Discussion Boards

#1 Old image in canvas - 2003-07-22, 16:10

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
I just moved from "Forms" to Canvas and I wonder how I add an Image to a Canvas so it will be displayed on the phone....
Reply With Quote

#2 Old 2003-07-22, 17:03

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
Code:
public void paint(Graphics g) {
  g.drawImage(myBackgroundImage,0,0,Graphics.TOP|Graphics.LEFT);
  // the rest of the painting code
}
shmoove
Reply With Quote

#3 Old 2003-07-23, 06:36

Join Date: Apr 2003
Posts: 117
Location: Bangalore
Send a message via AIM to chandu_bgm Send a message via Yahoo to chandu_bgm
chandu_bgm
Offline
Regular Contributor
Hi,

Use paint(Graphics g) Method.

and as per your req use repaint method.

Regards

Chandu
Reply With Quote

#4 Old 2003-07-23, 08:58

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
What is the relation between paint and repaint
Reply With Quote

#5 Old 2003-07-23, 09:38

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
zivgr
paint() is called by the phone, when it thinks that image should update.

repaint() is called by you and makes phone think so :)
Reply With Quote

#6 Old 2003-07-23, 09:41

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
Thanks for your reply...
So the phone only call paint() if I call repaint?
What are the situations in which paint() is called?
Reply With Quote

#7 Old 2003-07-23, 09:57

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
zivgr
You should read documentation. It's not that simple question.

Generally you are right, phone calls paint(), when you call repaint(), but there are some details, like phone actually cals paint(), when it has time, you can force it by calling serviceRepaints, etc.
Reply With Quote

#8 Old 2003-07-23, 10:25

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
Thanks.
How can I have in Canvas the same text wrapping functionality that there is in Forms?
Does someone have a piece of code that does thais task?
Reply With Quote

#9 Old 2003-07-23, 10:30

Join Date: Apr 2003
Posts: 117
Location: Bangalore
Send a message via AIM to chandu_bgm Send a message via Yahoo to chandu_bgm
chandu_bgm
Offline
Regular Contributor
Hi

Look there are many Situations wher do you want use the paint (),repaint() and/or serviceRepaints().But all depends on for what perpose you are using it...

I mean If you are using that for games the way of doing this are different and for general display of graph its different..

So think of the situation and use the methodes wisely....:)



I hope this will help

Regards
Chandu
Reply With Quote

#10 Old 2003-07-23, 10:50

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
zivgr
How can I have in Canvas the same text wrapping functionality that there is in Forms?

Implemet it yourself. Actually it's not that complex.

Does someone have a piece of code that does thais task?
Yes I've seen an example somewhere in common place. I think it was on Sun's Wireless Developer or here, on Forum Nokia. Check their examples.

However, there was nothing fantastic in those examples - just simple calculation of position, where to wrap.
Reply With Quote

#11 Old Word Wrapping function - 2003-07-23, 11:16

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
And a couple of other useful things:
http://kobjects.org/utils4me/

shmoove
Reply With Quote

#12 Old 2003-07-23, 15:23

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
Thanks!!!
Does someone know whether it is possible to scroll a Canvas as in a Form???
Reply With Quote

#13 Old 2003-07-23, 15:50

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
zivgr
Does someone know whether it is possible to scroll a Canvas as in a Form???

Canvas is called canvas, because it's just a pack of pixels to set values.
You can draw there anything you want, but it's absolutely up to you, whether to implement any extra non-drawing (or keypress handling) functionality.

Of course, for such popular needs as game scrolling there are some usual ways to do it, but anyway you should implement it.

P.S.
I haven't done anything for MIDP 2.0. There are a lot of enhancements for game developers. Maybe there is some standard solution for scrolling also.
Reply With Quote

#14 Old 2003-07-24, 10:37

Join Date: Apr 2003
Posts: 117
Location: Bangalore
Send a message via AIM to chandu_bgm Send a message via Yahoo to chandu_bgm
chandu_bgm
Offline
Regular Contributor
Does someone know whether it is possible to scroll a Canvas as in a Form???




Yes Its possible to scroll .....It can be done by manipulating the Cords..(X-axis,Y-axis).


I hope this may help.

Regards
Chandu
Reply With Quote

#15 Old 2003-07-24, 10:41

Join Date: Apr 2003
Posts: 184
zivgr
Offline
Regular Contributor
Thanks chandu.
Could you please give some more details or a reference, as I'm quite new to the subject.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ