Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*****************************************************************************
 ** ANGRYBIRDS AI AGENT FRAMEWORK
 ** Copyright (c) 2013,XiaoYu (Gary) Ge, Stephen Gould,Jochen Renz
 **  Sahan Abeyasinghe, Jim Keys, Kar-Wai Lim, Zain Mubashir,  Andrew Wang, Peng Zhang
 ** All rights reserved.
 **This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 
 **To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ 
 *or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
 *****************************************************************************/

import java.awt.*;
import java.awt.image.*;

public class Main {
    public static BufferedImage highlightRegions(Image img, int[][] regions, int regionId, Color fgColour) {
        BufferedImage canvas = new BufferedImage(img.getWidth(null), img.getHeight(null),
                BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = canvas.createGraphics();
        g2d.drawImage(img, 0, 0, null);
        g2d.setColor(fgColour);
        for (int y = 0; y < regions.length; y++) {
            for (int x = 0; x < regions[y].length; x++) {
                if (regions[y][x] == regionId) {
                    g2d.drawRect(x, y, 1, 1);
                }
            }
        }

        return canvas;
    }
}