docs/examples/ImageWithMetaData.java
/**
     * Generates image for a table
     *
     * @param section metadata information
     * @return image
     */
Generates image for a table
@param section metadata information
@return image
Generates image for a table @param section metadata information @return image
private static BufferedImage printMetadataInformation(Section section) {
        String[] columnNames = {"Name", "Value"};
        List<Property> properties = section.getProperties();
        Object[][] data = new Object[properties.size()][2];
        for (int i = 0; i < data.length; i++) {
            Property property = properties.get(i);
            data[i][0] = property.getName();
            data[i][1] = property.getValues().get(0).getString();
        }
        JTable table = new JTable(data, columnNames);
        table.setRowHeight(30);
        table.getColumnModel().getColumn(0).setWidth(100);
        table.getColumnModel().getColumn(1).setWidth(200);
        table.setSize(300, 30 * data.length);
        BufferedImage bi = new BufferedImage(table.getWidth(), table.getHeight(), BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = bi.createGraphics();
        table.getTableHeader().paint(graphics);
        table.paint(graphics);
        graphics.dispose();
        return bi;
    }
private static BufferedImage printMetadataInformation ( Section section ) { String [ ] columnNames = { "Name" , "Value" } ; List < Property > properties = section . getProperties ( ) ; Object [ ] [ ] data = new Object [ properties . size ( ) ] [ 2 ] ; for ( int i = 0 ; i < data . length ; i ++ ) { Property property = properties . get ( i ) ; data [ i ] [ 0 ] = property . getName ( ) ; data [ i ] [ 1 ] = property . getValues ( ) . get ( 0 ) . getString ( ) ; } JTable table = new JTable ( data , columnNames ) ; table . setRowHeight ( 30 ) ; table . getColumnModel ( ) . getColumn ( 0 ) . setWidth ( 100 ) ; table . getColumnModel ( ) . getColumn ( 1 ) . setWidth ( 200 ) ; table . setSize ( 300 , 30 * data . length ) ; BufferedImage bi = new BufferedImage ( table . getWidth ( ) , table . getHeight ( ) , BufferedImage . TYPE_INT_RGB ) ; Graphics2D graphics = bi . createGraphics ( ) ; table . getTableHeader ( ) . paint ( graphics ) ; table . paint ( graphics ) ; graphics . dispose ( ) ; return bi ; }
Generates image for a table
 @param section metadata information
 @return image
Generates image for a table @param section metadata information @return image
// header names // attached information // create table // create image