Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #4453

(swing)newbie - handling

From "Michael" <michael@THRWHITE.remove-dii-this>
Subject (swing)newbie - handling
Message-ID <491a0ebe$0$32255$9b622d9e@news.freenet.de> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:50 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui

this is my first swing program so I surely didn't invent the best solution for my prob :-)

I want to get a better way to solve the following:

I want to show an image, a colorful fancy world map of a board game, be able to scale it (smaller and bigger) and scroll it. If clicking into the map I want to get the special infos connected to the area on the map (even if scaled, scrolled...)

I did this with an ImageIcon in a JScrollPane. I prescaled the image to ten different sizes and cached those images. To scale th map I change the image of the ImageIcon. 

The parts of the map represent countries which have different attributes. To get those attributes after a click into the (maybe scaled) image I have a second "shadow" map, in which the colors represent special properties of the map.

The only way to get the colour of a pixel is using a BufferedImage (I didn't got this working, the images had errors after scaling) or a PixelGrabber.
So I created the PixelGrabbers and cached the grabbed pixels for each shadow map. This takes quite long to initialize...
That way, if I click into the scaled and scrolled image, I get the info out of the shadow map.

This all works, it just seems elegant and too much code. What may be a better way to do it? Is using a canvas better?

Thanks for some hints on this,

 Michael

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

(swing)newbie - handling "Michael" <michael@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
  Re: (swing)newbie - handl "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000

csiph-web