Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Constantly changing color of World Map Image in Java

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Constantly changing color of World Map Image in Java

    I am trying to create a virus simulation program. The program is supposed to just be a map of the world where the user can click any country in the world to specify where they want their virus to start, specify how transmittable the virus is, and be able to see how the virus spreads through the world by seeing a change in color throughout the world,

    I want the world map to initially start out with a very light yellow, and as areas of the world slowly start to get more and more infected by the virus, I want those areas on the map to start changing to a very dark red (going from a light yellow, through shades of orange and red, to dark red).

    So, the main idea of this is to have a program that displays an image where certain parts of the image will slowly change color during the runtime of the program.

    Does anyone have ideas as to how to do this? Or even ideas as to how to start this? I obviously know how to change colors of certain parts of a window or even an image, but this is very very detailed and advanced and I truly have no idea how to even start this.

    If anyone needs any more clarification as to my question, I would be happy to help.

    Thank you!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 635 Times in 540 Posts

    Default Re: Constantly changing color of World Map Image in Java

    This thread has been cross posted here:

    http://stackoverflow.com/questions/26239332/make-a-map-of-the-world-with-constantly-changing-colors-in-java

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    Although given the vagueness of the question, StackOverflow will probably delete it in the next few minutes.

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Constantly changing color of World Map Image in Java

    This is a very broad question.
    You could, for example, change the pixels RGB values. Or use any of one million other methods of doing it...

  4. #4
    Junior Member
    Join Date
    Jan 2014
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Constantly changing color of World Map Image in Java

    Quote Originally Posted by Cornix View Post
    This is a very broad question.
    You could, for example, change the pixels RGB values. Or use any of one million other methods of doing it...
    Well the reason this question is so broad is because I do not know the "any of one million other methods of doing it..." .
    I get the idea of changing the color of a specific pixel, wouldn't that be very cumbersome for a giant image of the world?

    What I mean is, wouldn't it be very cumbersome and almost impossible to record what country each pixel of the image is in, and then change the color of those pixels as the country becomes more infected?

    For example, if I had just a blank square and I had to constantly change the color of half of the square, I could probably manage that.
    But constantly changing the colors of all (or at least most) of the countries on an map image of the whole world? That is a much more difficult task that requires much more knowledge than just how to change the RGB value of a pixel.

    Does this help clarify my question?
    What would you do to create the simulation map that I have described? Would you record which pixels reside in each of the 150+ countries in the world, keep track of the infection rate in each of these 150+ countries, and then slowly change the color of all of those pixels for each country?

  5. #5
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Constantly changing color of World Map Image in Java

    What you should do really depends on much more detailed specifics of your program.
    First of all, what kind of graphics library do you want to use? AWT? Swing? SWT? OpenGL? Or any others?
    Then, how accurate do you want to make the country borders? How detailed should the map be? Can the user zoom in and out or whatnot?
    Is performance important (real-time) or do you want to create snapshots every now and then?
    Is anything else going to be shown or is it just the colored areas?

    etc etc etc. There is so much information missing that I cant tell you anything. Especially not about the "best" way because thats highly subjective.

  6. #6
    Junior Member
    Join Date
    Jan 2014
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Constantly changing color of World Map Image in Java

    I prefer to use Swing but I can use whatever you would suggest, whatever you think would be easiest (or whatever you have experience in and are able to suggest).

    I want to make the country borders pretty accurate, so the borders would basically imitate most world map images that I would find on the internet.

    The user does not have the ability to zoom or other special features like that. If I wanted my program to have those features, I would have specified. I truly just want to know how to take an image of a world map and change the color of multiple countries during the runtime of a program based on data in my program.
    This means that I do not want just snapshots every now and then. Instead, I want the map to be constantly changing colors depending on what is going on in the program. That is it.

    I am not even looking for the "best" way to do this so much as "a" way to do this that actually works considering I do not know how to do this.
    This program is a very simple program where most of it is simply this idea of constantly changing the color of the map. There are no special features that would change the image in any way such as zooming.

  7. #7
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Constantly changing color of World Map Image in Java

    Well then why dont you take a complete image of a world map and cut each country out by hand with the help of an image editing program. You can then save each country as a separate image file and load them on run time. Place them (within the application) at the correct locations to form a complete map again. At this point you can either iterate through all pixels to change the RGB values by hand or read into blending and alpha composites to do the coloring.

    Alternatively if you want to use things like OpenGL the color part would become easier but everything else would be a little bit more tricky.

    In any case you will not get around writing your own renderers unless you are lucky and find a library out there which does exactly what you need.

Similar Threads

  1. removing image background color using java??
    By game06 in forum Java Theory & Questions
    Replies: 2
    Last Post: March 23rd, 2013, 07:19 AM
  2. World Map
    By LorenzoR in forum AWT / Java Swing
    Replies: 5
    Last Post: December 2nd, 2011, 11:20 PM
  3. Okay Here Goes...World and Map Generation.
    By rooster5105 in forum Algorithms & Recursion
    Replies: 1
    Last Post: October 30th, 2011, 02:45 PM
  4. How Do I Make Color Changing Buttons?
    By blurredvis0n in forum AWT / Java Swing
    Replies: 3
    Last Post: August 30th, 2011, 02:14 PM
  5. Need help with changing color of JOptionPane
    By jwise95 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 22nd, 2011, 09:49 AM

Tags for this Thread