Help them understand how to display a raster image

Hello.

I apologize in advance if this sounds a bit complicated issue, but I'm a little confused as to how to go about it.

I have an Ascii-grid file exported from ArcMap and I want to draw on a JPanel.
This particular grid is a DEM, but it would be good if it could produce this for any network, if it makes a difference.
The problem is I don't really even know where to begin... I looked at using templates, buffers of data, etc. for the creation of a frame, but I don't really know how to enter the ascii data that I have in one of these.
Can I remove the integer values pixel data in the file before etc and if so how can I go about it?

Also is it possible to do a color model of an int array standard, if it was created in a particular model, for example to the designated height values.

Help to identify the ways to go about this would be very welcome because I am lost about what to do. Even just a few tips in the right direction. I'm more that happy to go work it out I really don't know where to start.
See you soon.

Sounds something like a map of contours. I don't know there must be a technically superior (read: horribly complicated) way to do this, use IndexColorModel, WriteableRaster etc etc, but if performance is satisfactory, I would go with a simple BufferedImage and setRGB.

import java.awt.Color;
import java.awt.image.BufferedImage;
import javax.swing.*;

public class ContourMap {

  private int[] colors = {
    Color.BLACK.getRGB(),
    Color.GREEN.getRGB(),
    Color.YELLOW.getRGB(),
    Color.RED.getRGB()
  };

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {

      @Override
      public void run() {
        new ContourMap().makeUI();
      }
    });
  }

  public void makeUI() {
    String[] strData = {
      "000000000000000",
      "000000111000000",
      "000111221110000",
      "001112222111000",
      "001122332211000",
      "001112222111000",
      "000111221110000",
      "000000111000000",
      "000000000000000"
    };
    BufferedImage image = new BufferedImage(strData.length, strData[0].length(),
            BufferedImage.TYPE_INT_ARGB);
    for (int i = 0; i < strData.length; i++) {
      for (int j = 0; j < strData[0].length(); j++) {
        image.setRGB(i, j, colors[strData.charAt(j) - '0']);}System.out.println();}JLabel label = new JLabel(new ImageIcon(image), JLabel.CENTER);

JFrame frame = new JFrame();frame.add(label);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setSize(200, 200);frame.setLocationRelativeTo(null);frame.setVisible(true);}}db

edit And oh, the data is in a hardcoded String array only because I couldn't be bothered adding all the commas to make it a int[][] after copying from your post

Edited by: Darryl Burke 

Tags: Java

Similar Questions

  • Please help me understand how to install updates with the following error updated Message__The following have not been installed: __Security update for Microsoft XP KB 2289162

    Please help me understand how to install updates with the following error Message

    The following updates were not installed:

    Security for Microsoft XP KB 2289162 update

    See the section "How to get help" of http://support.microsoft.com/kb/2289162

    For individuals, please visit the Microsoft Solution Center and antivirus security for resources and tools to keep your PC safe and healthy.  If you have problems with the installation of the update itself, visit the Microsoft Update Support for resources and tools to keep your PC updated with the latest updates.

    Buying to meet problems installing Microsoft security updates also can visit the following page for assistance: https://consumersecuritysupport.microsoft.com/

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • I have a problem with my shrink to a smaller size text, when I create a link. Can someone help me understand how to solve this problem?

    I have a problem with my shrink to a smaller size text, when I create a link. Can someone help me understand how to solve this problem? Here is the URL of the page where it happens. Spring Art tour

    Tamlyn

    Line 22 of your main document

    do-size: 14px;

    change that to

    font size: 1 rem;

    See https://css-tricks.com/confused-rem-em/

  • Can someone help me understand how to access such RW2 files saved by my Lumix LX100 in Lightroom 4.4?

    Can someone help me understand how to access such RW2 files saved by my Lumix LX100 in Lightroom 4.4?

    Hi Edward,.

    4.4 Lightroom does not support files of Lumix LX100 RW2. You need at least 5.7 version of Lightroom to access these raw files.

    Or, you can use free Adobe DNG Converter to convert raw to DNG files, and then import the DNG in Lightroom.

    For Mac: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5854

    For Windows: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5864

  • Need help to understand how to use the SDK for our use case

    Hi all!

    I'm having a lot of problems with understanding the SDK and how to work with it.

    The documentation available only is generated comments PHP which summarizes the methods, variables, about classes and groups.

    It is a reference that helps a little more on the technical aspect of the classes and their relationship with each other, but it IS NOT tell me, for example of one of the sample files:

    echo "-ch. |" -netmoref < netmoref > [choose] Vim portgroup MoRef. Required to create. \n » ;

    It's the example script that creates an external network, what I have to do to set up a new client, organization.

    Another unknown is what is a "fence Mode" in the present: $config-> setFenceMode ($fenceMode);

    Another concept of basis of the SDK I could not really grasp yet - is why some of the classes start as VMware_VCloud_API * while others are VMware_VCloud_SDK *.

    Another example? in the scree of new organization of the GUI, in terms of policy, there is a section 'Limits' - I searched carefully and found no corresponding SDK/API method in the documentation!

    Also, I couldn't find a way to delete organization (when a customer cancels a subscription, for example).

    I apologize if my attitude invades a bit on the angry side, but I was home for a while now and every time I get more irritated watching the "documentation" try to understand something

    Nevertheless, Kimberly Wang code is simply remarkable and very well written, just help to know how to make this huge puzzel I wish (even in the sample code that I do not understand how to find the right order of things in nesting objects in order to do something like object of class VMware_VCloud_API_OrgSettingsType for the parameters for example then feed him in a VMware_VCloud_API_AdminOrgType (as well as other parameters - why are they not in the $settings object? And finally another object of VMware_VCloud_SDK_Admin is to truly create the Organization!

    Why the VMware_VCloud_API_AdminOrgType couldn't be the class doing the creation of the Organization)?

    This is a brief summary of the things I'm trying to understand.

    Perhaps, I missed some sort of guide for this? and if not, I would be very grateful if someone could explain in a few words to help me to understand this puzzel so that I can start doing my work and build something out of these awesome (even if cryptic) building blocks!

    Thank you

    Sorry, you must use

    $SDKAdminOrgObj = $service-> createSDKObj ($adminOrgRef);

    It should return you a... Object SDK_AdminOrg.

  • How to display a .swf image when the film is disabled?

    I wonder how to display an image or a swf image when the film is not play. Any information appreciated. Thank you!

    A swf is never really off if it is displayed. But if you want something to show when there is nothing going on in the file, then just do sit in a frame with any content you intend to display.

  • How to return the raster image to 100%

    I have a bunch of pictures that are embedded in a document to HAVE him, and I want to cut and paste in photoshop. I want what they at their original resolution, but unfortunately they are all scaled down. For example, one of the images is reduced to 50%, and when I copy and paste into photoshop, it remains to the scale to 50% and resamples the image (by which I lose resolution.) I want to this effect resize all images to their 100% original scale) and THEN copy and paste into photoshop. I don't know how to do this. WHEN I click on the Info link for each image, tells me what percentage to scale each image, but I have no way to simply select all the images and saying scale = 100% (it would be easy in After effects). Someone one knows how? I just want what they all returned to their original size, so that when I paste it into Photoshop, there is no resampling or generational loss...

    Illustrator does not store the 'original size' of embedded raster images. When you embed it, it is what it is: a number of pixels is reduced to its current size. You can see this expressed in number of pixel and ppi in (of all places) the Document Info palette, if you select selection only and Images incorporated into the context menu.

    In the links Palette, you can select link information in the flyout and see the "scale" expressed as a percentage. It's always compared to 72 dpi, so laboriously, you must do the math and turn it accordingly to make what Illustrator sees as "100%" (72 dpi).

    (Isn't this practice? Is not that intuitive? Worst - of - Class of interface between the vector of all drawing programs).

    Workaround solution:

    Save the file TO PDF format (predefined default Illustrator will be good).

    Open in Acrobat.

    Advanced > DocumentProcessing > ExportAllImages.

    JET

  • How to display a BLOB (Image) in a report of the EBS?

    User has requested to add a Logo image to a report called the E-Business Suite (EBS).

    The image is currently stores in a BLOB column.

    How can I make the image to display in the report?

    Thank you!

    I don't see why it wouldn't work on Unix. Each element in the layout is a source based on a column in your query (in the datamodel). It doesn't matter if it's Windows or Unix.

    Reports done automatically if you use the wizard. If you change an existing report, you need to add the column (in the datamodel) and element (in the layout) yourself.

  • Can someone help me understand how the URL handlers work and how they can be used to launch AppleScripts links?

    Preface:

    -I'm not a complete noob, but Applescript is my first programming language

    -J' have been able to write scripts that are useful for a variety of tasks, but especially the interaction between the Excel and numbers

    -I consider myself to be an advanced/expert with the numbers, but not Excel

    My goal is to be able to run scripts from a link in a Numbers spreadsheet without opening a browser.  For me, a key missing numbers is the ability to create interactive buttons.  I know reading is it possible to use links in OSX to trigger scripts via URL, but all managers the explanations and instructions, I found are over my head, because they reference the definitions of programming I don't understand.   I know it's probably a very long answer.  I really appreciate the effort and promise of will not be wasted your time and your knowledge will be used for good (at least by me).

    World  thanks,

    Ash

    Google this string: Manager of URLS AppleScript.

    The first strike several include the how-to code AppleScript which should guide you on the construction and launch of a URL handler.

  • I'm trying to install 3 critical updates and keep getting the error code 646... No matter what I try, this code comes up and I can't spent! Please help me understand how to get my installed critical downloads!

    Vista... Update of security for Microsoft Office Excel 2007 (KB978382)

    Download size: 8.5 MB

    You may have to restart your computer for this update is taken into account.

    Update type: Important

    A vulnerability of security in Microsoft Office Excel 2007 that could allow arbitrary code to run when opening a file modified for malicious purposes. This update resolves this vulnerability.

    More information:
    http://support.Microsoft.com/kb/978382

    Help and Support:
    http://support.Microsoft.com/?ln=en-us

    and

    Update of security for Microsoft Office System 2007 (KB978380)

    Download size: 7. 4 MB

    You may have to restart your computer for this update is taken into account.

    Update type: Important

    A security vulnerability in the 2007 Microsoft Office System and the Microsoft Office Compatibility Pack that could allow arbitrary code to run when opening a file modified for malicious purposes. This update resolves this vulnerability.

    More information:
    http://support.Microsoft.com/kb/978380

    Help and Support:
    http://support.Microsoft.com/?ln=en-us
    and

    Update for the junk e-mail in Outlook 2007 (KB979895) filter

    Download size: 3.3 MB

    You may have to restart your computer for this update is taken into account.

    Update type: Important

    This update provides the filter of junk e-mail in Microsoft Office Outlook 2007 a more current definition of which e-mail messages should be considered junk e-mail.

    More information:
    http://support.Microsoft.com/kb/979895

    Help and Support:
    http://support.Microsoft.com/?ln=en-us

    Will be updated not at all there is an optional update.

    Windows Live Essentials

    Download size: 1.1 MB

    You may have to restart your computer for this update is taken into account.

    Update type: Optional

    Windows Live Essentials provides a set of free programs that help you keep in touch with the people you love the most, edit and share your photos and your memories and even help you keep your kids safer online. Programs include Windows Live Messenger, Mail, Writer, Gallery photos, family safety, Toolbar, and Movie Maker.

    More information:
    http://download.live.com

    Help and Support:
    http://help.live.com/help.aspx?project=wlinstallerv3&query=wli02d46ad8

    I can't not to update on my system either... PLEASE HELP ME!

    E-mail address is removed from the privacy * I am confused about how to get these downloaded on my system.

    Thank you!!!

    Hi there, manually download and install updates for Office.

    Go here: http://www.microsoft.com/downloads/en/results.aspx?freetext=KB978382&displaylang=en&stype=s_basic

    Then search for the others, their download to a location on your hard drive, you can locate and install manually. He is the current solution to this problem.

    TaurArian [MVP] 2005-2010 - Update Services

  • can someone help me understand how to get a driver usb mtp device and base system device online?

    Pavilion dv7 1245ca

    Awesome. It's a nice phone you understand not what operating system you were using so I couldn't connect download, but here is the link to the download page for the SIII. Everything you need to do is find the right operating system you use.

    http://goo.GL/GZcLP

    I hope this helps!
    Sean

  • Need help to understand how to use importTextData

    I am trying to write a script using importTextData and I can't get the text file to load properly using Acrobat 9 Pro.  At this point, I'm not even worried about the overall functionality of the script.  I'm just trying to nail presents a single piece.

    When I run this.importTextData (); in the java console in Acrobat, I'm prompted to choose my text file, then the rank.  It then returns a value of 3, which is an error "invalid line".

    My text file is as simple as they come.  It contains the following information:

    test

    1

    I've seen references to a naming convention more complex for the identifier of the column.  What is my problem?

    My other question is that I am finally able to load the text file, how do I reference data inside?  The data loaded into a table?  Can I assign the data loaded in a variable like this:

    var x = this.importTextData ();

    and then different reference cells using x [0], x [1], x [2], etc.. ?  Or do I have to use this.getField?

    Sorry if these are dumb questions.  My understanding of this is very basic.  Thank you.

    The Doc.importTextData () method is used to import data into an interactive form. To do this, you must make sure that all the needs of the service is in place:

    • You need a tab separated text (file not a CSV, data fields must be separated by tabs).
    • Your PDF form must have exactly the same number of fields as there are has columns in the text file
    • The columns of your text file must be named exactly as your form fields

    When you import a text file into your form, you can choose which line you want to import. This is done via the user interface if you use the feature on Acrobat UI, or via a parameter when you call the JavaScript function. Using the user interface (for example through forms > manage form data > Import menu Acrobat 9) is an easy way to check that your file is correct, without having to call the JS function.

    The data is imported into your form. If you want to access the data, you must do so via the form field. You cannot import several lines at once. If you need data from several rows, you will need to do this one line at a time and then store the data in your own JS data structure.

  • Could someone help me understand how I could accomplish this?

    Okay, so I try to create an effect that tells hearing: If the noise just picked up the microphone volume is UNDER 'x' strong db, then it didn't out. I need of to happen in audio editing multitrack/live. Any help is appreciated, thanks!

    You have to look in the Amplitude and the treatment of the effects/Dynamics of Compression for a predefined gate or Expander. Try the Noise Gate > 20dB at first. But you will need to adjust the controls to the suite your audio especially.

  • Can someone help me understand how the code should look like this?

    I keep looking for forums and I can't figure out if I need an instance name, a frame name, convert to symbol, graphics or video clip. All that I want is the images I have to move and stop as this graph on this website. If anyone can help to provide the code, it would be greatly appreciated!

    Best,

    Brett

    http://byluisvenegas.com/zines/ey-magateen/ey-magateen-5/

    this.addEventListener (MouseEvent.MOUSE_OVER, stopF);

    this.addEventListener (MouseEvent.MOUSE_OUT, playF);

    function stopF(e:MouseEvent):void {}

    This.Stop ();

    }

    function playF(e:MouseEvent):void {}

    This.Play ();

    }

  • Looking for answers/help to understand how can I "fix".

    Hola... .new

    I got a nav div with a color, width, and a high properties that are crossed with a line in my CSS Inspector

    If I pass the mouse over it, it shows this

    "background color does not apply to your selection because it is not inherited. It is applied to an attached tag.

    However, the elements of the page are transparent by default, so this color may appear through"

    So, what happened?

    How can I fix it?

    Thank you

    At this point, you are best placed to find out why this happened and how to fix it.

    But now that you have made us curious, you might want to share this unique phenomenon providing a link to your site.

    GRAMPS

Maybe you are looking for