Automatic repainting..

Moderatoren: crack, Krüsty, Marwin

Beitragvon Ignat » Mittwoch 12. November 2003, 19:50

Hi, people!
I need help!
I have simple programm that paints polygons on Panel using coordinates from database..
It takes a lot of time.
BUT if another window is puted on my programm and the "went" out, the image deleted!
How to make my programm automatic repainting not using database (its too long). I want SYSTEM only to redraw picture on Panel.
May be I should set some property?
If the ship don't know where to go - it has no fair wind...
Ignat
Alter Hase
 
Beiträge: 80
Registriert: Samstag 2. August 2003, 11:13

Beitragvon Marwin » Freitag 14. November 2003, 17:57

Hi Ignat :)

Ive searched but I found nothing until now. What is too slow, the painting-routine or the database querys? If the last one is the problem you could fetch the coordinates one time to save them in an array. After this you read the data every time from this array. If the first point is the problem, then try to save to created picture in an array (or something else, in Basic I do this by using an array :P. Maybe there is a better data type in Java.). Then, if the paint-method is invoked you just draw the saved picture to your Panel.

Marwin
Benutzeravatar
Marwin
Moderator
 
Beiträge: 307
Registriert: Donnerstag 8. Mai 2003, 21:19
Wohnort: Seelow, Deutschland

Beitragvon Ignat » Freitag 14. November 2003, 18:21

Hi, Marwin!
I have the last problem - database queries - it takes too many time..
I cannt save all data in array - I have nearly 150.000 records (points of polygons..) - I cannt use so many memory.. :(
If the ship don't know where to go - it has no fair wind...
Ignat
Alter Hase
 
Beiträge: 80
Registriert: Samstag 2. August 2003, 11:13

Beitragvon Marwin » Samstag 15. November 2003, 17:27

Well, then try to save to created picture in memory (I mean every pixel). Is this possible?

Marwin
Benutzeravatar
Marwin
Moderator
 
Beiträge: 307
Registriert: Donnerstag 8. Mai 2003, 21:19
Wohnort: Seelow, Deutschland

Beitragvon Ignat » Sonntag 16. November 2003, 23:06

I found the way. I have to use Buffered Image (something like Marwin suggested me..)
Code: Alles auswählen
BufferedImage image = new BufferedImage(width, height, imageType);
Graphics graph = image.createGraphics();
drawImage(graph);
...
//in paint method:
public void paint(Graphics g) {
 g.drawImage(image, 0, 0, null);
}

I hope itll work.. :)
If the ship don't know where to go - it has no fair wind...
Ignat
Alter Hase
 
Beiträge: 80
Registriert: Samstag 2. August 2003, 11:13


Zurück zu Java

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder

cron