1    /*
2    Copyright 2003 by Ralph Hartley
3    This software is licenced under the terms of the
4    Gnu Public Licence
5    */
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   //      if (view.draw.getClip().intersects(getBounds(trans))) {
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   //  public int getLevel() {return(super.getLevel()+1);}
65   
66   //  transient PrefPage prefs = null;
67   
68   //  public void getPropertyEdit(Object[] edits,int slot,Set sub) {
69   //    prefs = new PrefPage(this);
70   //    edits[slot] = prefs.getPane(null);
71   //    ((Component)edits[slot]).setName("Page");
72   //    super.getPropertyEdit(edits,slot-1,sub);
73   //  }
74   
75   //  public void acceptPropertyEdit() {
76   //    super.acceptPropertyEdit();
77   //    prefs.save();
78   //    prefs = null;
79   //  }
80   
81   //  public void abandonPropertyEdit() {
82   //    prefs = null;
83   //    super.abandonPropertyEdit();
84   //  }
85   }
86   
87