• Post Reply Bookmark Topic Watch Topic
  • New Topic

Gui based graphical bit pattern Analyzer  RSS feed

 
faisal siraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to develop a GUI based application.This application displays bits for the underlying characters.For example we have 8 characters in a file.This application will display bits for each character.i have drawn rectangles to show either one or zero bits.I have used jtextarea for displaying these bits in the JTextarea.But my problem is that it only display a file up to 1.4 MB file length.If a display more than this size,the drawing becomes very slow.I just want to know is there any method that can help in resizing virtual memory or else what should i do
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would only display a certain portion of the file (say 20 or 30 lines - thats up to you) and only load the the parts that is currently being displayed. You can also have buffers, i.e. load 30 lines before your displayed bit, and 30 lines after, so that scrolling is faster.

.........
......... --- your "pre"-buffer
.........
+++++ |
+++++ |--- this part is displayed on screen
+++++ |
.........
......... --- your "post"-buffer
.........

If the user scrolls down 2 lines, you quickly display the lines from memory:

......... X these lines you dump from memory
......... X and overwrite with
......... ] these lines
+++++ ] over here
+++++ ] conveniently still in memory
+++++ |
......... |--- this part is displayed on screen (viewport)
......... |
......... - this line is still in the "post"-buffer
nnnnn ] these are the only lines
nnnnn ] you need to read from file

similar if you want to scroll up:

nnnnn ] these are the only lines
nnnnn ] you need to read from file
......... - this line is still in your "pre"-buffer
......... |
......... |--- this part is displayed on screen
+++++ |
+++++ ] these lines are now your new
+++++ ] "post" buffer
......... ]
......... X these lines you dump from memory
......... X these lines you dump from memory

now to make this appear faster, only do the loading from file after you have moved the viewport has been adjusted. you can also experiment with the size of your buffers to optimise speed.
[ October 05, 2005: Message edited by: Scheepers de Bruin ]
 
faisal siraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can readjust the viewport with scrollbar.Can u give me an example.i will be very very gratefule if u share a code that perform this task i,e display 30 lines and as the viewport changes then again display next 30 lines.
thanks again for ur reply
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea here is not for me to code for you, but help you code yourself. I will try my best to explain the mechanics behind it though.

Lets call the displayed bit your viewport, and the displayed bit plus the buffers your file aperture (or FA).

You can represent your FA with an array of bytes, and the buffers and viewport are 10 in size.
Byte[] fileAperture = new Byte[30];

So the pre-buffer would be fileAperture from index 0 through 9, viewport 10 to 19 and post-buffer 20 to 29.

To scroll up x lines:

// Display fileAperture[10-x] to fileAperture[20-x]

Byte[] tempArr = new Byte[fileAperture.lenght];
System.arraycopy(fileAperture, 0, tempArr, x, fileAperture.lenght-x);

// So now the first x spaces in tempArr is empty.
// Read those butes from file and put them in there

fileAperture = tempArr;

// You're now ready to handle another scroll event

Definition of arraycopy:
System.arraycopy(Object source, int sourceStartPosition, Object destination, int destinationStartPosition, int length)

Please note that there's still a LOT of this that can be optimised
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!