package com.johnuckele.vivarium.visualization.animation;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.ImageObserver;

import javax.swing.ImageIcon;

import com.johnuckele.vivarium.core.Direction;
import com.johnuckele.vivarium.visualization.GraphicalSystem;

public class SwingGraphics extends GraphicalSystem
{
    private static ImageIcon IMAGE_ICON = new ImageIcon("src/main/resources/sprites.png");
    private static Image IMAGE = IMAGE_ICON.getImage();

    private Graphics2D _graphics;
    private ImageObserver _observer;

    public SwingGraphics()
    {

    }

    public void setResources(Graphics2D graphics, ImageObserver observer)
    {
        _graphics = graphics;
        _observer = observer;
    }

    @Override
    public void drawImage(int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Direction heading)
    {
        _graphics.rotate(-Direction.getRadiansFromNorth(heading), (dx1 + dx2) / 2, (dy1 + dy2) / 2);
        _graphics.drawImage(IMAGE, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, _observer);
        _graphics.rotate(Direction.getRadiansFromNorth(heading), (dx1 + dx2) / 2, (dy1 + dy2) / 2);

    }

}

@@ -221,70 +221,8 @@
 ion;
-%0Aimport com.johnuckele.vivarium.visualization.GraphicalSystem;
 %0A%0Apu
@@ -890,32 +890,34 @@
  (dx1 + dx2) / 2
+.0
 , (dy1 + dy2) / 
@@ -917,16 +917,18 @@
 dy2) / 2
+.0
 );%0A     
@@ -1089,16 +1089,18 @@
 dx2) / 2
+.0
 , (dy1 +
@@ -1108,16 +1108,18 @@
 dy2) / 2
+.0
 );%0A%0A    

Fix to division by int warning