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.*;

import java.util.List;

public class Main {
    public static BufferedImage drawBoundingBoxes(BufferedImage canvas, Rectangle[] boxes, Color fgColour,
            Color bgColour) {
        Graphics2D g2d = canvas.createGraphics();
        for (int i = 0; i < boxes.length; i++) {
            g2d.setColor(bgColour);
            g2d.drawRect(boxes[i].x - 1, boxes[i].y - 1, boxes[i].width + 2, boxes[i].height + 2);
            g2d.drawRect(boxes[i].x + 1, boxes[i].y + 1, boxes[i].width - 2, boxes[i].height - 2);
            g2d.setColor(fgColour);
            g2d.drawRect(boxes[i].x, boxes[i].y, boxes[i].width, boxes[i].height);
        }

        return canvas;
    }

    public static BufferedImage drawBoundingBoxes(BufferedImage canvas, Rectangle[] boxes, Color fgColour) {
        return drawBoundingBoxes(canvas, boxes, fgColour, Color.WHITE);
    }

    public static BufferedImage drawBoundingBoxes(BufferedImage canvas, List<Rectangle> boxes, Color fgColour,
            Color bgColour) {
        Graphics2D g2d = canvas.createGraphics();
        for (Rectangle r : boxes) {
            g2d.setColor(bgColour);
            g2d.drawRect(r.x - 1, r.y - 1, r.width + 2, r.height + 2);
            g2d.drawRect(r.x + 1, r.y + 1, r.width - 2, r.height - 2);
            g2d.setColor(fgColour);
            g2d.drawRect(r.x, r.y, r.width, r.height);
        }

        return canvas;
    }

    public static BufferedImage drawBoundingBoxes(BufferedImage canvas, List<Rectangle> boxes, Color fgColour) {
        return drawBoundingBoxes(canvas, boxes, fgColour, Color.WHITE);
    }
}