source: winedb/src/utils/DynamicImage.java@ 9b6a069

Last change on this file since 9b6a069 was 9b6a069, checked in by dportnoy <devnull@…>, 13 years ago

Initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1package utils;
2
3import java.awt.*;
4import java.awt.image.*;
5
6public class DynamicImage {
7 private String filePath;
8 private BufferedImage img;
9 private Color bg, shadow;
10
11 public DynamicImage(String filePath) {
12 this.filePath = filePath;
13 img = null;
14 bg = shadow = null;
15 }
16
17 public DynamicImage(String filePath, Color bg, Color shadow) {
18 this.filePath = filePath;
19 img = null;
20 this.bg = bg;
21 this.shadow = shadow;
22 }
23
24 private void loadImg() {
25 if(bg == null)
26 img = Utils.loadImg(filePath);
27 else
28 img = Utils.loadTransImg(filePath, bg, shadow);
29 }
30
31 public int getHeight() {
32 if(img == null)
33 loadImg();
34 return img.getHeight();
35 }
36
37 public int getWidth() {
38 if(img == null)
39 loadImg();
40 return img.getWidth();
41 }
42
43 public void draw(Graphics g, int x, int y) {
44 if(img == null)
45 loadImg();
46 g.drawImage(img, x, y, null);
47 }
48
49 public void draw(Graphics g, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
50 if(img == null)
51 loadImg();
52 g.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
53 }
54}
Note: See TracBrowser for help on using the repository browser.