Displaying generated images greater than 32767 pixels on canvas
Adam Sheen Smith
Joined: Feb 06, 2012
I've been stuck on this for almost a week now so here it goes..
The general gist of the application is to generate one large horizontal bar up to approxiamtely 85,000 pixels to model the amount of seconds in a 24hr period, each pixel represents a second.
This bar is split into multiple sections, these sections can number sometimes anywhere between 1000-2000, each represent a particular 'event' within the 24hr period. So I might have an event A coloured red and that is 300 seconds, another event Z may be 400 seconds with a yellow bar. So they've taken up 700 horizontal pixels so far --> 700 seconds within the 24hr timespan.
These bars and their colours are generated according to a pre-determined 'model' so their never the same.
Inititally I tried it with a ScrolledComposite to display the bar, it worked great up till 32767 pixels (the composite expanded to 32767 pixels) of which after I soon found out I reached the maximum pixel limit for composites in Windows and whatever that should have been drawn beyond this point has been cut off, the scrollbars also worked great displaying the 32767 pixels however and with no lag.
So after having a consultation with the supervisor I've decided to go for the Canvas approach. The thing is my original approach was with a Canvas but I got stuck hence making me switch to a ScrolledComposite. Now I am back to square one. Here are my questions:
Would this be the best approach in your opinion? Does canvas support a pixel width of 85,000 (I tried with 'Image' and it failed)?
My idea was to have a 1000 pixel wide fixed width canvas with scrollbars. Everytime the scrollbars or a 'forward button' is pressed the canvas is repainted to simulate a side "scroll" to show the next lot of pixel graphics. Once the button is clicked on again it shows the next lot of pixel graphics. With this approach I only ever have to deal with 1000 pixels at a time and not the whole 85,000 pixels however I will still be able to view the whole 85,000 pixels without lag or reaching a limit.
How would I 'technically' be able to go around doing this? Some pointers please!
I wrote a "Canvas Test" program to try to test out my idea mentioned above.
The problem with this code is that it's supposed to display 4 different coloured rectangles on the canvas however it only displays the first three, I have to drag the shell window out manually to see the fourth image. So to address this issue I added a Listener to listen for SWT.Resize events. However it does not work as it should - the horizontal scrollbar just disappears when I re-size the window manually. The thumb size on the scrollbar should become smaller if I manually resize the shell smaller so that the scrollbar can be used to view all four images, and the scrollbar width should increase if I manually resize the window outward.
Can someone please tell me what's wrong with my Resize listener code.
Really appreciate it!
PS: Should mention I am not an expert on SWT however I did read some books and went through tutorials to try to understand the best I can given the timeframe.
Joined: Oct 21, 2000
interesting question. i dont know the answer. my first approach, however, would be a JPanel and a JScrollPane
Adam Sheen Smith
Joined: Feb 06, 2012
No I can't use any SWING components since the boss wants it to be done in SWT.
Guys if you can't answer the first question please answer the second!! Still trying here...
Joined: Jun 09, 2003
SWT gets very little traffic here, and most questions go unanswered (a quick search will confirm).
You're more likely to solve the problem by posting in an Eclipse/SWT forum (if there is one - should be)