1    /*
2    Copyright 2000 by Ralph Hartley
3    This software is licenced under the terms of the
4    Gnu Public Licence
5    */
6    import java.awt.*;
7    import java.awt.geom.*;
8    import java.io.*;
9    
10   public class SavableRectangle2D extends Rectangle2D.Double implements Serializable {
11     private static final long serialVersionUID = Version.getSUID();
12   
13     public SavableRectangle2D(Rectangle2D rect) {
14       this.x = rect.getX();
15       this.y = rect.getY();
16       this.width = rect.getWidth();
17       this.height = rect.getHeight();
18     }
19   
20     public SavableRectangle2D(double x, double y, double width, double height) {
21       this.x = x;
22       this.y = y;
23       this.width = width;
24       this.height = height;
25     }
26   
27     public SavableRectangle2D(Rectangle2D rect,double xfact,double yfact) {
28       this.x = rect.getX()*xfact;
29       this.y = rect.getY()*yfact;
30       this.width = rect.getWidth();
31       this.height = rect.getHeight();
32     }
33   
34     private void readObject(java.io.ObjectInputStream stream)
35         throws java.io.IOException,java.lang.ClassNotFoundException {
36       x = stream.readDouble();
37       y = stream.readDouble();
38       width = stream.readDouble();
39       height = stream.readDouble();
40     }
41   
42     private void writeObject(java.io.ObjectOutputStream stream)
43         throws java.io.IOException {
44       stream.writeDouble(x);
45       stream.writeDouble(y);
46       stream.writeDouble(width);
47       stream.writeDouble(height);
48     }
49   }
50