Saving modifled ARGB values in an Integer array to a jpeg file?

Hi,
I have searched sites and forums and it seems that the key to this is to use BufferedImage and Graphics's drawImage(). But how can I use the drawImage when I only have an array of integer values?
I went through the docs and seems that BufferedImage class's setRGB() method may suit my purpose but the results were negative. The saved jpeg was just painted black instead of the photo.
Does my code below make any sense or am I missing out something here? Any help will be greatly appreciated!
//from my code, oneDPix is an int[] array containing modified ARGB values
BufferedImage buff = new BufferedImage(imgCols,imgRows,BufferedImage.TYPE_INT_ARGB);
Graphics2D g = buff.createGraphics();
buff.setRGB(0,0,imgCols,imgRows,oneDPix,0,imgCols);
try {
     String targetFile = "/Users/cover.jpg";
        ImageIO.write(buff,"jpg", new File(targetFile));
        } catch (IOException ex) {
            ex.printStackTrace();
        }

hi, if your array has the right values, then you could use the createImage method of the class Toolkit and teh class MemoryImageSource for making the image before, something like this:
Image ima = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(numOfColumns, numOfRows, ColorModel.getRGBdefault(), array, 0, numOfColumns));
BufferedImage bi = new BufferedImage(numOfColumns, numOfRows, BufferedImage.TYPE_INT_RGB);
Graphics g = bi.getGraphics();
g.drawImage(ima, 0, 0, null);
g.dispose();
ImageIO.write(bi,"jpg",new File(targetFile));hope this helps

Similar Messages

  • Saving an integer array into a .txt file

    hii, im only a beginner in java, so this is the only code i've learned so far for saving array elements into a file
         public static void saveNames(String [] name) throws IOException
                   FileWriter file = new FileWriter("Example\\names.txt");
                   BufferedWriter out = new BufferedWriter(file);
                   int i = 0;
                   while (i < name.length)
                             if (name[i] != null)
                                  out.write(name);
                                  out.newLine();
                                  i++;
                   out.flush();
                   out.close();
    However, this is only used for string arrays; and i can't call the same method for an integer array (because it's not compatible with null)
    I don't really understand this code either... since my teacher actually just gave us the code to use, and didn't really explain how it works
    I have the same problem for my reading a file code as well --> it's only compatible with string
         public static String [] readNames (String [] name) throws IOException
              int x = 0;
              int counter = 0;
              String temp = "asdf";
              name = new String [100];
              FileReader file = new FileReader("Example\\names.txt");
              BufferedReader in = new BufferedReader(file);
              int i = 0;
              while (i < array.length && temp != null)                    // while the end of file is not reached
                   temp = in.readLine();
                   if (temp != null)
                        name[i] = temp;                    // saves temp into the array
                   else
                        name[i] = "";
                   i++;
              in.close();                                   // close the file
              return name;
    Could someone suggest a way to save elements from an integer array to a file, and read integer elements of that file?
    Or if it's possible, replace null with a similar variable (function?), that is suitable for the integer array (i can't use temp != 0 because some of my elements might be 0)
    Thanks so much!!!!!

    because it's not compatible with nullI think it should be okay to just remove the null condition check since there are no null elements in a primitive array when writing.
    Use Integer.parseInt() [http://java.sun.com/javase/6/docs/api/java/lang/Integer.html] to convert the String into an Integer when you read it back and use Integer.toString() to be able to write it as a String.

  • How to lookup a value in a 2D array from an Excel file - Dasylab version 12 Pro

    Hi, I am new to this forum and am looking for some advice on a worksheet I'm trying to construct.  I have an Excel spreadsheet that is basically a 2D array, and I want to use Dasylab v12 Pro to be able to import a value from this array based on user selections from within the Dasylab worksheet.
    Column A lists 200+ diesel engine models.  I've shown 9 in my Excel attachment...one model per row (shaded in yellow), and each engine model can be run at several speeds (shaded green in columns B thru F).  For an engine in a given row, combined with a chosen operating speed gives you a corresponding horsepower (blue shading).
    I have this Excel sheet saved somewhere on my C:/ drive, and what I want to do is when the user starts the Dasylab worksheet he will select from a drop drown menu to choose the engine model (ie A, B, C, etc) and another drop down menu to choose the speed (ie 1470, 1760, etc).  I know that I can make a drop down menu with a Coded Switch within Dasylab, however it seems only 16 choices can be made from each switch, so for my 200 engine models I will need 13 switches!  I know I can assign a text description like "Engine A" to a numerical value within that coded switch.  Somehow I need to take those two selections made within the Dasylab experiment, and read this Excel file (ie my database of all of these 200 diesel engine models) as a 2 dimensional array by row and column to spit out the data value (the blue numbers) back into Dasylab.
    The goal is to take the engine model, speed, and the horsepower obtained from the array search and write these to an .asc file that I will create a running log of this data.  So, after the test page is run 50 times it will have 50 rows of data containing these 3 parameters.  There is some other test data taken from my data acquisition that goes along with this, however that's not part of my 2D array predicament.
    I'm taking a guess that I need to do something with global strings & variables, and some how import them and export them with an ODBC in/out module.  This is something I've just never worked with before so I am a bit lost.  Obviously I can just make the user type in the engine model and speed as a startup parameter at the start of the test and save that to a variable or string, but I want to make it idiot proof so that the two selections (ie row and column) can be chosen from a pre-set list and will yield my data value.  Everything else related to Dasylab I am pretty proficient with.
    Thanks,
    Mike
    Attachments:
    engine 2D array.xlsx ‏10 KB

    This would be the best way.
    Also, with version 13 they started using Phyton to create custom modules that can be programmed in DASYLab.
    We arte learning this right now and I know that you can use standard message dialogs with that as well.
    I would suggest to you to download a demo of V13 and take a look at the Pyton module.
    Also, usually DASYLab system intgretors like us, can provide services also on things like this including Excel programming for pre and post analisys 
    Tom Rizzo
    InSyS Corp.
    www.insyscorp.com
    Your DASYLab integrator

  • Only writing Integer pixel array to a .txt file,or showing in Frame

    Sir,
    I want to write integer values (range:0 to 255) to a .txt file .Actually after manipulating a .jpeg/.gif image I have gotten a 2D pixel array and a 1D pixel array that can be easily shown in console but I want to write this pixel array into a .txt file. Using of writeInt() is not working. Actually after using this faction the created file contain information which is non-alphanumeric /alphanumeric characters......
    following is error free the code: Plz. See only and only into the �class TestImage�and plz look after line marked by //�my_problem_to_be_resolved.�It is just few lines of code .I promise you will not be bothered.Plz��..
    import java.awt.*;
    import java.io.File;
    import java.io.FileWriter;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;
    class Image {
    protected int width,height;
    // 'samples' stores the image pixel values.
    protected int[][] samples;
    // Constructor: Reads the image from the
    // specified file name.
    public Image(String filename)
    throws Exception { read(filename); }
    // Returns the pixel width of the image.
    public int getWidth() { return width; }
    // Returns the pixel height of the image.
    public int getHeight() { return height; }
    // Reads the image from the specified file
    // name into the 'samples' array. Throws an
    // exception if the image is stored in an
    // unsupported file format (currently only
    // .GIF, .JPG, and .PNG are supported by Sun).
    public void read(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageReaders that claim
    // to be able to decode this image file
    // based on the file name suffix.
    Iterator imageReaders = ImageIO.
    getImageReadersBySuffix(ext);
    ImageReader imageReader;
    // Grab the first ImageReader in the list.
    if (imageReaders.hasNext())
    imageReader = (ImageReader)
    imageReaders.next();
    // If we get here we cannot decode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file input stream object to
    // read the image date.
    FileImageInputStream imageInputStream =
    new FileImageInputStream(fileImage);
    // Tell the ImageReader object to read data
    // from our file input stream object.
    imageReader.setInput(imageInputStream);
    // Get the width and height of the image.
    width = imageReader.getWidth(0);
    height = imageReader.getHeight(0);
    // Read the image from the file input stream,
    // and close the input stream when done.
    BufferedImage bufImage =
    imageReader.read(0);
    imageInputStream.close();
    // Get a raster object so we can extract the
    // pixel data from the BufferedImage.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Create our 'samples' 2d-array.
    samples = new int[height][width];
    // Extract the image data into our 'samples'
    // array.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    samples[row][col] =
    wRaster.getSample(col,row,0);
    // Write the image stored in the 'samples'
    // array to the specified file. The file name
    // suffix should be a supported image file
    // format (currently either .JPG or .PNG).
    public void write(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageWriters that claim to
    // be able to encode images in the specified
    // image file format based on the file name
    // suffix.
    Iterator imageWriters = ImageIO.
    getImageWritersBySuffix(ext);
    ImageWriter imageWriter;
    // Grab the first ImageWriter in the list.
    if (imageWriters.hasNext())
    imageWriter = (ImageWriter)
    imageWriters.next();
    // If we get here we cannot encode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file output stream object to
    // write the image data.
    FileImageOutputStream imageOutputStream
    = new FileImageOutputStream
    (fileImage);
    // Tell the ImageWriter to use our file
    // output stream object.
    imageWriter.setOutput
    (imageOutputStream);
    // The ImageWriter.write() method expects a
    // BufferedImage. Convert our 'samples' array
    // into a BufferedImage.
    BufferedImage bufImage =
    createBufferedImage();
    // Encode the image to the output file.
    imageWriter.write(bufImage);
    imageOutputStream.close();
    // Draws the image stored in the 'samples'
    // array on the specified graphics context.
    public void draw(Graphics gc,int x,int y){
    BufferedImage bufImage =
    createBufferedImage();
    gc.drawImage(bufImage,x,y,null);
    // Converts the 'samples' array into a
    // BufferedImage object. Students do not have
    // to understand how this works.
    private BufferedImage
    createBufferedImage() {
    // Create a monochrome BufferedImage object.
    BufferedImage bufImage = new
    BufferedImage(width,height,
    BufferedImage.TYPE_BYTE_GRAY);
    // Create a WriteableRaster object so we can
    // put sample data into the BufferedImage
    // object's raster.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Copy the 'samples' data into the
    // BufferedImage object's raster.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    wRaster.setSample
    (col,row,0,samples[row][col]);
    // Return the newly created BufferedImage.
    return bufImage;
    } // End of Class Image
    class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/lilies.jpg");
    int height=img.getHeight();
    int width =img.getWidth();
    //�my_problem_to_be_resolved.�
         File image_object_arry=new File("C:/Image_array.txt");
         FileOutputStream image_object_arry_stream= new FileOutputStream(image_object_arry);
         DataOutputStream int_image_object_arry_stream=new DataOutputStream(image_object_arry_stream);
    //Conversion of two dimensional pixel arrry into one dimensional array
    int intPixels1[] = new int [height * width];
    int k = 0;
    for(int i = 0; i <= width; i++) {
    for(int j = 0; j <= height; j++) {
    intPixels1[k] = img.samples[i][j];
    int_image_object_arry_stream.writeInt((int) intPixels1[k]);
    // System.out.println(intPixels1[k]);
    k = k+1;
    import java.awt.*;
    import java.io.File;
    import java.io.FileWriter;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;
    class Image {
    protected int width,height;
    // 'samples' stores the image pixel values.
    protected int[][] samples;
    // Constructor: Reads the image from the
    // specified file name.
    public Image(String filename)
    throws Exception { read(filename); }
    // Returns the pixel width of the image.
    public int getWidth() { return width; }
    // Returns the pixel height of the image.
    public int getHeight() { return height; }
    // Reads the image from the specified file
    // name into the 'samples' array. Throws an
    // exception if the image is stored in an
    // unsupported file format (currently only
    // .GIF, .JPG, and .PNG are supported by Sun).
    public void read(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageReaders that claim
    // to be able to decode this image file
    // based on the file name suffix.
    Iterator imageReaders = ImageIO.
    getImageReadersBySuffix(ext);
    ImageReader imageReader;
    // Grab the first ImageReader in the list.
    if (imageReaders.hasNext())
    imageReader = (ImageReader)
    imageReaders.next();
    // If we get here we cannot decode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file input stream object to
    // read the image date.
    FileImageInputStream imageInputStream =
    new FileImageInputStream(fileImage);
    // Tell the ImageReader object to read data
    // from our file input stream object.
    imageReader.setInput(imageInputStream);
    // Get the width and height of the image.
    width = imageReader.getWidth(0);
    height = imageReader.getHeight(0);
    // Read the image from the file input stream,
    // and close the input stream when done.
    BufferedImage bufImage =
    imageReader.read(0);
    imageInputStream.close();
    // Get a raster object so we can extract the
    // pixel data from the BufferedImage.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Create our 'samples' 2d-array.
    samples = new int[height][width];
    // Extract the image data into our 'samples'
    // array.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    samples[row][col] =
    wRaster.getSample(col,row,0);
    // Write the image stored in the 'samples'
    // array to the specified file. The file name
    // suffix should be a supported image file
    // format (currently either .JPG or .PNG).
    public void write(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageWriters that claim to
    // be able to encode images in the specified
    // image file format based on the file name
    // suffix.
    Iterator imageWriters = ImageIO.
    getImageWritersBySuffix(ext);
    ImageWriter imageWriter;
    // Grab the first ImageWriter in the list.
    if (imageWriters.hasNext())
    imageWriter = (ImageWriter)
    imageWriters.next();
    // If we get here we cannot encode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file output stream object to
    // write the image data.
    FileImageOutputStream imageOutputStream
    = new FileImageOutputStream
    (fileImage);
    // Tell the ImageWriter to use our file
    // output stream object.
    imageWriter.setOutput
    (imageOutputStream);
    // The ImageWriter.write() method expects a
    // BufferedImage. Convert our 'samples' array
    // into a BufferedImage.
    BufferedImage bufImage =
    createBufferedImage();
    // Encode the image to the output file.
    imageWriter.write(bufImage);
    imageOutputStream.close();
    // Draws the image stored in the 'samples'
    // array on the specified graphics context.
    public void draw(Graphics gc,int x,int y){
    BufferedImage bufImage =
    createBufferedImage();
    gc.drawImage(bufImage,x,y,null);
    // Converts the 'samples' array into a
    // BufferedImage object. Students do not have
    // to understand how this works.
    private BufferedImage
    createBufferedImage() {
    // Create a monochrome BufferedImage object.
    BufferedImage bufImage = new
    BufferedImage(width,height,
    BufferedImage.TYPE_BYTE_GRAY);
    // Create a WriteableRaster object so we can
    // put sample data into the BufferedImage
    // object's raster.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Copy the 'samples' data into the
    // BufferedImage object's raster.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    wRaster.setSample
    (col,row,0,samples[row][col]);
    // Return the newly created BufferedImage.
    return bufImage;
    } // End of Class Image
    /*class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/srk.jpg");
    // Display the image.
    img.draw(gc,10,40);
    // Flip the image upside down
    //img.flipX();
    // Display the flipped image.
    img.draw(gc,20+img.getWidth(),40);
    // Write the new image to a file
    img.write("HorseNew.jpg");
    } catch (Exception e) {
    System.out.println
    ("Exception in main() "+e.toString());
    class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/lilies.jpg");
    int height=img.getHeight();
    int width =img.getWidth();
    File image_object_arry=new File("C:/Image_array.txt");
    FileOutputStream image_object_arry_stream=new FileOutputStream(image_object_arry);
         DataOutputStream int_image_object_arry_stream=new DataOutputStream(image_object_arry_stream);
    //Conversion of two dimensional pixel arrry into one dimensional array
    int intPixels1[] = new int [height * width];
    int k = 0;
    for(int i = 0; i <= width; i++) {
    for(int j = 0; j <= height; j++) {
    intPixels1[k] = img.samples[i][j];
    int_image_object_arry_stream.writeInt((int) intPixels1[k]);
    // System.out.println(intPixels1[k]);
    k = k+1;
    catch (Exception e) {
    System.out.println("Exception in main() "+e.toString());
    catch (Exception e) {
    System.out.println("Exception in main() "+e.toString());
    }

    My Friend, you need to put your code within CODE tags
    And I suspect if anyone would go through your code this way.
    Assuming your problem is to write pixel values to a file you may use this,
          try{
            // Create file
            FileWriter fstream = new FileWriter("out.txt");
            BufferedWriter out = new BufferedWriter(fstream);
            for(int i =0; pixels.length() ; i++)
              out.write(pixels[i]+"\t");
           //Close the output stream
           out.close();
           }catch (Exception e){//Catch exception if any
          System.err.println("Error: " + e.getMessage());
        }

  • Writing an integer array to a file...

    Okay, so I just wanna write a sorted integer array to file... but I'm having a problem or two.
    int[] array = read(new File("C:\\college work\radixsort.txt");
    radixSort(array, array.length);That text file is a list of 30 numbers.
    After the radixSort method is called the values in the text file are sorted into the correct order. Then I want to write the sorted values to a text file radixSorted.txt
    I had too many problems with printArray() so I figured this could be easier.
    I have tried FileInputStream and FileWriter but no luck.
    I don't want the answer, but just something to help point me in the right direction.
    Thank you.

    pri.println(char[] x) looks like the one I am looking for.
    I have modified the code. I've placed only the println part inside the loop now, but it's just the pri.println(char[], array) now. I'm nearrrrly there! (I think).
    try
                   PrintWriter pri = new PrintWriter(new FileWriter("C:/college work/radixsort.txt", true));
                   for (int h = 0; h < array.length; h++)
                        pri.println(char[], array);
              catch (Exception e)
                   e.printStackTrace();
                   System.out.println("No such file exists.");
              finally
                   pri.close();
              }Edited by: JayJay88 on Nov 8, 2008 1:16 PM

  • How to find the nearlest value in 1-D array ?

    Hi.. everybody..
    I need to seperate the raw data(1-D) into 2 group of array by the center value and then make the average value in each array. But I also still have the problem about if the center value is not the same of some value in the 1-D array. I cannot use the split function.
    "How to find the nearlest value to the center point that I calculated, in the 1-D array ?"
    Thanks a lot for anybody help

    In a general sense, since I'm not sure what your data values are or how far away your calculated center is from the true value, I would do it one of two ways:
    1) Use a threshold value and scan the array until the threshold is reached (assumes constantly increasing values in the array).
    2) Use either a) round to nearest integer b) round to + Infinity (round up) or c) round to - infinity (round down). If you don't have decimal values, you'll have to devide the values by a power of 10.
    2006 Ultimate LabVIEW G-eek.

  • How to bind SelectManyChoice to Integer array parameter

    Hi.
    I am using JDev TP4. I need to populate an integer array with the keys of the items selected in a SelectManyChoice.
    I have created a page with a parameter form for the three parameters and a readonly table for the result class from a data control for this method:
    public FreeGuaranteeModel[] getFreeGuarantees(Timestamp firstDate, Timestamp lastDate, Integer[] companyIds)
    In the parameter form i have created a SelectManyChoice which displays a list
    from a viewObject by dragging the companyIds parameter onto the parameter form, creating a SelectSingle component and then converted it to a SelectManyChoice.
    The page renders ok, I can select one or more items in the list, but when I press the button to execute the method, the companyIds array is empty.
    (The two date parameters are populated).
    What am I missing? Is the binding wrong? I am new to JDev so if there is some other way to do this, please let me know.
    This is the relevant part of the jspx:
    <af:selectManyChoice value="#{bindings.companyIds.inputValue}"
              label="#{bindings.companyIds.label}"
              shortDesc="#{bindings.companyIds.hints.tooltip}"
              binding="#{backing_ViewFinancialResult.selectOneListbox1}"
              id="selectOneListbox1">
    <f:selectItems value="#{bindings.companyIds.items}"
         binding="#{backing_ViewFinancialResult.selectItems1}"
         id="selectItems1"/>
    </af:selectManyChoice>
    The pagedef contains this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel"
    version="11.1.1.49.49" id="ViewFinancialResultPageDef"
    Package="com.ispartner.gvg.pageDefs">
    <parameters/>
    <executables>
    <variableIterator id="variables">
    <variable Type="java.sql.Timestamp" Name="getFreeGuarantees_firstDate"
    IsQueriable="false"/>
    <variable Type="java.sql.Timestamp" Name="getFreeGuarantees_lastDate"
    IsQueriable="false"/>
    <variable Type="java.lang.Integer[]" Name="getFreeGuarantees_companyIds"
    IsQueriable="false"/>
    </variableIterator>
    <methodIterator Binds="getFreeGuarantees.result"
    DataControl="CapacityReader" RangeSize="25"
    BeanClass="com.ispartner.gvg.util.capacity.FreeGuaranteeModel"
    id="getFreeGuaranteesIterator"
    RefreshCondition="#{adfFacesContext.postback == true}"
    Refresh="renderModelIfNeeded"/>
    <iterator Binds="CompanyLOV1" RangeSize="-1"
    DataControl="ChoiceListAMDataControl" id="CompanyLOV1Iterator"/>
    </executables>
    <bindings>
    <methodAction id="getFreeGuarantees" RequiresUpdateModel="true"
    Action="invokeMethod" MethodName="getFreeGuarantees"
    IsViewObjectMethod="false" DataControl="CapacityReader"
    InstanceName="CapacityReader.dataProvider"
    ReturnName="CapacityReader.methodResults.getFreeGuarantees_CapacityReader_dataProvider_getFreeGuarantees_result">
    <NamedData NDName="firstDate" NDType="java.sql.Timestamp"
    NDValue="${getFreeGuarantees_firstDate}"/>
    <NamedData NDName="lastDate" NDType="java.sql.Timestamp"
    NDValue="${getFreeGuarantees_lastDate}"/>
    <NamedData NDName="companyIds" NDType="java.lang.Integer[]"
    NDValue="${bindings.getFreeGuarantees_companyIds}"/>
    </methodAction>
    <attributeValues IterBinding="variables" id="firstDate">
    <AttrNames>
    <Item Value="getFreeGuarantees_firstDate"/>
    </AttrNames>
    </attributeValues>
    <attributeValues IterBinding="variables" id="lastDate">
    <AttrNames>
    <Item Value="getFreeGuarantees_lastDate"/>
    </AttrNames>
    </attributeValues>
    <tree IterBinding="getFreeGuaranteesIterator" id="FreeGuaranteeModel">
    <nodeDefinition DefName="com.ispartner.gvg.util.capacity.FreeGuaranteeModel">
    <AttrNames>
    <Item Value="companyId"/>
    <Item Value="name"/>
    <Item Value="guaranteeRequired"/>
    <Item Value="guaranteeToDate"/>
    <Item Value="guaranteeAmount"/>
    <Item Value="bookedValue"/>
    <Item Value="freeGuarantee"/>
    </AttrNames>
    </nodeDefinition>
    </tree>
    <list IterBinding="variables" id="companyIds" DTSupportsMRU="false"
    StaticList="false" ListIter="CompanyLOV1Iterator"
    NullValueFlag="start" NullValueId="companyIds_null">
    <AttrNames>
    <Item Value="getFreeGuarantees_companyIds"/>
    </AttrNames>
    <ListAttrNames>
    <Item Value="CompanyId"/>
    </ListAttrNames>
    <ListDisplayAttrNames>
    <Item Value="ShortName"/>
    </ListDisplayAttrNames>
    </list>
    </bindings>
    <ResourceBundle>
    <PropertiesBundle xmlns="http://xmlns.oracle.com/adfm/resourcebundle"
    PropertiesFile="com.ispartner.gvg.gvg-webBundle"/>
    </ResourceBundle>
    </pageDefinition>
    Regards,
    TL

    Hi,
    Thank you for your answer.
    Following the example I was able to get the selected entries into an Integer array property with accessors which I created in a managed bean.
    But I have not been able to get the values into the companyIds parameter of the method to execute.
    Is there a way to bind directly to this parameter, or do I have to collect all parameters through separate properties and then call my method manually when the button is pressed?
    TL

  • Suggestion: Macros or a way to unroll loops? Integer array input? Shader Model 3 and 4?

    I think it would be nice if pixel bender supported a way to unroll loops. In it's current state certain shaders are really awkward to write or just get ugly when they're converted for flash player. I know it wouldn't be that hard for the developers to just unroll constant sized loops. Things such as:
    for (int i = 0; i < 10; ++i)
      if (foo) { ... }
    can be unrolled easily. Either that or add in some code generation feature that allows this with a preprocessor system. Or better yet add in support for loops since it only requires shader model 3 or equivelant from GLSL.
    This brings me onto another point. Is there going to be support for Shader Model 4? I'm talking about bitwise operations and integer types. Even if you don't allow native support for byte array adding texture sampling for bytes, shorts, and integers would be nice. Also allowing this to work in flash would be nice with the ability to tell the user they don't have shader model 4 or be able to detect compatability and use a different shader.
    Integer arrays would be nice to allow to as input then to the shader. I noticed the reference manual already mentioned:
    "NOTE: Pixel Bender 1.0 supports only arrays of floats, and the array size is a compile-time constant. Future versions of Pixel Bender will allow arrays to be declared with a size based on kernel parameters, which will enable parameter-dependent look-up table sizes."
    Again support for these features in flash player would be really nice.
    Targetting the lowest GPUs is really limiting the true power of pixel bender. I wrote this for fun: http://assaultwars.com/pictures/raycasting6.png which is just a simple real-time voxel raycaster. However, it could be so much more powerful if pixel bender supported more of the GPUs features. Even simple things like custom functions would be really handy in flash player. I'm thinking of this more oriented toward flash games too where more powerful features are unlocked based on the user's GPU.
    If this is already planned for a future pixel bender release then nevermind. I didn't see a developers blog or any news about future versions.
    Interesting:
    http://forums.adobe.com/thread/36659?tstart=60
    Apparently Kevin said "Look for them in a future version of the language as cards that support  these features become common." in regards to bitwise operators aka Shader Model 4.

    Here's an example, not using NetBeans:
    import javax.swing.*;
    public class TextDemo extends JPanel
        public TextDemo()
            int[] newbinarray = {0, 1, 1};
            StringBuffer sb = new StringBuffer();
            for (int value : newbinarray)
                sb.append(value);
            String st = new String(sb);
            this.add(new JTextField(st));
        private static void createAndShowGUI()
            JFrame frame = new JFrame("TextDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new TextDemo());
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }

  • 2 parts: 1) integer array to string 2) string out to a jTextField

    I am completely new to Java and Netbeans, but I'm writing my 1st
    application that takes a "hex" character input from a jTextField,
    then converts it to an "binary" integer array. I then do a lot of bit
    manipulation, and generate a new "binary" integer array.
    String myhex = jTextField1.getText();
        int len = myhex.length();
        int[] binarray = new int[len*4];
            for (int i = 0; i < len; i++) {
               if (myhex.charAt(i) == '0'){
                  binarray[4*i]=0;
                  binarray[4*i+1]=0;
                  binarray[4*i+2]=0;
                  binarray[4*i+3]=0;
               else if (myhex.charAt(i) ==
               // repeat for '1 to 9' and 'a-f/A-F'
               // generate new integer array(s) using various bits from binarrayI realize it might not be the best way to do the
    conversion, but my input can be of arbitrary length,
    and it is my first time trying to write Java code.
    All of the above I've completed and it works...(thanks Netbeans
    for making the gui interface design a real breeze!)
    So I end up with:
    binarray[0]=0 or 1
    binarray[1]=0 or 1
    binarray[2]=0 or 1
    binarray[n]=0 or 1
    Where n can be any number from 0 to 63...
    I then manipulate the bits in binarray creating a new integer array
    and for the sake of expediency let's call it "newbinarray".
    newbinarray[0]=0 or 1
    newbinarray[1]=0 or 1
    newbinarray[2]=0 or 1
    newbinarray[n]=0 or 1
    Where n can be any number from 0 to 63...
    I first need to know how to convert this "newbinarray" integer array to a string.
    In the simplest terms if the first three elements of the array are [0][1][1],
    I want the string to be 011.
    Then I want to take this newly formed string and output it to a jTextField.
    string 011 output in JTextField as 011
    I've scoured the net, and I've seen a lot of complex answers involving
    formatting, but I'm looking for just a simple answer here so I can finish
    this application as quickly as possible.
    Thanks,
    Thorne Kontos

    Here's an example, not using NetBeans:
    import javax.swing.*;
    public class TextDemo extends JPanel
        public TextDemo()
            int[] newbinarray = {0, 1, 1};
            StringBuffer sb = new StringBuffer();
            for (int value : newbinarray)
                sb.append(value);
            String st = new String(sb);
            this.add(new JTextField(st));
        private static void createAndShowGUI()
            JFrame frame = new JFrame("TextDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new TextDemo());
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }

  • How to set variable value in an XML array

    Hi,
    Please let me know how to set the value for a xml array element using assign activity inside a for-each block in BPEL 11g
    I tried to set the variable value for result element using the below condition but i encountered selection failure message
    $outputVariable.payload/ns1:Student['i']/ns1:result or
    $outputVariable.payload/ns1:Student[$i]/ns1:result
    And the xsd used is as below
    <xsd:complexType name="StudentCollection">
    <xsd:sequence>
    <xsd:element name="Student" type="Student" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Student">
    <xsd:sequence>
    <xsd:element name="Name" type="xsd:string"/>
    <xsd:element name="location" type="xsd:string"/>
    <xsd:element name="mark" type="xsd:string"/>
    <xsd:element name="result" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    Thanks,
    Dhana

    Hi,
    At the back of button specify the following parameter:-
    CMD    1        Execute_planning_function
    Planning_function_name  1   xyz
    Var_name     1    variable_name
    var_value      1    blank
    Can also refer to link below:-
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0a89464-f697-2910-2ba6-9877e3088954?quicklink=index&overridelayout=true(can refer to page 20)
    http://www.sdn.sap.com/ddc5564a-337d-4cf9-a34e-2dab64df09be/finaldownload/downloadid-a61a6724ba8e7b7fbd9c5df9590ab50d/ddc5564a-337d-4cf9-a34e-2dab64df09be/irj/scn/go/portal/prtroot/docs/library/uuid/f0881371-78a1-2910-f0b8-af3e184929be?quicklink=index&overridelayout=true
    Hope it may help

  • Code for how to read an integer array from the command prompt...

    hello,
    Could anyone give me the code for how to read an integer array from the command prompt...its very urgent!..

    If you are using a recent version of Java (5 or later) you can use Scanner:
    http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
    That page has some example code on it, too.

  • How to change the value in an Integer object?

    Hi,
    Is it possible to change the value that is contained in an Integer object.
    I know Integer objects are immutable. So it might not be possible to chage to value in an integer object once its been initalized a value @ the time of construction.
    Also does autoboxing and unboxing feature of 1.5 help acheive this?
    Please let me know of any other alternative
    Thanks
    Deepak

    Tried the autoboxing and unboxing feature doesnt
    help.It doesn't help in general. But in this special case it doesn't help because it doesn't anything to do with it. Do you really know what you're doing?
    So across the function its not changing the value.
    As I have created an object of Integer class and
    passed a reference of that object into the chage()
    ,So any changes should have been reflected
    acrosss method calls.?Since you let the newly created parameter-reference a point to a new Integer object: no. Why? You have two references to I(31). Then you move one reference to I(33). Why should 31 get another value?
    Does the the java compiler creates a new Integer
    object each time it does autoboxing Not necessarily. Some values are pooled. Actualy, the JVM does it. The compiler never creates any object.
    so that the value
    is lost across method calls?That's not the compiler's or the JVM's fault. It's all a misconception of yours.
    Is there any means to achieve this?What for?
    int a = 0;
    a = change(a);
    int change (final int i) {
      return i + 12;
    }Does exactly what you want, without side-effects.

  • Problem trying to compare 2 values of type Integer in IF condition

    I havd pop a value of type Integer from a stack into a variable, but the If conditions does not seem to work:
    iqueuedVar = conn3.removeFromFeed();
    System.out.println(iqueuedVar);
    Integer test = new Integer(123);
    if(test == iqueuedVar)
    System.out.println("It Works !!");
    The Integer test searched for the popped value 123 - which exists - but the IF condition is not working.
    I'm using API 1.4.2 - Please help ?

    I havd pop a value of type Integer from a stack into
    a variable, but the If conditions does not seem to
    work:
    iqueuedVar = conn3.removeFromFeed();
    System.out.println(iqueuedVar);
    Integer test = new Integer(123);
    if(test == iqueuedVar)
    System.out.println("It Works !!");
    The Integer test searched for the popped value 123 -
    which exists - but the IF condition is not working.
    I'm using API 1.4.2 - Please help ?get the int value from Integer.Then compare two int value

  • Access values stored in 2D Array in HashMap

    Hi everyone i would like to know how to access values stored in a 2D array inside a HashMap
    Here is a drawing representation of the map.
    So to get the KEYS I just have to execute this code:
    this.allPeople = personInterests.keySet();But how can I get acces to the actual values inside the 2D Array?
    My goal is to create a treeSet and store all the elements of the first array in it, then look at the second array if any new elements are detected add them to the treeset, then third array and so on.
    I tried this code:
    Object[] bands = personInterests.values().toArray();
         for( int i=0; i<bands.length; i++)
              this.allBands.add(bands.toString());
    }But this.allBands.add(bands[i].toString())seems to be the problem, Dealing with a 2D array, this code only return a string representation of the Arrays and not a string representation of their elements.
    Using my logic I tried to execute:
       this.allBands.add(bands[0][i].toString());But i get a ARRAY REQUIRED BUT JAVA.LANG.OBJECT FOUND
    I really don't know the way to go.
    Thanks to anyone that will help.
    Regards, Damien.
    Edited by: Fir3blast on Mar 3, 2010 5:27 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You'll just need to cast the object to the correct type. This is nothing to do with HashMap at all. If you don't know what that means then your google keywords are "java cast tutorial".

  • Passing a integer array  client to server

    Hi
    Is it possible to pass integer array from client to server
    Through soap.
    Basically i want to pass this array buffer
    int[] buffer = new int[(int)len];
         for(int i=0;i<len;i++){
              buffer[i] = F.read();
              System.out.print(buffer[i]+ " ");
    Nams Thanks

    Yes, if the server is written to accept one.
    To create a server to accept one, create a service endpoint
    interface that has a method that takes a int[] as a parameter and
    generate the service from that by following the steps in the jaxrpc
    tutorial. Then generate the client from the generated WSDL.

Maybe you are looking for