1
6 import java.awt.geom.*;
7 import java.awt.*;
8 import java.awt.Graphics2D.*;
9 import java.awt.print.*;
10 import java.util.*;
11 import java.io.*;
12
13 public class Picture extends Box {
14
15 private static final long serialVersionUID = Version.getSUID();
16
17 public ImageFile contents = null;
18 int width;
19 int height;
20
21 public Picture() {
22 super(new Point2D.Double(0,0),null,null);
23 }
24
25 public Picture(Point2D where,View view,Object arg) {
26 super(where,view,null);
27
28 contents = (ImageFile)arg;
29 Image image = contents.getImage();
30
31 if (image!=null) {
32 try {
33 for (width= -1;width<=0;width = image.getWidth(null)) Thread.sleep(50);
34 for (height= -1;height<=0;height = image.getHeight(null)) Thread.sleep(50);
35 } catch(InterruptedException e){ErrorLog.exception(e);};
36 }
37
38 subaspect = ((double)height)/width;
39
40 reshape();
41 }
42
43 public void copy(Page that) {
44 super.copy(that);
45 }
46
47 public boolean valid() {return(contents!=null);}
48
49 public void paintContents(View view) {
50 if (!view.visible.isMember(this)) return;
51 Image image = contents.getImage();
52
53 if (image!=null) {
54
55 AffineTransform trans = (AffineTransform)view.trans.clone();
56
57
58 trans.translate(-0.5,subaspect/2);
59 trans.scale(1.0/width,-1.0/width);
60 view.draw.drawImage(image,trans,view.observer);
61 }
62 }
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 }
86
87