Results 1 to 8 of 8
Thread: rendering question
- 05-20-2012, 02:05 AM #1
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
- 05-20-2012, 02:35 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,537
- Rep Power
- 11
Re: rendering question
In problems like this it is generally a good idea to to get the logic of the program solid (compiles,runs and passes your comprehensive tests so you're sure it is valid) before optimising things. The last thing you want is to be dealing with tricky painting code if the underlying stuff you are painting is buggy in some way.
The effectiveness of the improved painting code will (like the proverbial pudding) be seen only once you have written it and measured the effect.
-----
That's not to say that someone here can't look at how you are painting and suggest something. (In my limited experience speedup will be associated with some *simplification* of the code.) But for that to happen you will have to post the code that you are using to paint. Others may be familiar with this "falling sands game", but I'm not. Code should compile and run, but be free from dependencies on other aspects of the program - no-one wants to wade through hundreds of lines of code to examine 20 or so that deal with painting. That is, the data you are painting should be "mocked" in some way: supplied to the painting code in some simple way like an array, but resembling the actual data that would arise as your program runs (having realistic "clumping" properties for instance).
- 05-20-2012, 06:22 AM #3
Re: rendering question
This one didn't bother to return to the first thread started, not even to thank Norm.
affecting other classes
I don't really expect any better behavior here.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-21-2012, 11:41 PM #4
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Re: rendering question
Sorry, This is the first time I've checked back. As for my draw code, here it is:
for(int i=0;i<width;i++){
for(int n=0;n<height;n++){
if(map[i][n]!=lmap[i][n]){
g.setColor(inf.getCol(map[i][n]));
g.fillRect(i*size, n*size, size, size);
}
}
}
width and height are the total number of cells, size is the size of each cell. g is the graphics 2d. Map[][] is what im drawing, it stores an int in each cell, and each int represents a different type of cell. inf.getCol(...) returns the color for each type of cell. lmap[][] is the map from the last refresh, i use it so that I can draw only the cells that have changed.
Is there any quick way for me to detect groups of cells of the same type that are in a rectangle?
- 05-22-2012, 04:10 AM #5
Re: rendering question
Why do they call it rush hour when nothing moves? - Robin Williams
- 05-24-2012, 12:19 AM #6
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Re: rendering question
what?
- 05-24-2012, 12:44 AM #7
Member
- Join Date
- May 2012
- Location
- USA
- Posts
- 38
- Rep Power
- 0
Re: rendering question
He wants you to put code tags around your snippet.
As for the original topic itself, I apologize that I am unable to assist. I am just beginning Java.Java Code:for(int i=0;i<width;i++){ for(int n=0;n<height;n++){ if(map[i][n]!=lmap[i][n]){ g.setColor(inf.getCol(map[i][n])); g.fillRect(i*size, n*size, size, size); } }
- 05-24-2012, 01:26 AM #8
Member
- Join Date
- May 2012
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
Rendering HTML???
By jspexception in forum NetworkingReplies: 29Last Post: 01-30-2012, 08:28 AM -
Android PDF Rendering
By iankitshah in forum AndroidReplies: 0Last Post: 08-17-2011, 06:18 AM -
Problem in JSP rendering
By srkumarj2ee@gmail.com in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-27-2009, 02:02 AM -
Help with JTable rendering
By daniel2008 in forum AWT / SwingReplies: 8Last Post: 01-18-2009, 03:51 AM -
JLabel Rendering
By random4534 in forum New To JavaReplies: 3Last Post: 12-16-2008, 08:55 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks