forked from External/mage
changed the type used in ImagePanel from an int to an enum
This commit is contained in:
parent
0a77c186be
commit
4aaf73e0d2
9 changed files with 61 additions and 56 deletions
|
|
@ -9,20 +9,18 @@ import javax.swing.JViewport;
|
|||
|
||||
@SuppressWarnings("serial")
|
||||
public class ImagePanel extends JPanel {
|
||||
public static final int TILED = 0;
|
||||
public static final int SCALED = 1;
|
||||
public static final int ACTUAL = 2;
|
||||
|
||||
|
||||
private BufferedImage image;
|
||||
private int style;
|
||||
private ImagePanelStyle style;
|
||||
private float alignmentX = 0.5f;
|
||||
private float alignmentY = 0.5f;
|
||||
|
||||
public ImagePanel(BufferedImage image) {
|
||||
this(image, TILED);
|
||||
this(image, ImagePanelStyle.TILED);
|
||||
}
|
||||
|
||||
public ImagePanel(BufferedImage image, int style) {
|
||||
public ImagePanel(BufferedImage image, ImagePanelStyle style) {
|
||||
this.image = image;
|
||||
this.style = style;
|
||||
setLayout(new BorderLayout());
|
||||
|
|
@ -65,18 +63,16 @@ public class ImagePanel extends JPanel {
|
|||
return;
|
||||
|
||||
switch (style) {
|
||||
case TILED:
|
||||
drawTiled(g);
|
||||
break;
|
||||
|
||||
case SCALED:
|
||||
Dimension d = getSize();
|
||||
g.drawImage(image, 0, 0, d.width, d.height, null);
|
||||
break;
|
||||
|
||||
case ACTUAL:
|
||||
drawActual(g);
|
||||
break;
|
||||
case TILED:
|
||||
drawTiled(g);
|
||||
break;
|
||||
case SCALED:
|
||||
Dimension d = getSize();
|
||||
g.drawImage(image, 0, 0, d.width, d.height, null);
|
||||
break;
|
||||
case ACTUAL:
|
||||
drawActual(g);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue