Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Preformans boost needed!!!  RSS feed

 
Jimmy Nilsson
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!

I have two JPanel with JScrollPanes, i am overriding the paint mothod on this JPanel and then i takes the Graphics obj and paint out text and lines on the JPanel. After the page is finish i set the setPreferredSize so i can scroll to see the howl dokument.

The text is saved in one string and the color is saved in one string

TextStr = "Hey is this right?"
MarkStr = "000011000000444442"

And to fasten this upp so i dont have to go throw char by char i only do this the first time. This first time im saving down the paint areas in an array with its position(where on the screan it will be printed).

In this case it is
Array[0] = "Hey "
Array[1] = "is"
Array[2] = " this "
Array[3] = "right"
Array[4] = "?"

And in the second time i am int the pint method i am just paiting all that the array have. So i dont have alot of loops that checks every char and what color it would have to be.

This inproves the preformance when scrolling in the dokument, but not as good as i hade hope.

the strange thing is that i have tryed to skip the drawing to the pane the second time, and it lookt like the JScroolPane is taken care of this, so i dont have to go to this array every time it have to be redrawn.

Now i need it to be even faster.

Do you have any ide how i could fasten this up? i realy need it to paint faster, its still lagging on my machin, and it will lagg alot mor on the system it will be runned leter on.

Maby it helps to just JTextPane ?? it have not problems to draw the lines and so on, but it simes like the Text is taking alot of preformance.

I have tryed to use JTextPane but then the JScrollPane will not work at all?

Best Regards
Jimmy
 
Jimmy Nilsson
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have now tested the JTextPane some, i added alot of Text in setText(String) and this works well, no preformance problem.

Now is the question how i could use this to my system, i realy have to position out the text as fast as posible, and if i use JTextPane.setText(String) i dont realy know how to do this.

I need to position the Text on a searten position and if i have got this right the JTextPane haves a dynamic system that depends on the JTextPanes size. if the text is not fitted it falls down to the next row, but i cant have this becourse i will dra drawings that have to fit to the text.

Ples help, is there any way to position text and get a good preformance?

I have looked att StyledDocument but i cant se any use of this, it have the sam problem with the dynamic system(the words that dont fitt horizontal falls down to the next row, and i cant position things)

if you got any ides, ples help

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