aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Displaying generated images greater than 32767 pixels on canvas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Displaying generated images greater than 32767 pixels on canvas" Watch "Displaying generated images greater than 32767 pixels on canvas" New topic
Author

Displaying generated images greater than 32767 pixels on canvas

Adam Sheen Smith
Greenhorn

Joined: Feb 06, 2012
Posts: 2
Hi

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:

1)
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!

2)
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.

Thanks guys

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.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

interesting question. i dont know the answer. my first approach, however, would be a JPanel and a JScrollPane


SCJP
Visit my download page
Adam Sheen Smith
Greenhorn

Joined: Feb 06, 2012
Posts: 2
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...
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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)
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Michael Dunn wrote:
You're more likely to solve the problem by posting in an Eclipse/SWT forum (if there is one - should be)

Indeed. This looks like the real McCoy http://www.eclipse.org/forums/index.php/f/100/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying generated images greater than 32767 pixels on canvas