Revert "Drawers refactored. Imageloading is now in the Drawers instead of"

This reverts commit 3268268dc2.
This commit is contained in:
ericnerdo 2016-05-07 20:12:49 +02:00
parent 3268268dc2
commit 0d31d8c79b
6 changed files with 39 additions and 90 deletions

View File

@ -1,19 +1,13 @@
package cicaprojekt;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class FieldDrawer extends ImagePanel implements Drawer {
public class FieldDrawer extends JPanel implements Drawer {
private BufferedImage image;
Field field;
public FieldDrawer(Field f) throws IOException {
image = ImageIO.read(new File("Field.png"));
super("Field.png");
field = f;
setVisible(false);
}
@ -40,15 +34,4 @@ public class FieldDrawer extends JPanel implements Drawer {
return field.getY();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}
public void changeImage(String path) throws IOException {
image = ImageIO.read(new File(path));
repaint();
}
}

View File

@ -1,19 +1,13 @@
package cicaprojekt;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class GapDrawer extends ImagePanel implements Drawer{
public class GapDrawer extends JPanel implements Drawer{
private BufferedImage image;
private Gap gap;
public GapDrawer(Gap g) throws IOException {
image = ImageIO.read(new File("Gap.png"));
super("Gap.png");
gap = g;
setVisible(false);
}
@ -33,10 +27,4 @@ public class GapDrawer extends JPanel implements Drawer{
return gap.getY();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}
}

View File

@ -1,19 +1,13 @@
package cicaprojekt;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class GateDrawer extends ImagePanel implements Drawer{
public class GateDrawer extends JPanel implements Drawer{
private BufferedImage image;
Gate gate;
public GateDrawer(Gate g) throws IOException {
image = ImageIO.read(new File("ClosedGate.png"));
super("ClosedGate.png");
gate = g;
setVisible(false);
}
@ -38,15 +32,4 @@ public class GateDrawer extends JPanel implements Drawer{
return gate.getY();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}
public void changeImage(String path) throws IOException {
image = ImageIO.read(new File(path));
repaint();
}
}

View File

@ -0,0 +1,29 @@
package cicaprojekt;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class ImagePanel extends JPanel{
private BufferedImage image;
public ImagePanel(String path) throws IOException {
image = ImageIO.read(new File(path));
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}
public void changeImage(String path) throws IOException {
image = ImageIO.read(new File(path));
repaint();
}
}

View File

@ -1,19 +1,13 @@
package cicaprojekt;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class ScaleDrawer extends ImagePanel implements Drawer {
public class ScaleDrawer extends JPanel implements Drawer {
private BufferedImage image;
Scale scale;
public ScaleDrawer(Scale s) throws IOException {
image = ImageIO.read(new File("Scale.png"));
super("Scale.png");
scale = s;
setVisible(false);
}
@ -38,15 +32,4 @@ public class ScaleDrawer extends JPanel implements Drawer {
return scale.getY();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}
public void changeImage(String path) throws IOException {
image = ImageIO.read(new File(path));
repaint();
}
}

View File

@ -1,19 +1,13 @@
package cicaprojekt;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class WallDrawer extends ImagePanel implements Drawer {
public class WallDrawer extends JPanel implements Drawer {
private BufferedImage image;
Wall wall;
public WallDrawer(Wall w) throws IOException {
image = ImageIO.read(new File("Wall.png"));
super("Wall.png");
wall = w;
setVisible(false);
}
@ -52,15 +46,4 @@ public class WallDrawer extends JPanel implements Drawer {
return wall.getY();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}
public void changeImage(String path) throws IOException {
image = ImageIO.read(new File(path));
repaint();
}
}