How to mirror an image with Java.awt

I have an assignment to be done in Java, and I can't figure this out for the life of me. I'm supposed to use Graphics2D and Java.AWT. to mirror an image across both the x-axis and y-axis.

Current code is:

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
public class DrawingImages
{
private Picture newCanvas = null;
private Graphics g = null;
private Graphics2D g2 = null;
private Picture pic1 = null;
private Picture pic2 = null;
private Color color = null;
private Pixel sourcePixel, targetPixel = null;
private Color sourceColor, targetColor = null;

DrawingImages(Picture canv, Color col)
{
    Picture sourcePicture = new Picture("WashingtonMonument.jpg");
    newCanvas = canv;
    newCanvas.setAllPixelsToAColor(Color.BLACK);
    for(int y = sourcePicture.getHeight()-1; y >0; y=y-1)
    {
        for(int x = sourcePicture.getWidth() - 1; x > 0; x = x - 1)
        {
            sourcePixel = sourcePicture.getPixel(x,y);
            sourceColor = sourcePixel.getColor();
            targetPixel = newCanvas.getPixel(x+sourcePicture.getWidth() -1,y+sourcePicture.getHeight()- 1);
            targetPixel.setColor(sourceColor);         
        }
    }


    g = newCanvas.getGraphics();
    g2 = (Graphics2D)g;  
}

}

Answer:1

Ok, I have methods like CompletableFuture fetchCar(int id); CompletableFuture runSomething(Something t, Extra d); CompletableFuture invoke(); and I would like a single method that I can use that ...

Making a runnable .jar with dependent libraries for dummys.. Can someone outline the steps I have to take to making a runnable .jar with dependent libraries for dummy with Maven and Eclipse. I want ...

When I compile a ruby file to a java class using jrubyc, I get different output when compiling with just jrubyc and with jrubyc --java (to generate the java file) and just javac. Why? Example: First ...

Say I have a 3x4x5x6 java double array a that I unroll into an ArrayList b of length 360 in the following way: for (int i = 0; i<a.length; i++){ for (int j = 0; j<a[0].length; j++){ ...