docs/examples/ImageWithMetaData.java
/**
     * Function to plot data
     *
     * @param dataArray data array
     */
Function to plot data
@param dataArray data array
Function to plot data @param dataArray data array
private static void plotData(DataArray dataArray) {
        try {
            byte[] img_data = new byte[(int) dataArray.getDataExtent().getElementsProduct()];
            dataArray.getData(img_data, dataArray.getDataExtent(), new NDSize());
            BufferedImage img1 = ImageIO.read(new ByteArrayInputStream(img_data));
            BufferedImage img2 = printMetadataInformation(dataArray.getMetadata());
            int w = img1.getWidth() + img2.getWidth();
            int h = Math.max(img1.getHeight(), img2.getHeight());
            BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g = combined.createGraphics();
            g.setBackground(Color.WHITE);
            g.clearRect(0, 0, combined.getWidth(), combined.getHeight());
            g.drawImage(img1, 0, 0, null);
            g.drawImage(img2, img1.getWidth(), 0, null);
            ImageIO.write(combined, "png", new java.io.File("image_with_metadata_output.png"));
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
private static void plotData ( DataArray dataArray ) { try { byte [ ] img_data = new byte [ ( int ) dataArray . getDataExtent ( ) . getElementsProduct ( ) ] ; dataArray . getData ( img_data , dataArray . getDataExtent ( ) , new NDSize ( ) ) ; BufferedImage img1 = ImageIO . read ( new ByteArrayInputStream ( img_data ) ) ; BufferedImage img2 = printMetadataInformation ( dataArray . getMetadata ( ) ) ; int w = img1 . getWidth ( ) + img2 . getWidth ( ) ; int h = Math . max ( img1 . getHeight ( ) , img2 . getHeight ( ) ) ; BufferedImage combined = new BufferedImage ( w , h , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g = combined . createGraphics ( ) ; g . setBackground ( Color . WHITE ) ; g . clearRect ( 0 , 0 , combined . getWidth ( ) , combined . getHeight ( ) ) ; g . drawImage ( img1 , 0 , 0 , null ) ; g . drawImage ( img2 , img1 . getWidth ( ) , 0 , null ) ; ImageIO . write ( combined , "png" , new java . io . File ( "image_with_metadata_output.png" ) ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } }
Function to plot data
 @param dataArray data array
Function to plot data @param dataArray data array
// image // table // joining both images // paint both images // write to file