Here is my code.
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
public class Test {
public static void main(String args[]) throws IOException{
int width = 400, height = 400;
Test plot = new Test();
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics();
g2d.setPaint(Color.red);
g2d.draw(new Line2D.Double(0,0,0,50));
g2d.draw(new Line2D.Double(0,50,50,50));
g2d.draw(new Line2D.Double(50,50,50,0));
g2d.draw(new Line2D.Double(50,0,0,0));
ImageIO.write(bi, "PNG", new File("d:\\sample.PNG"));
}
}
You can see the output image above.
Now, Since the square looks very small(I tried varying the width and height), I need to scale this up programmatically. (As I need to show the path traveled by the robot). How can I do it? Please help.
Please note that shape is more important here not the dimension.